@itwin/core-frontend 5.10.0-dev.11 → 5.10.0-dev.12

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.
@@ -144,11 +144,11 @@ export declare class BriefcaseConnection extends IModelConnection {
144
144
  hasPendingTxns(): Promise<boolean>;
145
145
  /** Commit pending changes to this briefcase.
146
146
  * @param description Optional description of the changes.
147
- * @deprecated in 5.1.9 - will not be removed until after 2027-05-04. Use methods on EditCommand instead.
147
+ * @deprecated in 5.9.0 - will not be removed until after 2027-05-04. Use methods on EditCommand instead.
148
148
  */
149
149
  saveChanges(description?: string): Promise<void>;
150
150
  /** Abandon pending changes to this briefcase.
151
- * @deprecated in 5.1.9 - will not be removed until after 2027-05-04. Use methods on EditCommand instead.
151
+ * @deprecated in 5.9.0 - will not be removed until after 2027-05-04. Use methods on EditCommand instead.
152
152
  */
153
153
  abandonChanges(): Promise<void>;
154
154
  /** Pull (and potentially merge if there are local changes) up to a specified changeset from iModelHub into this briefcase
@@ -248,13 +248,13 @@ class BriefcaseConnection extends IModelConnection_1.IModelConnection {
248
248
  }
249
249
  /** Commit pending changes to this briefcase.
250
250
  * @param description Optional description of the changes.
251
- * @deprecated in 5.1.9 - will not be removed until after 2027-05-04. Use methods on EditCommand instead.
251
+ * @deprecated in 5.9.0 - will not be removed until after 2027-05-04. Use methods on EditCommand instead.
252
252
  */
253
253
  async saveChanges(description) {
254
254
  await IpcApp_1.IpcApp.appFunctionIpc.saveChanges(this.key, description); // eslint-disable-line @typescript-eslint/no-deprecated
255
255
  }
256
256
  /** Abandon pending changes to this briefcase.
257
- * @deprecated in 5.1.9 - will not be removed until after 2027-05-04. Use methods on EditCommand instead.
257
+ * @deprecated in 5.9.0 - will not be removed until after 2027-05-04. Use methods on EditCommand instead.
258
258
  */
259
259
  async abandonChanges() {
260
260
  await IpcApp_1.IpcApp.appFunctionIpc.abandonChanges(this.key); // eslint-disable-line @typescript-eslint/no-deprecated
@@ -1 +1 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oBAAoB;YACpC,gBAAgB,EAAE,OAAO,EAAE,gBAAgB;YAC3C,kBAAkB,EAAE,CAAC,CAAC,OAAO,EAAE,WAAW;SAC3C,CAAC;QACF,IAAI,CAAC;YACH,IAAI,CAAC,SAAS,GAAG,MAAM,eAAM,CAAC,cAAc,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,EAAE,OAAO,EAAE,aAAa,CAAC,CAAC;QAC7F,CAAC;gBAAS,CAAC;YACT,eAAe,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC;QAChD,CAAC;IACH,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,WAAW,CAAC,WAAmB;QAC1C,IAAI,CAAC,eAAe,EAAE,CAAC;QACvB,OAAO,eAAM,CAAC,cAAc,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;IAClE,CAAC;IAED;;OAEG;IACH,IAAW,YAAY;QACrB,OAAO,IAAI,CAAC,cAAc,CAAC,YAAY,CAAC;IAC1C,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,wBAAwB;QACnC,OAAO,eAAM,CAAC,cAAc,CAAC,2BAA2B,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACrE,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,iBAAiB;QAC5B,OAAO,IAAI,CAAC,cAAc,CAAC,iBAAiB,EAAE,CAAC;IACjD,CAAC;IAED;;OAEG;IACa,sBAAsB,GAAG,IAAI,sBAAO,EAA0C,CAAC;CAChG;AApMD,kDAoMC","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 IModelConnection\r\n */\r\n\r\nimport { assert, BeEvent, CompressedId64Set, Guid, GuidString, Id64Set, Id64String, IModelStatus, OpenMode } from \"@itwin/core-bentley\";\r\nimport {\r\n BriefcaseConnectionProps, ChangesetIndex, ChangesetIndexAndId, getPullChangesIpcChannel, IModelError,\r\n PullChangesOptions as IpcAppPullChangesOptions, LockState, OpenBriefcaseProps, StandaloneOpenOptions,\r\n} from \"@itwin/core-common\";\r\nimport { BriefcaseTxns } from \"./BriefcaseTxns\";\r\nimport { GraphicalEditingScope } from \"./GraphicalEditingScope\";\r\nimport { IModelApp } from \"./IModelApp\";\r\nimport { IModelConnection } from \"./IModelConnection\";\r\nimport { IpcApp } from \"./IpcApp\";\r\nimport { disposeTileTreesForGeometricModels } from \"./tile/internal\";\r\nimport { Viewport } from \"./Viewport\";\r\n\r\n/**\r\n * Download progress information.\r\n * @public\r\n */\r\nexport interface DownloadProgressInfo {\r\n /** Bytes downloaded. */\r\n loaded: number;\r\n /** Total size of the download in bytes. */\r\n total: number;\r\n}\r\n\r\n/**\r\n * Called to show progress during a download.\r\n * @public\r\n */\r\nexport type OnDownloadProgress = (progress: DownloadProgressInfo) => void;\r\n\r\n/**\r\n * Partial interface of AbortSignal.\r\n * @see https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal\r\n * @beta\r\n */\r\nexport interface GenericAbortSignal {\r\n /** Add Listener for abort signal. */\r\n addEventListener: (type: \"abort\", listener: (this: GenericAbortSignal, ev: any) => any) => void;\r\n /** Remove Listener for abort signal. */\r\n removeEventListener: (type: \"abort\", listener: (this: GenericAbortSignal, ev: any) => any) => void;\r\n}\r\n\r\n/**\r\n * Options for pulling iModel changes.\r\n * @public\r\n */\r\nexport interface PullChangesOptions {\r\n /** Function called regularly to report progress of changes download. */\r\n downloadProgressCallback?: OnDownloadProgress;\r\n /** Interval for calling progress callback (in milliseconds). */\r\n progressInterval?: number;\r\n /** Signal for cancelling the download.\r\n * @beta\r\n */\r\n abortSignal?: GenericAbortSignal;\r\n}\r\n\r\n/** Keeps track of changes to models, buffering them until synchronization points.\r\n * While a GraphicalEditingScope is open, the changes are buffered until the scope exits, at which point they are processed.\r\n * Otherwise, the buffered changes are processed after undo/redo, commit, or pull+merge changes.\r\n */\r\nclass ModelChangeMonitor {\r\n private _editingScope?: GraphicalEditingScope;\r\n private readonly _briefcase: BriefcaseConnection;\r\n private readonly _deletedModels = new Set<string>();\r\n private readonly _modelIdToGuid = new Map<string, string>();\r\n private readonly _removals: VoidFunction[] = [];\r\n\r\n public constructor(briefcase: BriefcaseConnection) {\r\n this._briefcase = briefcase;\r\n\r\n // Buffer updated geometry guids.\r\n this._removals.push(briefcase.txns.onModelGeometryChanged.addListener((changes) => {\r\n for (const change of changes) {\r\n this._deletedModels.delete(change.id);\r\n this._modelIdToGuid.set(change.id, change.guid);\r\n }\r\n }));\r\n\r\n // Buffer deletions of models.\r\n this._removals.push(briefcase.txns.onModelsChanged.addListener((changes) => {\r\n if (changes.deleted) {\r\n for (const id of CompressedId64Set.iterable(changes.deleted)) {\r\n this._modelIdToGuid.delete(id);\r\n this._deletedModels.add(id);\r\n }\r\n }\r\n }));\r\n\r\n // Outside of an editing scope, we want to update viewport contents after commit, undo/redo, or merging changes.\r\n const maybeProcess = async () => {\r\n if (this.editingScope)\r\n return;\r\n\r\n const modelIds = Array.from(this._modelIdToGuid.keys());\r\n if (modelIds.length > 0)\r\n await IModelApp.tileAdmin.purgeTileTrees(this._briefcase, modelIds);\r\n\r\n this.processBuffered();\r\n };\r\n\r\n this._removals.push(briefcase.txns.onCommitted.addListener(maybeProcess));\r\n this._removals.push(briefcase.txns.onReplayedExternalTxns.addListener(maybeProcess));\r\n this._removals.push(briefcase.txns.onAfterUndoRedo.addListener(maybeProcess));\r\n this._removals.push(briefcase.txns.onChangesPulled.addListener(maybeProcess));\r\n }\r\n\r\n public async close(): Promise<void> {\r\n for (const removal of this._removals)\r\n removal();\r\n\r\n this._removals.length = 0;\r\n\r\n if (this._editingScope) {\r\n await this._editingScope.exit();\r\n this._editingScope = undefined;\r\n }\r\n }\r\n\r\n public get editingScope(): GraphicalEditingScope | undefined {\r\n return this._editingScope;\r\n }\r\n\r\n public async enterEditingScope(): Promise<GraphicalEditingScope> {\r\n if (this._editingScope)\r\n throw new Error(\"Cannot create an editing scope for an iModel that already has one\");\r\n\r\n this._editingScope = await GraphicalEditingScope.enter(this._briefcase);\r\n\r\n const removeGeomListener = this._editingScope.onGeometryChanges.addListener((changes) => {\r\n const modelIds = [];\r\n for (const change of changes)\r\n modelIds.push(change.id);\r\n\r\n this.invalidateScenes(modelIds);\r\n });\r\n\r\n this._editingScope.onExited.addOnce((scope) => {\r\n assert(scope === this._editingScope);\r\n this._editingScope = undefined;\r\n removeGeomListener();\r\n this.processBuffered();\r\n });\r\n\r\n return this._editingScope;\r\n }\r\n\r\n private processBuffered(): void {\r\n const models = this._briefcase.models;\r\n for (const [id, guid] of this._modelIdToGuid) {\r\n const model = models.getLoaded(id)?.asGeometricModel;\r\n if (model)\r\n model.geometryGuid = guid;\r\n }\r\n\r\n const modelIds = new Set<string>(this._modelIdToGuid.keys());\r\n for (const deleted of this._deletedModels) {\r\n modelIds.add(deleted);\r\n models.unload(deleted);\r\n }\r\n\r\n this.invalidateScenes(modelIds);\r\n disposeTileTreesForGeometricModels(modelIds, this._briefcase);\r\n\r\n this._briefcase.onBufferedModelChanges.raiseEvent(modelIds);\r\n\r\n this._modelIdToGuid.clear();\r\n this._deletedModels.clear();\r\n }\r\n\r\n private invalidateScenes(changedModels: Iterable<Id64String>): void {\r\n for (const user of IModelApp.tileAdmin.tileUsers) {\r\n if (user instanceof Viewport && user.iModel === this._briefcase) {\r\n for (const modelId of changedModels) {\r\n if (user.view.viewsModel(modelId)) {\r\n user.invalidateScene();\r\n user.setFeatureOverrideProviderChanged();\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Provides access to lock information in the iModel.\r\n * @see [[BriefcaseConnection.locks]]\r\n * @alpha\r\n */\r\nexport interface LockService {\r\n /** Get all elements with exclusive locks owned by other briefcases. */\r\n getExclusiveForeignLocks(): Promise<Id64Set>;\r\n /** Get all elements with shared locks owned by other briefcases. */\r\n getSharedForeignLocks(): Promise<Id64Set>;\r\n /** Check whether it's possible to acquire a lock for the element. */\r\n checkElementLockAvailability(elementId: Id64String, lock: LockState): Promise<boolean>;\r\n}\r\n\r\n/** Function for creating a [[LockService]] for a [[BriefcaseConnection]].\r\n * @alpha\r\n */\r\nexport type LockServiceFactory = (iModel: BriefcaseConnection) => Promise<LockService>;\r\n\r\n/** Settings that can be used to control the behavior of [[Tool]]s that modify a [[BriefcaseConnection]].\r\n * For example, tools that want to create new elements can consult the briefcase's editor tool settings to\r\n * determine into which model and category to insert the elements.\r\n * Specialized tools are free to ignore these settings.\r\n * @see [[BriefcaseConnection.editorToolSettings]] to query or modify the current settings for a briefcase.\r\n * @see [CreateElementTool]($editor-frontend) for an example of a tool that uses these settings.\r\n * @beta\r\n */\r\nexport class BriefcaseEditorToolSettings {\r\n private _category?: Id64String;\r\n private _model?: Id64String;\r\n\r\n /** An event raised just after the default [[category]] is changed. */\r\n public readonly onCategoryChanged = new BeEvent<(previousCategory: Id64String | undefined) => void>();\r\n\r\n /** An event raised just after the default [[model]] is changed. */\r\n public readonly onModelChanged = new BeEvent<(previousModel: Id64String | undefined) => void>();\r\n\r\n /** The [Category]($backend) into which new elements should be inserted by default.\r\n * Specialized tools are free to ignore this setting and instead use their own logic to select an appropriate category.\r\n * @see [[onCategoryChanged]] to be notified when this property is modified.\r\n * @see [CreateElementTool.targetCategory]($editor-frontend) for an example of a tool that uses this setting.\r\n */\r\n public get category(): Id64String | undefined {\r\n return this._category;\r\n }\r\n public set category(category: Id64String | undefined) {\r\n const previousCategory = this.category;\r\n if (category !== this.category) {\r\n this._category = category;\r\n this.onCategoryChanged.raiseEvent(previousCategory);\r\n }\r\n }\r\n\r\n /** The [Model]($backend) into which new elements should be inserted by default.\r\n * Specialized tools are free to ignore this setting and instead use their own logic to select an appropriate model.\r\n * @see [[onModelChanged]] to be notified when this property is modified.\r\n * @see [CreateElementTool.targetModelId]($editor-frontend) for an example of a tool that uses this setting.\r\n */\r\n public get model(): Id64String | undefined {\r\n return this._model;\r\n }\r\n public set model(model: Id64String | undefined) {\r\n const previousModel = this.model;\r\n if (model !== this.model) {\r\n this._model = model;\r\n this.onModelChanged.raiseEvent(previousModel);\r\n }\r\n }\r\n}\r\n\r\n/** A connection to an editable briefcase on the backend. This class uses [Ipc]($docs/learning/IpcInterface.md) to communicate\r\n * to the backend and may only be used by [[IpcApp]]s.\r\n * @public\r\n */\r\nexport class BriefcaseConnection extends IModelConnection {\r\n protected _isClosed?: boolean;\r\n private readonly _modelsMonitor: ModelChangeMonitor;\r\n private _locks?: LockService;\r\n\r\n /** The ID of the briefcase.\r\n * @beta\r\n */\r\n public readonly briefcaseId?: number;\r\n\r\n /** Default settings that can be used to control the behavior of [[Tool]]s that modify this briefcase.\r\n * @beta\r\n */\r\n public readonly editorToolSettings = new BriefcaseEditorToolSettings();\r\n\r\n /** Manages local changes to the briefcase via [Txns]($docs/learning/InteractiveEditing.md). */\r\n public readonly txns: BriefcaseTxns;\r\n\r\n /** Information about locks held on this iModel.\r\n * @note This is intended to be used by tools and other UI elements, to provide information about the current lock state. Implementations are expected to cache lock information and so may not reflect changes to locks immediately.\r\n * @alpha\r\n */\r\n public get locks(): LockService | undefined { return this._locks; }\r\n\r\n public override isBriefcaseConnection(): this is BriefcaseConnection { return true; }\r\n\r\n /** The Guid that identifies the iTwin that owns this iModel. */\r\n public override get iTwinId(): GuidString { return super.iTwinId ?? Guid.empty; } // GuidString | undefined for IModelConnection, but required for BriefcaseConnection\r\n\r\n /** The Guid that identifies this iModel. */\r\n public override get iModelId(): GuidString { return super.iModelId ?? Guid.empty; } // GuidString | undefined for IModelConnection, but required for BriefcaseConnection\r\n\r\n protected constructor(props: BriefcaseConnectionProps, openMode: OpenMode) {\r\n super(props);\r\n this._openMode = openMode;\r\n this.briefcaseId = props.briefcaseId;\r\n this.txns = new BriefcaseTxns(this);\r\n this._modelsMonitor = new ModelChangeMonitor(this);\r\n if (OpenMode.ReadWrite === this._openMode)\r\n this.txns.onAfterUndoRedo.addListener(async () => { await IModelApp.toolAdmin.restartPrimitiveTool(); });\r\n\r\n this.categories.cache.attachToBriefcase(this);\r\n }\r\n\r\n /** Open a BriefcaseConnection to a [BriefcaseDb]($backend). */\r\n public static async openFile(briefcaseProps: OpenBriefcaseProps): Promise<BriefcaseConnection>;\r\n\r\n /** Open a BriefcaseConnection to a [BriefcaseDb]($backend).\r\n * @alpha\r\n */\r\n public static async openFile(briefcaseProps: OpenBriefcaseProps, lockServiceFactory?: LockServiceFactory): Promise<BriefcaseConnection>\r\n\r\n public static async openFile(briefcaseProps: OpenBriefcaseProps, lockServiceFactory?: LockServiceFactory): Promise<BriefcaseConnection> {\r\n const iModelProps = await IpcApp.appFunctionIpc.openBriefcase(briefcaseProps);\r\n const connection = new this({ ...briefcaseProps, ...iModelProps }, briefcaseProps.readonly ? OpenMode.Readonly : OpenMode.ReadWrite);\r\n if (lockServiceFactory)\r\n connection._locks = await lockServiceFactory(connection);\r\n\r\n IModelConnection.onOpen.raiseEvent(connection);\r\n return connection;\r\n }\r\n\r\n /** Open a BriefcaseConnection to a [StandaloneDb]($backend)\r\n * @note StandaloneDbs, by definition, may not push or pull changes. Attempting to do so will throw exceptions.\r\n */\r\n public static async openStandalone(filePath: string, openMode: OpenMode = OpenMode.ReadWrite, opts?: StandaloneOpenOptions): Promise<BriefcaseConnection> {\r\n const openResponse = await IpcApp.appFunctionIpc.openStandalone(filePath, openMode, opts);\r\n const connection = new this(openResponse, openMode);\r\n IModelConnection.onOpen.raiseEvent(connection);\r\n return connection;\r\n }\r\n\r\n /** Returns `true` if [[close]] has already been called. */\r\n public get isClosed(): boolean { return this._isClosed === true; }\r\n\r\n /**\r\n * Close this BriefcaseConnection.\r\n * @note make sure to call [[saveChanges]] before calling this method. Unsaved local changes are abandoned.\r\n */\r\n public async close(): Promise<void> {\r\n if (this.isClosed)\r\n return;\r\n\r\n await this._modelsMonitor.close();\r\n\r\n this.beforeClose();\r\n this.txns[Symbol.dispose]();\r\n\r\n this._isClosed = true;\r\n await IpcApp.appFunctionIpc.closeIModel(this._fileKey);\r\n }\r\n\r\n protected requireTimeline() {\r\n if (this.iTwinId === Guid.empty)\r\n throw new IModelError(IModelStatus.WrongIModel, \"iModel has no timeline\");\r\n }\r\n\r\n /** Query if there are any pending Txns in this briefcase that are waiting to be pushed. */\r\n public async hasPendingTxns(): Promise<boolean> { // eslint-disable-line @itwin/prefer-get\r\n return this.txns.hasPendingTxns();\r\n }\r\n\r\n /** Commit pending changes to this briefcase.\r\n * @param description Optional description of the changes.\r\n * @deprecated in 5.1.9 - will not be removed until after 2027-05-04. Use methods on EditCommand instead.\r\n */\r\n public async saveChanges(description?: string): Promise<void> {\r\n await IpcApp.appFunctionIpc.saveChanges(this.key, description); // eslint-disable-line @typescript-eslint/no-deprecated\r\n }\r\n\r\n /** Abandon pending changes to this briefcase.\r\n * @deprecated in 5.1.9 - will not be removed until after 2027-05-04. Use methods on EditCommand instead.\r\n */\r\n public async abandonChanges(): Promise<void> {\r\n await IpcApp.appFunctionIpc.abandonChanges(this.key); // eslint-disable-line @typescript-eslint/no-deprecated\r\n }\r\n\r\n /** Pull (and potentially merge if there are local changes) up to a specified changeset from iModelHub into this briefcase\r\n * @param toIndex The changeset index to pull changes to. If `undefined`, pull all changes.\r\n * @param options Options for pulling changes.\r\n * @see [[BriefcaseTxns.onChangesPulled]] for the event dispatched after changes are pulled.\r\n */\r\n public async pullChanges(toIndex?: ChangesetIndex, options?: PullChangesOptions): Promise<void> {\r\n const removeListeners: VoidFunction[] = [];\r\n const shouldReportProgress = !!options?.downloadProgressCallback;\r\n\r\n if (shouldReportProgress) {\r\n const handleProgress = (_evt: Event, data: { loaded: number, total: number }) => {\r\n options?.downloadProgressCallback?.(data);\r\n };\r\n\r\n const removeProgressListener = IpcApp.addListener(\r\n getPullChangesIpcChannel(this.iModelId),\r\n handleProgress,\r\n );\r\n removeListeners.push(removeProgressListener);\r\n }\r\n\r\n if (options?.abortSignal) {\r\n const abort = () => void IpcApp.appFunctionIpc.cancelPullChangesRequest(this.key);\r\n options?.abortSignal.addEventListener(\"abort\", abort);\r\n removeListeners.push(() => options?.abortSignal?.removeEventListener(\"abort\", abort));\r\n }\r\n\r\n this.requireTimeline();\r\n const ipcAppOptions: IpcAppPullChangesOptions = {\r\n reportProgress: shouldReportProgress,\r\n progressInterval: options?.progressInterval,\r\n enableCancellation: !!options?.abortSignal,\r\n };\r\n try {\r\n this.changeset = await IpcApp.appFunctionIpc.pullChanges(this.key, toIndex, ipcAppOptions);\r\n } finally {\r\n removeListeners.forEach((remove) => remove());\r\n }\r\n }\r\n\r\n /** Create a changeset from local Txns and push to iModelHub. On success, clear Txn table.\r\n * @param description The description for the changeset\r\n * @returns the changesetId of the pushed changes\r\n * @see [[BriefcaseTxns.onChangesPushed]] for the event dispatched after changes are pushed.\r\n */\r\n public async pushChanges(description: string): Promise<ChangesetIndexAndId> {\r\n this.requireTimeline();\r\n return IpcApp.appFunctionIpc.pushChanges(this.key, description);\r\n }\r\n\r\n /** The current graphical editing scope, if one is in progress.\r\n * @see [[enterEditingScope]] to begin graphical editing.\r\n */\r\n public get editingScope(): GraphicalEditingScope | undefined {\r\n return this._modelsMonitor.editingScope;\r\n }\r\n\r\n /** Return whether graphical editing is supported for this briefcase. It is not supported if the briefcase is read-only, or the briefcase contains a version of\r\n * the BisCore ECSchema older than v0.1.11.\r\n * @see [[enterEditingScope]] to enable graphical editing.\r\n */\r\n public async supportsGraphicalEditing(): Promise<boolean> {\r\n return IpcApp.appFunctionIpc.isGraphicalEditingSupported(this.key);\r\n }\r\n\r\n /** Begin a new graphical editing scope.\r\n * @throws Error if an editing scope already exists or one could not be created.\r\n * @see [[GraphicalEditingScope.exit]] to exit the scope.\r\n * @see [[supportsGraphicalEditing]] to determine whether this method should be expected to succeed.\r\n * @see [[editingScope]] to obtain the current editing scope, if one is in progress.\r\n */\r\n public async enterEditingScope(): Promise<GraphicalEditingScope> {\r\n return this._modelsMonitor.enterEditingScope();\r\n }\r\n\r\n /** Strictly for tests - dispatched from ModelChangeMonitor.processBuffered.\r\n * @internal\r\n */\r\n public readonly onBufferedModelChanges = new BeEvent<(changedModelIds: Set<string>) => void>();\r\n}\r\n"]}
1
+ {"version":3,"file":"BriefcaseConnection.js","sourceRoot":"","sources":["../../src/BriefcaseConnection.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAwI;AACxI,oDAG4B;AAC5B,mDAAgD;AAChD,mEAAgE;AAChE,2CAAwC;AACxC,yDAAsD;AACtD,qCAAkC;AAClC,8CAAqE;AACrE,yCAAsC;AA8CtC;;;GAGG;AACH,MAAM,kBAAkB;IACd,aAAa,CAAyB;IAC7B,UAAU,CAAsB;IAChC,cAAc,GAAG,IAAI,GAAG,EAAU,CAAC;IACnC,cAAc,GAAG,IAAI,GAAG,EAAkB,CAAC;IAC3C,SAAS,GAAmB,EAAE,CAAC;IAEhD,YAAmB,SAA8B;QAC/C,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAE5B,iCAAiC;QACjC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,sBAAsB,CAAC,WAAW,CAAC,CAAC,OAAO,EAAE,EAAE;YAChF,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;gBAC7B,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;gBACtC,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;YAClD,CAAC;QACH,CAAC,CAAC,CAAC,CAAC;QAEJ,8BAA8B;QAC9B,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC,OAAO,EAAE,EAAE;YACzE,IAAI,OAAO,CAAC,OAA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,CAAC,OAAO,EAAE,WAAW,EAAE,mBAAmB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC;QACxF,CAAC;QAED,IAAI,CAAC,eAAe,EAAE,CAAC;QACvB,MAAM,aAAa,GAA6B;YAC9C,cAAc,EAAE,oBAAoB;YACpC,gBAAgB,EAAE,OAAO,EAAE,gBAAgB;YAC3C,kBAAkB,EAAE,CAAC,CAAC,OAAO,EAAE,WAAW;SAC3C,CAAC;QACF,IAAI,CAAC;YACH,IAAI,CAAC,SAAS,GAAG,MAAM,eAAM,CAAC,cAAc,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,EAAE,OAAO,EAAE,aAAa,CAAC,CAAC;QAC7F,CAAC;gBAAS,CAAC;YACT,eAAe,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC;QAChD,CAAC;IACH,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,WAAW,CAAC,WAAmB;QAC1C,IAAI,CAAC,eAAe,EAAE,CAAC;QACvB,OAAO,eAAM,CAAC,cAAc,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;IAClE,CAAC;IAED;;OAEG;IACH,IAAW,YAAY;QACrB,OAAO,IAAI,CAAC,cAAc,CAAC,YAAY,CAAC;IAC1C,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,wBAAwB;QACnC,OAAO,eAAM,CAAC,cAAc,CAAC,2BAA2B,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACrE,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,iBAAiB;QAC5B,OAAO,IAAI,CAAC,cAAc,CAAC,iBAAiB,EAAE,CAAC;IACjD,CAAC;IAED;;OAEG;IACa,sBAAsB,GAAG,IAAI,sBAAO,EAA0C,CAAC;CAChG;AApMD,kDAoMC","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 IModelConnection\r\n */\r\n\r\nimport { assert, BeEvent, CompressedId64Set, Guid, GuidString, Id64Set, Id64String, IModelStatus, OpenMode } from \"@itwin/core-bentley\";\r\nimport {\r\n BriefcaseConnectionProps, ChangesetIndex, ChangesetIndexAndId, getPullChangesIpcChannel, IModelError,\r\n PullChangesOptions as IpcAppPullChangesOptions, LockState, OpenBriefcaseProps, StandaloneOpenOptions,\r\n} from \"@itwin/core-common\";\r\nimport { BriefcaseTxns } from \"./BriefcaseTxns\";\r\nimport { GraphicalEditingScope } from \"./GraphicalEditingScope\";\r\nimport { IModelApp } from \"./IModelApp\";\r\nimport { IModelConnection } from \"./IModelConnection\";\r\nimport { IpcApp } from \"./IpcApp\";\r\nimport { disposeTileTreesForGeometricModels } from \"./tile/internal\";\r\nimport { Viewport } from \"./Viewport\";\r\n\r\n/**\r\n * Download progress information.\r\n * @public\r\n */\r\nexport interface DownloadProgressInfo {\r\n /** Bytes downloaded. */\r\n loaded: number;\r\n /** Total size of the download in bytes. */\r\n total: number;\r\n}\r\n\r\n/**\r\n * Called to show progress during a download.\r\n * @public\r\n */\r\nexport type OnDownloadProgress = (progress: DownloadProgressInfo) => void;\r\n\r\n/**\r\n * Partial interface of AbortSignal.\r\n * @see https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal\r\n * @beta\r\n */\r\nexport interface GenericAbortSignal {\r\n /** Add Listener for abort signal. */\r\n addEventListener: (type: \"abort\", listener: (this: GenericAbortSignal, ev: any) => any) => void;\r\n /** Remove Listener for abort signal. */\r\n removeEventListener: (type: \"abort\", listener: (this: GenericAbortSignal, ev: any) => any) => void;\r\n}\r\n\r\n/**\r\n * Options for pulling iModel changes.\r\n * @public\r\n */\r\nexport interface PullChangesOptions {\r\n /** Function called regularly to report progress of changes download. */\r\n downloadProgressCallback?: OnDownloadProgress;\r\n /** Interval for calling progress callback (in milliseconds). */\r\n progressInterval?: number;\r\n /** Signal for cancelling the download.\r\n * @beta\r\n */\r\n abortSignal?: GenericAbortSignal;\r\n}\r\n\r\n/** Keeps track of changes to models, buffering them until synchronization points.\r\n * While a GraphicalEditingScope is open, the changes are buffered until the scope exits, at which point they are processed.\r\n * Otherwise, the buffered changes are processed after undo/redo, commit, or pull+merge changes.\r\n */\r\nclass ModelChangeMonitor {\r\n private _editingScope?: GraphicalEditingScope;\r\n private readonly _briefcase: BriefcaseConnection;\r\n private readonly _deletedModels = new Set<string>();\r\n private readonly _modelIdToGuid = new Map<string, string>();\r\n private readonly _removals: VoidFunction[] = [];\r\n\r\n public constructor(briefcase: BriefcaseConnection) {\r\n this._briefcase = briefcase;\r\n\r\n // Buffer updated geometry guids.\r\n this._removals.push(briefcase.txns.onModelGeometryChanged.addListener((changes) => {\r\n for (const change of changes) {\r\n this._deletedModels.delete(change.id);\r\n this._modelIdToGuid.set(change.id, change.guid);\r\n }\r\n }));\r\n\r\n // Buffer deletions of models.\r\n this._removals.push(briefcase.txns.onModelsChanged.addListener((changes) => {\r\n if (changes.deleted) {\r\n for (const id of CompressedId64Set.iterable(changes.deleted)) {\r\n this._modelIdToGuid.delete(id);\r\n this._deletedModels.add(id);\r\n }\r\n }\r\n }));\r\n\r\n // Outside of an editing scope, we want to update viewport contents after commit, undo/redo, or merging changes.\r\n const maybeProcess = async () => {\r\n if (this.editingScope)\r\n return;\r\n\r\n const modelIds = Array.from(this._modelIdToGuid.keys());\r\n if (modelIds.length > 0)\r\n await IModelApp.tileAdmin.purgeTileTrees(this._briefcase, modelIds);\r\n\r\n this.processBuffered();\r\n };\r\n\r\n this._removals.push(briefcase.txns.onCommitted.addListener(maybeProcess));\r\n this._removals.push(briefcase.txns.onReplayedExternalTxns.addListener(maybeProcess));\r\n this._removals.push(briefcase.txns.onAfterUndoRedo.addListener(maybeProcess));\r\n this._removals.push(briefcase.txns.onChangesPulled.addListener(maybeProcess));\r\n }\r\n\r\n public async close(): Promise<void> {\r\n for (const removal of this._removals)\r\n removal();\r\n\r\n this._removals.length = 0;\r\n\r\n if (this._editingScope) {\r\n await this._editingScope.exit();\r\n this._editingScope = undefined;\r\n }\r\n }\r\n\r\n public get editingScope(): GraphicalEditingScope | undefined {\r\n return this._editingScope;\r\n }\r\n\r\n public async enterEditingScope(): Promise<GraphicalEditingScope> {\r\n if (this._editingScope)\r\n throw new Error(\"Cannot create an editing scope for an iModel that already has one\");\r\n\r\n this._editingScope = await GraphicalEditingScope.enter(this._briefcase);\r\n\r\n const removeGeomListener = this._editingScope.onGeometryChanges.addListener((changes) => {\r\n const modelIds = [];\r\n for (const change of changes)\r\n modelIds.push(change.id);\r\n\r\n this.invalidateScenes(modelIds);\r\n });\r\n\r\n this._editingScope.onExited.addOnce((scope) => {\r\n assert(scope === this._editingScope);\r\n this._editingScope = undefined;\r\n removeGeomListener();\r\n this.processBuffered();\r\n });\r\n\r\n return this._editingScope;\r\n }\r\n\r\n private processBuffered(): void {\r\n const models = this._briefcase.models;\r\n for (const [id, guid] of this._modelIdToGuid) {\r\n const model = models.getLoaded(id)?.asGeometricModel;\r\n if (model)\r\n model.geometryGuid = guid;\r\n }\r\n\r\n const modelIds = new Set<string>(this._modelIdToGuid.keys());\r\n for (const deleted of this._deletedModels) {\r\n modelIds.add(deleted);\r\n models.unload(deleted);\r\n }\r\n\r\n this.invalidateScenes(modelIds);\r\n disposeTileTreesForGeometricModels(modelIds, this._briefcase);\r\n\r\n this._briefcase.onBufferedModelChanges.raiseEvent(modelIds);\r\n\r\n this._modelIdToGuid.clear();\r\n this._deletedModels.clear();\r\n }\r\n\r\n private invalidateScenes(changedModels: Iterable<Id64String>): void {\r\n for (const user of IModelApp.tileAdmin.tileUsers) {\r\n if (user instanceof Viewport && user.iModel === this._briefcase) {\r\n for (const modelId of changedModels) {\r\n if (user.view.viewsModel(modelId)) {\r\n user.invalidateScene();\r\n user.setFeatureOverrideProviderChanged();\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Provides access to lock information in the iModel.\r\n * @see [[BriefcaseConnection.locks]]\r\n * @alpha\r\n */\r\nexport interface LockService {\r\n /** Get all elements with exclusive locks owned by other briefcases. */\r\n getExclusiveForeignLocks(): Promise<Id64Set>;\r\n /** Get all elements with shared locks owned by other briefcases. */\r\n getSharedForeignLocks(): Promise<Id64Set>;\r\n /** Check whether it's possible to acquire a lock for the element. */\r\n checkElementLockAvailability(elementId: Id64String, lock: LockState): Promise<boolean>;\r\n}\r\n\r\n/** Function for creating a [[LockService]] for a [[BriefcaseConnection]].\r\n * @alpha\r\n */\r\nexport type LockServiceFactory = (iModel: BriefcaseConnection) => Promise<LockService>;\r\n\r\n/** Settings that can be used to control the behavior of [[Tool]]s that modify a [[BriefcaseConnection]].\r\n * For example, tools that want to create new elements can consult the briefcase's editor tool settings to\r\n * determine into which model and category to insert the elements.\r\n * Specialized tools are free to ignore these settings.\r\n * @see [[BriefcaseConnection.editorToolSettings]] to query or modify the current settings for a briefcase.\r\n * @see [CreateElementTool]($editor-frontend) for an example of a tool that uses these settings.\r\n * @beta\r\n */\r\nexport class BriefcaseEditorToolSettings {\r\n private _category?: Id64String;\r\n private _model?: Id64String;\r\n\r\n /** An event raised just after the default [[category]] is changed. */\r\n public readonly onCategoryChanged = new BeEvent<(previousCategory: Id64String | undefined) => void>();\r\n\r\n /** An event raised just after the default [[model]] is changed. */\r\n public readonly onModelChanged = new BeEvent<(previousModel: Id64String | undefined) => void>();\r\n\r\n /** The [Category]($backend) into which new elements should be inserted by default.\r\n * Specialized tools are free to ignore this setting and instead use their own logic to select an appropriate category.\r\n * @see [[onCategoryChanged]] to be notified when this property is modified.\r\n * @see [CreateElementTool.targetCategory]($editor-frontend) for an example of a tool that uses this setting.\r\n */\r\n public get category(): Id64String | undefined {\r\n return this._category;\r\n }\r\n public set category(category: Id64String | undefined) {\r\n const previousCategory = this.category;\r\n if (category !== this.category) {\r\n this._category = category;\r\n this.onCategoryChanged.raiseEvent(previousCategory);\r\n }\r\n }\r\n\r\n /** The [Model]($backend) into which new elements should be inserted by default.\r\n * Specialized tools are free to ignore this setting and instead use their own logic to select an appropriate model.\r\n * @see [[onModelChanged]] to be notified when this property is modified.\r\n * @see [CreateElementTool.targetModelId]($editor-frontend) for an example of a tool that uses this setting.\r\n */\r\n public get model(): Id64String | undefined {\r\n return this._model;\r\n }\r\n public set model(model: Id64String | undefined) {\r\n const previousModel = this.model;\r\n if (model !== this.model) {\r\n this._model = model;\r\n this.onModelChanged.raiseEvent(previousModel);\r\n }\r\n }\r\n}\r\n\r\n/** A connection to an editable briefcase on the backend. This class uses [Ipc]($docs/learning/IpcInterface.md) to communicate\r\n * to the backend and may only be used by [[IpcApp]]s.\r\n * @public\r\n */\r\nexport class BriefcaseConnection extends IModelConnection {\r\n protected _isClosed?: boolean;\r\n private readonly _modelsMonitor: ModelChangeMonitor;\r\n private _locks?: LockService;\r\n\r\n /** The ID of the briefcase.\r\n * @beta\r\n */\r\n public readonly briefcaseId?: number;\r\n\r\n /** Default settings that can be used to control the behavior of [[Tool]]s that modify this briefcase.\r\n * @beta\r\n */\r\n public readonly editorToolSettings = new BriefcaseEditorToolSettings();\r\n\r\n /** Manages local changes to the briefcase via [Txns]($docs/learning/InteractiveEditing.md). */\r\n public readonly txns: BriefcaseTxns;\r\n\r\n /** Information about locks held on this iModel.\r\n * @note This is intended to be used by tools and other UI elements, to provide information about the current lock state. Implementations are expected to cache lock information and so may not reflect changes to locks immediately.\r\n * @alpha\r\n */\r\n public get locks(): LockService | undefined { return this._locks; }\r\n\r\n public override isBriefcaseConnection(): this is BriefcaseConnection { return true; }\r\n\r\n /** The Guid that identifies the iTwin that owns this iModel. */\r\n public override get iTwinId(): GuidString { return super.iTwinId ?? Guid.empty; } // GuidString | undefined for IModelConnection, but required for BriefcaseConnection\r\n\r\n /** The Guid that identifies this iModel. */\r\n public override get iModelId(): GuidString { return super.iModelId ?? Guid.empty; } // GuidString | undefined for IModelConnection, but required for BriefcaseConnection\r\n\r\n protected constructor(props: BriefcaseConnectionProps, openMode: OpenMode) {\r\n super(props);\r\n this._openMode = openMode;\r\n this.briefcaseId = props.briefcaseId;\r\n this.txns = new BriefcaseTxns(this);\r\n this._modelsMonitor = new ModelChangeMonitor(this);\r\n if (OpenMode.ReadWrite === this._openMode)\r\n this.txns.onAfterUndoRedo.addListener(async () => { await IModelApp.toolAdmin.restartPrimitiveTool(); });\r\n\r\n this.categories.cache.attachToBriefcase(this);\r\n }\r\n\r\n /** Open a BriefcaseConnection to a [BriefcaseDb]($backend). */\r\n public static async openFile(briefcaseProps: OpenBriefcaseProps): Promise<BriefcaseConnection>;\r\n\r\n /** Open a BriefcaseConnection to a [BriefcaseDb]($backend).\r\n * @alpha\r\n */\r\n public static async openFile(briefcaseProps: OpenBriefcaseProps, lockServiceFactory?: LockServiceFactory): Promise<BriefcaseConnection>\r\n\r\n public static async openFile(briefcaseProps: OpenBriefcaseProps, lockServiceFactory?: LockServiceFactory): Promise<BriefcaseConnection> {\r\n const iModelProps = await IpcApp.appFunctionIpc.openBriefcase(briefcaseProps);\r\n const connection = new this({ ...briefcaseProps, ...iModelProps }, briefcaseProps.readonly ? OpenMode.Readonly : OpenMode.ReadWrite);\r\n if (lockServiceFactory)\r\n connection._locks = await lockServiceFactory(connection);\r\n\r\n IModelConnection.onOpen.raiseEvent(connection);\r\n return connection;\r\n }\r\n\r\n /** Open a BriefcaseConnection to a [StandaloneDb]($backend)\r\n * @note StandaloneDbs, by definition, may not push or pull changes. Attempting to do so will throw exceptions.\r\n */\r\n public static async openStandalone(filePath: string, openMode: OpenMode = OpenMode.ReadWrite, opts?: StandaloneOpenOptions): Promise<BriefcaseConnection> {\r\n const openResponse = await IpcApp.appFunctionIpc.openStandalone(filePath, openMode, opts);\r\n const connection = new this(openResponse, openMode);\r\n IModelConnection.onOpen.raiseEvent(connection);\r\n return connection;\r\n }\r\n\r\n /** Returns `true` if [[close]] has already been called. */\r\n public get isClosed(): boolean { return this._isClosed === true; }\r\n\r\n /**\r\n * Close this BriefcaseConnection.\r\n * @note make sure to call [[saveChanges]] before calling this method. Unsaved local changes are abandoned.\r\n */\r\n public async close(): Promise<void> {\r\n if (this.isClosed)\r\n return;\r\n\r\n await this._modelsMonitor.close();\r\n\r\n this.beforeClose();\r\n this.txns[Symbol.dispose]();\r\n\r\n this._isClosed = true;\r\n await IpcApp.appFunctionIpc.closeIModel(this._fileKey);\r\n }\r\n\r\n protected requireTimeline() {\r\n if (this.iTwinId === Guid.empty)\r\n throw new IModelError(IModelStatus.WrongIModel, \"iModel has no timeline\");\r\n }\r\n\r\n /** Query if there are any pending Txns in this briefcase that are waiting to be pushed. */\r\n public async hasPendingTxns(): Promise<boolean> { // eslint-disable-line @itwin/prefer-get\r\n return this.txns.hasPendingTxns();\r\n }\r\n\r\n /** Commit pending changes to this briefcase.\r\n * @param description Optional description of the changes.\r\n * @deprecated in 5.9.0 - will not be removed until after 2027-05-04. Use methods on EditCommand instead.\r\n */\r\n public async saveChanges(description?: string): Promise<void> {\r\n await IpcApp.appFunctionIpc.saveChanges(this.key, description); // eslint-disable-line @typescript-eslint/no-deprecated\r\n }\r\n\r\n /** Abandon pending changes to this briefcase.\r\n * @deprecated in 5.9.0 - will not be removed until after 2027-05-04. Use methods on EditCommand instead.\r\n */\r\n public async abandonChanges(): Promise<void> {\r\n await IpcApp.appFunctionIpc.abandonChanges(this.key); // eslint-disable-line @typescript-eslint/no-deprecated\r\n }\r\n\r\n /** Pull (and potentially merge if there are local changes) up to a specified changeset from iModelHub into this briefcase\r\n * @param toIndex The changeset index to pull changes to. If `undefined`, pull all changes.\r\n * @param options Options for pulling changes.\r\n * @see [[BriefcaseTxns.onChangesPulled]] for the event dispatched after changes are pulled.\r\n */\r\n public async pullChanges(toIndex?: ChangesetIndex, options?: PullChangesOptions): Promise<void> {\r\n const removeListeners: VoidFunction[] = [];\r\n const shouldReportProgress = !!options?.downloadProgressCallback;\r\n\r\n if (shouldReportProgress) {\r\n const handleProgress = (_evt: Event, data: { loaded: number, total: number }) => {\r\n options?.downloadProgressCallback?.(data);\r\n };\r\n\r\n const removeProgressListener = IpcApp.addListener(\r\n getPullChangesIpcChannel(this.iModelId),\r\n handleProgress,\r\n );\r\n removeListeners.push(removeProgressListener);\r\n }\r\n\r\n if (options?.abortSignal) {\r\n const abort = () => void IpcApp.appFunctionIpc.cancelPullChangesRequest(this.key);\r\n options?.abortSignal.addEventListener(\"abort\", abort);\r\n removeListeners.push(() => options?.abortSignal?.removeEventListener(\"abort\", abort));\r\n }\r\n\r\n this.requireTimeline();\r\n const ipcAppOptions: IpcAppPullChangesOptions = {\r\n reportProgress: shouldReportProgress,\r\n progressInterval: options?.progressInterval,\r\n enableCancellation: !!options?.abortSignal,\r\n };\r\n try {\r\n this.changeset = await IpcApp.appFunctionIpc.pullChanges(this.key, toIndex, ipcAppOptions);\r\n } finally {\r\n removeListeners.forEach((remove) => remove());\r\n }\r\n }\r\n\r\n /** Create a changeset from local Txns and push to iModelHub. On success, clear Txn table.\r\n * @param description The description for the changeset\r\n * @returns the changesetId of the pushed changes\r\n * @see [[BriefcaseTxns.onChangesPushed]] for the event dispatched after changes are pushed.\r\n */\r\n public async pushChanges(description: string): Promise<ChangesetIndexAndId> {\r\n this.requireTimeline();\r\n return IpcApp.appFunctionIpc.pushChanges(this.key, description);\r\n }\r\n\r\n /** The current graphical editing scope, if one is in progress.\r\n * @see [[enterEditingScope]] to begin graphical editing.\r\n */\r\n public get editingScope(): GraphicalEditingScope | undefined {\r\n return this._modelsMonitor.editingScope;\r\n }\r\n\r\n /** Return whether graphical editing is supported for this briefcase. It is not supported if the briefcase is read-only, or the briefcase contains a version of\r\n * the BisCore ECSchema older than v0.1.11.\r\n * @see [[enterEditingScope]] to enable graphical editing.\r\n */\r\n public async supportsGraphicalEditing(): Promise<boolean> {\r\n return IpcApp.appFunctionIpc.isGraphicalEditingSupported(this.key);\r\n }\r\n\r\n /** Begin a new graphical editing scope.\r\n * @throws Error if an editing scope already exists or one could not be created.\r\n * @see [[GraphicalEditingScope.exit]] to exit the scope.\r\n * @see [[supportsGraphicalEditing]] to determine whether this method should be expected to succeed.\r\n * @see [[editingScope]] to obtain the current editing scope, if one is in progress.\r\n */\r\n public async enterEditingScope(): Promise<GraphicalEditingScope> {\r\n return this._modelsMonitor.enterEditingScope();\r\n }\r\n\r\n /** Strictly for tests - dispatched from ModelChangeMonitor.processBuffered.\r\n * @internal\r\n */\r\n public readonly onBufferedModelChanges = new BeEvent<(changedModelIds: Set<string>) => void>();\r\n}\r\n"]}
@@ -86,7 +86,7 @@ export declare abstract class PrimitiveTool extends InteractiveTool {
86
86
  redoPreviousStep(): Promise<boolean>;
87
87
  /**
88
88
  * If this tool is editing a briefcase, commits any elements that the tool has changed, supplying the tool flyover for the undo description.
89
- * @deprecated in 5.1.9 - will not be removed until after 2027-05-04. Use methods on [[EditCommand]] IPC instead.
89
+ * @deprecated in 5.9.0 - will not be removed until after 2027-05-04. Use methods on [[EditCommand]] IPC instead.
90
90
  */
91
91
  saveChanges(): Promise<void>;
92
92
  }
@@ -169,7 +169,7 @@ class PrimitiveTool extends Tool_1.InteractiveTool {
169
169
  }
170
170
  /**
171
171
  * If this tool is editing a briefcase, commits any elements that the tool has changed, supplying the tool flyover for the undo description.
172
- * @deprecated in 5.1.9 - will not be removed until after 2027-05-04. Use methods on [[EditCommand]] IPC instead.
172
+ * @deprecated in 5.9.0 - will not be removed until after 2027-05-04. Use methods on [[EditCommand]] IPC instead.
173
173
  */
174
174
  async saveChanges() {
175
175
  if (this.iModel.isBriefcaseConnection())
@@ -1 +1 @@
1
- {"version":3,"file":"PrimitiveTool.js","sourceRoot":"","sources":["../../../src/tools/PrimitiveTool.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA6C;AAE7C,4CAAyC;AAEzC,gEAAqF;AAErF,iDAAmD;AACnD,iCAAsG;AAEtG;;;;GAIG;AACH,MAAsB,aAAc,SAAQ,sB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CAAC,8CAA8C;QAE9G,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,WAAW;QACtB,IAAI,IAAI,CAAC,MAAM,CAAC,qBAAqB,EAAE;YACrC,OAAO,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,uDAAuD;IACzG,CAAC;CACF;AAjND,sCAiNC","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 Tools\r\n */\r\n\r\nimport { assert } from \"@itwin/core-bentley\";\r\nimport { BriefcaseConnection } from \"../BriefcaseConnection\";\r\nimport { IModelApp } from \"../IModelApp\";\r\nimport { IModelConnection } from \"../IModelConnection\";\r\nimport { NotifyMessageDetails, OutputMessagePriority } from \"../NotificationManager\";\r\nimport { Viewport } from \"../Viewport\";\r\nimport { AccuDrawShortcuts } from \"./AccuDrawTool\";\r\nimport { BeButton, BeButtonEvent, CoordinateLockOverrides, CoreTools, InteractiveTool } from \"./Tool\";\r\n\r\n/** The PrimitiveTool class can be used to implement tools to create or modify geometric elements.\r\n * @see [Writing a PrimitiveTool]($docs/learning/frontend/primitivetools.md)\r\n * @public\r\n * @extensions\r\n */\r\nexport abstract class PrimitiveTool extends InteractiveTool {\r\n /** The viewport within which the tool operates.\r\n * @note This property is only initialized if [[run]] returns `true`, causing the tool to be installed.\r\n */\r\n public targetView?: Viewport;\r\n private _targetModelId?: string;\r\n public get targetModelId() { return this._targetModelId; }\r\n public set targetModelId(v: string | undefined) { this._targetModelId = v; }\r\n public targetIsLocked: boolean = false; // If target model is known, set this to true in constructor and override getTargetModel.\r\n\r\n /** Get the iModel on which this tool operates.\r\n * @note The iModel is obtained from [[targetView]], so should only be invoked if the tool installed successfully.\r\n */\r\n public get iModel(): IModelConnection {\r\n assert(undefined !== this.targetView);\r\n return this.targetView.view.iModel;\r\n }\r\n\r\n /** Get the briefcase on which this tool operates, if the tool has successfully installed and the target [[iModel]] is a briefcase. */\r\n public get briefcase(): BriefcaseConnection | undefined {\r\n const iModel = this.targetView?.view.iModel;\r\n return iModel?.isBriefcaseConnection() ? iModel : undefined;\r\n }\r\n\r\n /**\r\n * Establish this tool as the active PrimitiveTool.\r\n * @return true if this tool was installed (though it may have exited too)\r\n * @note If you override this method you **must** call `super.run` and return false if it returns false.\r\n */\r\n public override async run(..._args: any[]): Promise<boolean> {\r\n const { toolAdmin, viewManager } = IModelApp;\r\n if (!this.isCompatibleViewport(viewManager.selectedView, false))\r\n return false;\r\n\r\n if (!await toolAdmin.onInstallTool(this))\r\n return false;\r\n\r\n await toolAdmin.startPrimitiveTool(this);\r\n // If another tool was installed at the same time (due to concurrent run calls),\r\n // the last start to complete wins. Detect that situation and return false.\r\n if (toolAdmin.primitiveTool !== this)\r\n return false;\r\n\r\n await toolAdmin.onPostInstallTool(this);\r\n return true;\r\n }\r\n\r\n /** Determine whether the supplied Viewport is compatible with this tool.\r\n * @param vp the Viewport to check\r\n */\r\n public override isCompatibleViewport(vp: Viewport | undefined, isSelectedViewChange: boolean): boolean {\r\n if (undefined === vp)\r\n return false; // No views are open...\r\n\r\n const view = vp.view;\r\n const iModel = view.iModel;\r\n\r\n if (this.requireWriteableTarget() && iModel.isReadonly)\r\n return false; // this Tool can't be used when iModel is read only.\r\n\r\n if (undefined === this.targetView || (!this.targetIsLocked && isSelectedViewChange))\r\n this.targetView = vp; // Update target to new view if undefined or still free to change.\r\n\r\n if (undefined === this.targetModelId && (!this.targetIsLocked || vp === this.targetView))\r\n return true; // Accept if this view is current target or any type of model/view is still ok as target is still free to change.\r\n\r\n if (iModel !== this.iModel)\r\n return false; // Once a ViewState has been established, only accept viewport showing the same iModel.\r\n\r\n if (this.targetModelId)\r\n return view.viewsModel(this.targetModelId); // If a specific target model is specified, only allow view that shows it.\r\n\r\n if (view.isSpatialView() && this.targetView.view.isSpatialView())\r\n return true; // No specific target, two spatial views are considered compatible.\r\n\r\n let allowView = false;\r\n const targetView = this.targetView;\r\n view.forEachModel((model) => {\r\n if (!allowView && targetView.view.viewsModel(model.id))\r\n allowView = true;\r\n });\r\n\r\n return allowView; // Accept if this view shares a model in common with target.\r\n }\r\n\r\n /**\r\n * Checks that the adjusted point from the supplied button event is within the project extents for spatial views. The range of physical geometry\r\n * should always be fully inside the project extents. Only checking the adjusted point won't absolutely guarantee that a tool doesn't create/move geometry\r\n * outside the project extents, but it will be sufficient to handle most cases and provide good feedback to the user.\r\n * @return true if ev is acceptable.\r\n */\r\n public override isValidLocation(ev: BeButtonEvent, isButtonEvent: boolean): boolean {\r\n const vp = ev.viewport;\r\n if (undefined === vp)\r\n return false;\r\n\r\n if (isButtonEvent && BeButton.Data !== ev.button)\r\n return true;\r\n\r\n const view = vp.view;\r\n if (!view.isSpatialView())\r\n return true;\r\n\r\n // NOTE: If points aren't being adjusted then the tool shouldn't be creating geometry currently (ex. locating elements) and we shouldn't filter point...\r\n if (0 !== (IModelApp.toolAdmin.toolState.coordLockOvr & CoordinateLockOverrides.ACS))\r\n return true;\r\n\r\n // We know the tool isn't doing a locate, we don't know what it will do with this point. Minimize erroneous filtering by restricting the check to when AccuSnap is tool enable (not user enabled)...\r\n if (!IModelApp.accuSnap.isSnapEnabled)\r\n return true;\r\n\r\n const extents = view.iModel.projectExtents;\r\n if (extents.containsPoint(ev.point))\r\n return true;\r\n\r\n if (isButtonEvent && ev.isDown)\r\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Error, CoreTools.translate(\"ElementSet.Error.ProjectExtents\")));\r\n\r\n return false;\r\n }\r\n\r\n /** Called on data button down event to lock the tool to its current target model. */\r\n public autoLockTarget(): void {\r\n if (undefined === this.targetView)\r\n return;\r\n\r\n this.targetIsLocked = true;\r\n }\r\n\r\n /** Returns the prompt based on the tool's current state. */\r\n public getPrompt(): string { return \"\"; }\r\n\r\n /** Called from isCompatibleViewport to check for a read only iModel, which is not a valid target for tools that create or modify elements. */\r\n public requireWriteableTarget(): boolean { return true; }\r\n\r\n /**\r\n * Called when active view changes. Tool may choose to restart or exit based on current view type.\r\n * @param _previous The previously active view.\r\n * @param current The new active view.\r\n */\r\n public override async onSelectedViewportChanged(_previous: Viewport | undefined, current: Viewport | undefined): Promise<void> {\r\n if (this.isCompatibleViewport(current, true))\r\n return;\r\n return this.onRestartTool();\r\n }\r\n\r\n /**\r\n * Called when an external event may invalidate the current tool's state.\r\n * Examples are undo, which may invalidate any references to elements, or an incompatible active view change.\r\n * The active tool is expected to call installTool with a new instance, or exitTool to start the default tool.\r\n * ```ts\r\n * const tool = new MyPrimitiveTool();\r\n * if (!await tool.run())\r\n * return this.exitTool(); // Don't leave current instance active if new instance rejects install...\r\n * ```\r\n */\r\n public abstract onRestartTool(): Promise<void>;\r\n\r\n /**\r\n * Called to reset tool to initial state. PrimitiveTool implements this method to call onRestartTool.\r\n */\r\n public override async onReinitialize(): Promise<void> { return this.onRestartTool(); }\r\n\r\n public async exitTool() { return IModelApp.toolAdmin.startDefaultTool(); }\r\n\r\n /**\r\n * Called to reverse to a previous tool state (ex. undo last data button).\r\n * @return false to instead reverse the most recent transaction.\r\n */\r\n public async onUndoPreviousStep(): Promise<boolean> { return false; }\r\n\r\n /** @internal */\r\n public async undoPreviousStep(): Promise<boolean> {\r\n if (!await this.onUndoPreviousStep())\r\n return false;\r\n\r\n AccuDrawShortcuts.processPendingHints(); // Process pending hints from onUndoPreviousStep before calling updateDynamics...\r\n IModelApp.viewManager.invalidateDecorationsAllViews();\r\n IModelApp.toolAdmin.updateDynamics(undefined, undefined, true); // Don't wait for motion to update dynamics...\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Called to reinstate to a previous tool state (ex. redo last data button).\r\n * @return false to instead reinstate the most recent transaction.\r\n */\r\n public async onRedoPreviousStep(): Promise<boolean> { return false; }\r\n\r\n /** @internal */\r\n public async redoPreviousStep(): Promise<boolean> {\r\n if (!await this.onRedoPreviousStep())\r\n return false;\r\n\r\n AccuDrawShortcuts.processPendingHints(); // Process pending hints from onRedoPreviousStep before calling updateDynamics...\r\n IModelApp.viewManager.invalidateDecorationsAllViews();\r\n IModelApp.toolAdmin.updateDynamics(undefined, undefined, true); // Don't wait for motion to update dynamics...\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * If this tool is editing a briefcase, commits any elements that the tool has changed, supplying the tool flyover for the undo description.\r\n * @deprecated in 5.1.9 - will not be removed until after 2027-05-04. Use methods on [[EditCommand]] IPC instead.\r\n */\r\n public async saveChanges(): Promise<void> {\r\n if (this.iModel.isBriefcaseConnection())\r\n return this.iModel.saveChanges(this.flyover); // eslint-disable-line @typescript-eslint/no-deprecated\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"PrimitiveTool.js","sourceRoot":"","sources":["../../../src/tools/PrimitiveTool.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA6C;AAE7C,4CAAyC;AAEzC,gEAAqF;AAErF,iDAAmD;AACnD,iCAAsG;AAEtG;;;;GAIG;AACH,MAAsB,aAAc,SAAQ,sBAAe;IACzD;;OAEG;IACI,UAAU,CAAY;IACrB,cAAc,CAAU;IAChC,IAAW,aAAa,KAAK,OAAO,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC;IAC1D,IAAW,aAAa,CAAC,CAAqB,IAAI,IAAI,CAAC,cAAc,GAAG,CAAC,CAAC,CAAC,CAAC;IACrE,cAAc,GAAY,KAAK,CAAC,CAAC,yFAAyF;IAEjI;;OAEG;IACH,IAAW,MAAM;QACf,IAAA,qBAAM,EAAC,SAAS,KAAK,IAAI,CAAC,UAAU,CAAC,CAAC;QACtC,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC;IACrC,CAAC;IAED,sIAAsI;IACtI,IAAW,SAAS;QAClB,MAAM,MAAM,GAAG,IAAI,CAAC,UAA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E,gBAAgB;IACT,KAAK,CAAC,gBAAgB;QAC3B,IAAI,CAAC,MAAM,IAAI,CAAC,kBAAkB,EAAE;YAClC,OAAO,KAAK,CAAC;QAEf,gCAAiB,CAAC,mBAAmB,EAAE,CAAC,CAAC,iFAAiF;QAC1H,qBAAS,CAAC,WAAW,CAAC,6BAA6B,EAAE,CAAC;QACtD,qBAAS,CAAC,SAAS,CAAC,cAAc,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,8CAA8C;QAE9G,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,kBAAkB,KAAuB,OAAO,KAAK,CAAC,CAAC,CAAC;IAErE,gBAAgB;IACT,KAAK,CAAC,gBAAgB;QAC3B,IAAI,CAAC,MAAM,IAAI,CAAC,kBAAkB,EAAE;YAClC,OAAO,KAAK,CAAC;QAEf,gCAAiB,CAAC,mBAAmB,EAAE,CAAC,CAAC,iFAAiF;QAC1H,qBAAS,CAAC,WAAW,CAAC,6BAA6B,EAAE,CAAC;QACtD,qBAAS,CAAC,SAAS,CAAC,cAAc,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,8CAA8C;QAE9G,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,WAAW;QACtB,IAAI,IAAI,CAAC,MAAM,CAAC,qBAAqB,EAAE;YACrC,OAAO,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,uDAAuD;IACzG,CAAC;CACF;AAjND,sCAiNC","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 Tools\r\n */\r\n\r\nimport { assert } from \"@itwin/core-bentley\";\r\nimport { BriefcaseConnection } from \"../BriefcaseConnection\";\r\nimport { IModelApp } from \"../IModelApp\";\r\nimport { IModelConnection } from \"../IModelConnection\";\r\nimport { NotifyMessageDetails, OutputMessagePriority } from \"../NotificationManager\";\r\nimport { Viewport } from \"../Viewport\";\r\nimport { AccuDrawShortcuts } from \"./AccuDrawTool\";\r\nimport { BeButton, BeButtonEvent, CoordinateLockOverrides, CoreTools, InteractiveTool } from \"./Tool\";\r\n\r\n/** The PrimitiveTool class can be used to implement tools to create or modify geometric elements.\r\n * @see [Writing a PrimitiveTool]($docs/learning/frontend/primitivetools.md)\r\n * @public\r\n * @extensions\r\n */\r\nexport abstract class PrimitiveTool extends InteractiveTool {\r\n /** The viewport within which the tool operates.\r\n * @note This property is only initialized if [[run]] returns `true`, causing the tool to be installed.\r\n */\r\n public targetView?: Viewport;\r\n private _targetModelId?: string;\r\n public get targetModelId() { return this._targetModelId; }\r\n public set targetModelId(v: string | undefined) { this._targetModelId = v; }\r\n public targetIsLocked: boolean = false; // If target model is known, set this to true in constructor and override getTargetModel.\r\n\r\n /** Get the iModel on which this tool operates.\r\n * @note The iModel is obtained from [[targetView]], so should only be invoked if the tool installed successfully.\r\n */\r\n public get iModel(): IModelConnection {\r\n assert(undefined !== this.targetView);\r\n return this.targetView.view.iModel;\r\n }\r\n\r\n /** Get the briefcase on which this tool operates, if the tool has successfully installed and the target [[iModel]] is a briefcase. */\r\n public get briefcase(): BriefcaseConnection | undefined {\r\n const iModel = this.targetView?.view.iModel;\r\n return iModel?.isBriefcaseConnection() ? iModel : undefined;\r\n }\r\n\r\n /**\r\n * Establish this tool as the active PrimitiveTool.\r\n * @return true if this tool was installed (though it may have exited too)\r\n * @note If you override this method you **must** call `super.run` and return false if it returns false.\r\n */\r\n public override async run(..._args: any[]): Promise<boolean> {\r\n const { toolAdmin, viewManager } = IModelApp;\r\n if (!this.isCompatibleViewport(viewManager.selectedView, false))\r\n return false;\r\n\r\n if (!await toolAdmin.onInstallTool(this))\r\n return false;\r\n\r\n await toolAdmin.startPrimitiveTool(this);\r\n // If another tool was installed at the same time (due to concurrent run calls),\r\n // the last start to complete wins. Detect that situation and return false.\r\n if (toolAdmin.primitiveTool !== this)\r\n return false;\r\n\r\n await toolAdmin.onPostInstallTool(this);\r\n return true;\r\n }\r\n\r\n /** Determine whether the supplied Viewport is compatible with this tool.\r\n * @param vp the Viewport to check\r\n */\r\n public override isCompatibleViewport(vp: Viewport | undefined, isSelectedViewChange: boolean): boolean {\r\n if (undefined === vp)\r\n return false; // No views are open...\r\n\r\n const view = vp.view;\r\n const iModel = view.iModel;\r\n\r\n if (this.requireWriteableTarget() && iModel.isReadonly)\r\n return false; // this Tool can't be used when iModel is read only.\r\n\r\n if (undefined === this.targetView || (!this.targetIsLocked && isSelectedViewChange))\r\n this.targetView = vp; // Update target to new view if undefined or still free to change.\r\n\r\n if (undefined === this.targetModelId && (!this.targetIsLocked || vp === this.targetView))\r\n return true; // Accept if this view is current target or any type of model/view is still ok as target is still free to change.\r\n\r\n if (iModel !== this.iModel)\r\n return false; // Once a ViewState has been established, only accept viewport showing the same iModel.\r\n\r\n if (this.targetModelId)\r\n return view.viewsModel(this.targetModelId); // If a specific target model is specified, only allow view that shows it.\r\n\r\n if (view.isSpatialView() && this.targetView.view.isSpatialView())\r\n return true; // No specific target, two spatial views are considered compatible.\r\n\r\n let allowView = false;\r\n const targetView = this.targetView;\r\n view.forEachModel((model) => {\r\n if (!allowView && targetView.view.viewsModel(model.id))\r\n allowView = true;\r\n });\r\n\r\n return allowView; // Accept if this view shares a model in common with target.\r\n }\r\n\r\n /**\r\n * Checks that the adjusted point from the supplied button event is within the project extents for spatial views. The range of physical geometry\r\n * should always be fully inside the project extents. Only checking the adjusted point won't absolutely guarantee that a tool doesn't create/move geometry\r\n * outside the project extents, but it will be sufficient to handle most cases and provide good feedback to the user.\r\n * @return true if ev is acceptable.\r\n */\r\n public override isValidLocation(ev: BeButtonEvent, isButtonEvent: boolean): boolean {\r\n const vp = ev.viewport;\r\n if (undefined === vp)\r\n return false;\r\n\r\n if (isButtonEvent && BeButton.Data !== ev.button)\r\n return true;\r\n\r\n const view = vp.view;\r\n if (!view.isSpatialView())\r\n return true;\r\n\r\n // NOTE: If points aren't being adjusted then the tool shouldn't be creating geometry currently (ex. locating elements) and we shouldn't filter point...\r\n if (0 !== (IModelApp.toolAdmin.toolState.coordLockOvr & CoordinateLockOverrides.ACS))\r\n return true;\r\n\r\n // We know the tool isn't doing a locate, we don't know what it will do with this point. Minimize erroneous filtering by restricting the check to when AccuSnap is tool enable (not user enabled)...\r\n if (!IModelApp.accuSnap.isSnapEnabled)\r\n return true;\r\n\r\n const extents = view.iModel.projectExtents;\r\n if (extents.containsPoint(ev.point))\r\n return true;\r\n\r\n if (isButtonEvent && ev.isDown)\r\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Error, CoreTools.translate(\"ElementSet.Error.ProjectExtents\")));\r\n\r\n return false;\r\n }\r\n\r\n /** Called on data button down event to lock the tool to its current target model. */\r\n public autoLockTarget(): void {\r\n if (undefined === this.targetView)\r\n return;\r\n\r\n this.targetIsLocked = true;\r\n }\r\n\r\n /** Returns the prompt based on the tool's current state. */\r\n public getPrompt(): string { return \"\"; }\r\n\r\n /** Called from isCompatibleViewport to check for a read only iModel, which is not a valid target for tools that create or modify elements. */\r\n public requireWriteableTarget(): boolean { return true; }\r\n\r\n /**\r\n * Called when active view changes. Tool may choose to restart or exit based on current view type.\r\n * @param _previous The previously active view.\r\n * @param current The new active view.\r\n */\r\n public override async onSelectedViewportChanged(_previous: Viewport | undefined, current: Viewport | undefined): Promise<void> {\r\n if (this.isCompatibleViewport(current, true))\r\n return;\r\n return this.onRestartTool();\r\n }\r\n\r\n /**\r\n * Called when an external event may invalidate the current tool's state.\r\n * Examples are undo, which may invalidate any references to elements, or an incompatible active view change.\r\n * The active tool is expected to call installTool with a new instance, or exitTool to start the default tool.\r\n * ```ts\r\n * const tool = new MyPrimitiveTool();\r\n * if (!await tool.run())\r\n * return this.exitTool(); // Don't leave current instance active if new instance rejects install...\r\n * ```\r\n */\r\n public abstract onRestartTool(): Promise<void>;\r\n\r\n /**\r\n * Called to reset tool to initial state. PrimitiveTool implements this method to call onRestartTool.\r\n */\r\n public override async onReinitialize(): Promise<void> { return this.onRestartTool(); }\r\n\r\n public async exitTool() { return IModelApp.toolAdmin.startDefaultTool(); }\r\n\r\n /**\r\n * Called to reverse to a previous tool state (ex. undo last data button).\r\n * @return false to instead reverse the most recent transaction.\r\n */\r\n public async onUndoPreviousStep(): Promise<boolean> { return false; }\r\n\r\n /** @internal */\r\n public async undoPreviousStep(): Promise<boolean> {\r\n if (!await this.onUndoPreviousStep())\r\n return false;\r\n\r\n AccuDrawShortcuts.processPendingHints(); // Process pending hints from onUndoPreviousStep before calling updateDynamics...\r\n IModelApp.viewManager.invalidateDecorationsAllViews();\r\n IModelApp.toolAdmin.updateDynamics(undefined, undefined, true); // Don't wait for motion to update dynamics...\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Called to reinstate to a previous tool state (ex. redo last data button).\r\n * @return false to instead reinstate the most recent transaction.\r\n */\r\n public async onRedoPreviousStep(): Promise<boolean> { return false; }\r\n\r\n /** @internal */\r\n public async redoPreviousStep(): Promise<boolean> {\r\n if (!await this.onRedoPreviousStep())\r\n return false;\r\n\r\n AccuDrawShortcuts.processPendingHints(); // Process pending hints from onRedoPreviousStep before calling updateDynamics...\r\n IModelApp.viewManager.invalidateDecorationsAllViews();\r\n IModelApp.toolAdmin.updateDynamics(undefined, undefined, true); // Don't wait for motion to update dynamics...\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * If this tool is editing a briefcase, commits any elements that the tool has changed, supplying the tool flyover for the undo description.\r\n * @deprecated in 5.9.0 - will not be removed until after 2027-05-04. Use methods on [[EditCommand]] IPC instead.\r\n */\r\n public async saveChanges(): Promise<void> {\r\n if (this.iModel.isBriefcaseConnection())\r\n return this.iModel.saveChanges(this.flyover); // eslint-disable-line @typescript-eslint/no-deprecated\r\n }\r\n}\r\n"]}
@@ -144,11 +144,11 @@ export declare class BriefcaseConnection extends IModelConnection {
144
144
  hasPendingTxns(): Promise<boolean>;
145
145
  /** Commit pending changes to this briefcase.
146
146
  * @param description Optional description of the changes.
147
- * @deprecated in 5.1.9 - will not be removed until after 2027-05-04. Use methods on EditCommand instead.
147
+ * @deprecated in 5.9.0 - will not be removed until after 2027-05-04. Use methods on EditCommand instead.
148
148
  */
149
149
  saveChanges(description?: string): Promise<void>;
150
150
  /** Abandon pending changes to this briefcase.
151
- * @deprecated in 5.1.9 - will not be removed until after 2027-05-04. Use methods on EditCommand instead.
151
+ * @deprecated in 5.9.0 - will not be removed until after 2027-05-04. Use methods on EditCommand instead.
152
152
  */
153
153
  abandonChanges(): Promise<void>;
154
154
  /** Pull (and potentially merge if there are local changes) up to a specified changeset from iModelHub into this briefcase
@@ -244,13 +244,13 @@ export class BriefcaseConnection extends IModelConnection {
244
244
  }
245
245
  /** Commit pending changes to this briefcase.
246
246
  * @param description Optional description of the changes.
247
- * @deprecated in 5.1.9 - will not be removed until after 2027-05-04. Use methods on EditCommand instead.
247
+ * @deprecated in 5.9.0 - will not be removed until after 2027-05-04. Use methods on EditCommand instead.
248
248
  */
249
249
  async saveChanges(description) {
250
250
  await IpcApp.appFunctionIpc.saveChanges(this.key, description); // eslint-disable-line @typescript-eslint/no-deprecated
251
251
  }
252
252
  /** Abandon pending changes to this briefcase.
253
- * @deprecated in 5.1.9 - will not be removed until after 2027-05-04. Use methods on EditCommand instead.
253
+ * @deprecated in 5.9.0 - will not be removed until after 2027-05-04. Use methods on EditCommand instead.
254
254
  */
255
255
  async abandonChanges() {
256
256
  await IpcApp.appFunctionIpc.abandonChanges(this.key); // eslint-disable-line @typescript-eslint/no-deprecated
@@ -1 +1 @@
1
- {"version":3,"file":"BriefcaseConnection.js","sourceRoot":"","sources":["../../src/BriefcaseConnection.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,MAAM,E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,CAAC;YACtD,eAAe,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE,WAAW,EAAE,mBAAmB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC;QACxF,CAAC;QAED,IAAI,CAAC,eAAe,EAAE,CAAC;QACvB,MAAM,aAAa,GAA6B;YAC9C,cAAc,EAAE,oBAAoB;YACpC,gBAAgB,EAAE,OAAO,EAAE,gBAAgB;YAC3C,kBAAkB,EAAE,CAAC,CAAC,OAAO,EAAE,WAAW;SAC3C,CAAC;QACF,IAAI,CAAC;YACH,IAAI,CAAC,SAAS,GAAG,MAAM,MAAM,CAAC,cAAc,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,EAAE,OAAO,EAAE,aAAa,CAAC,CAAC;QAC7F,CAAC;gBAAS,CAAC;YACT,eAAe,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC;QAChD,CAAC;IACH,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,WAAW,CAAC,WAAmB;QAC1C,IAAI,CAAC,eAAe,EAAE,CAAC;QACvB,OAAO,MAAM,CAAC,cAAc,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;IAClE,CAAC;IAED;;OAEG;IACH,IAAW,YAAY;QACrB,OAAO,IAAI,CAAC,cAAc,CAAC,YAAY,CAAC;IAC1C,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,wBAAwB;QACnC,OAAO,MAAM,CAAC,cAAc,CAAC,2BAA2B,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACrE,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,iBAAiB;QAC5B,OAAO,IAAI,CAAC,cAAc,CAAC,iBAAiB,EAAE,CAAC;IACjD,CAAC;IAED;;OAEG;IACa,sBAAsB,GAAG,IAAI,OAAO,EAA0C,CAAC;CAChG","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 IModelConnection\r\n */\r\n\r\nimport { assert, BeEvent, CompressedId64Set, Guid, GuidString, Id64Set, Id64String, IModelStatus, OpenMode } from \"@itwin/core-bentley\";\r\nimport {\r\n BriefcaseConnectionProps, ChangesetIndex, ChangesetIndexAndId, getPullChangesIpcChannel, IModelError,\r\n PullChangesOptions as IpcAppPullChangesOptions, LockState, OpenBriefcaseProps, StandaloneOpenOptions,\r\n} from \"@itwin/core-common\";\r\nimport { BriefcaseTxns } from \"./BriefcaseTxns\";\r\nimport { GraphicalEditingScope } from \"./GraphicalEditingScope\";\r\nimport { IModelApp } from \"./IModelApp\";\r\nimport { IModelConnection } from \"./IModelConnection\";\r\nimport { IpcApp } from \"./IpcApp\";\r\nimport { disposeTileTreesForGeometricModels } from \"./tile/internal\";\r\nimport { Viewport } from \"./Viewport\";\r\n\r\n/**\r\n * Download progress information.\r\n * @public\r\n */\r\nexport interface DownloadProgressInfo {\r\n /** Bytes downloaded. */\r\n loaded: number;\r\n /** Total size of the download in bytes. */\r\n total: number;\r\n}\r\n\r\n/**\r\n * Called to show progress during a download.\r\n * @public\r\n */\r\nexport type OnDownloadProgress = (progress: DownloadProgressInfo) => void;\r\n\r\n/**\r\n * Partial interface of AbortSignal.\r\n * @see https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal\r\n * @beta\r\n */\r\nexport interface GenericAbortSignal {\r\n /** Add Listener for abort signal. */\r\n addEventListener: (type: \"abort\", listener: (this: GenericAbortSignal, ev: any) => any) => void;\r\n /** Remove Listener for abort signal. */\r\n removeEventListener: (type: \"abort\", listener: (this: GenericAbortSignal, ev: any) => any) => void;\r\n}\r\n\r\n/**\r\n * Options for pulling iModel changes.\r\n * @public\r\n */\r\nexport interface PullChangesOptions {\r\n /** Function called regularly to report progress of changes download. */\r\n downloadProgressCallback?: OnDownloadProgress;\r\n /** Interval for calling progress callback (in milliseconds). */\r\n progressInterval?: number;\r\n /** Signal for cancelling the download.\r\n * @beta\r\n */\r\n abortSignal?: GenericAbortSignal;\r\n}\r\n\r\n/** Keeps track of changes to models, buffering them until synchronization points.\r\n * While a GraphicalEditingScope is open, the changes are buffered until the scope exits, at which point they are processed.\r\n * Otherwise, the buffered changes are processed after undo/redo, commit, or pull+merge changes.\r\n */\r\nclass ModelChangeMonitor {\r\n private _editingScope?: GraphicalEditingScope;\r\n private readonly _briefcase: BriefcaseConnection;\r\n private readonly _deletedModels = new Set<string>();\r\n private readonly _modelIdToGuid = new Map<string, string>();\r\n private readonly _removals: VoidFunction[] = [];\r\n\r\n public constructor(briefcase: BriefcaseConnection) {\r\n this._briefcase = briefcase;\r\n\r\n // Buffer updated geometry guids.\r\n this._removals.push(briefcase.txns.onModelGeometryChanged.addListener((changes) => {\r\n for (const change of changes) {\r\n this._deletedModels.delete(change.id);\r\n this._modelIdToGuid.set(change.id, change.guid);\r\n }\r\n }));\r\n\r\n // Buffer deletions of models.\r\n this._removals.push(briefcase.txns.onModelsChanged.addListener((changes) => {\r\n if (changes.deleted) {\r\n for (const id of CompressedId64Set.iterable(changes.deleted)) {\r\n this._modelIdToGuid.delete(id);\r\n this._deletedModels.add(id);\r\n }\r\n }\r\n }));\r\n\r\n // Outside of an editing scope, we want to update viewport contents after commit, undo/redo, or merging changes.\r\n const maybeProcess = async () => {\r\n if (this.editingScope)\r\n return;\r\n\r\n const modelIds = Array.from(this._modelIdToGuid.keys());\r\n if (modelIds.length > 0)\r\n await IModelApp.tileAdmin.purgeTileTrees(this._briefcase, modelIds);\r\n\r\n this.processBuffered();\r\n };\r\n\r\n this._removals.push(briefcase.txns.onCommitted.addListener(maybeProcess));\r\n this._removals.push(briefcase.txns.onReplayedExternalTxns.addListener(maybeProcess));\r\n this._removals.push(briefcase.txns.onAfterUndoRedo.addListener(maybeProcess));\r\n this._removals.push(briefcase.txns.onChangesPulled.addListener(maybeProcess));\r\n }\r\n\r\n public async close(): Promise<void> {\r\n for (const removal of this._removals)\r\n removal();\r\n\r\n this._removals.length = 0;\r\n\r\n if (this._editingScope) {\r\n await this._editingScope.exit();\r\n this._editingScope = undefined;\r\n }\r\n }\r\n\r\n public get editingScope(): GraphicalEditingScope | undefined {\r\n return this._editingScope;\r\n }\r\n\r\n public async enterEditingScope(): Promise<GraphicalEditingScope> {\r\n if (this._editingScope)\r\n throw new Error(\"Cannot create an editing scope for an iModel that already has one\");\r\n\r\n this._editingScope = await GraphicalEditingScope.enter(this._briefcase);\r\n\r\n const removeGeomListener = this._editingScope.onGeometryChanges.addListener((changes) => {\r\n const modelIds = [];\r\n for (const change of changes)\r\n modelIds.push(change.id);\r\n\r\n this.invalidateScenes(modelIds);\r\n });\r\n\r\n this._editingScope.onExited.addOnce((scope) => {\r\n assert(scope === this._editingScope);\r\n this._editingScope = undefined;\r\n removeGeomListener();\r\n this.processBuffered();\r\n });\r\n\r\n return this._editingScope;\r\n }\r\n\r\n private processBuffered(): void {\r\n const models = this._briefcase.models;\r\n for (const [id, guid] of this._modelIdToGuid) {\r\n const model = models.getLoaded(id)?.asGeometricModel;\r\n if (model)\r\n model.geometryGuid = guid;\r\n }\r\n\r\n const modelIds = new Set<string>(this._modelIdToGuid.keys());\r\n for (const deleted of this._deletedModels) {\r\n modelIds.add(deleted);\r\n models.unload(deleted);\r\n }\r\n\r\n this.invalidateScenes(modelIds);\r\n disposeTileTreesForGeometricModels(modelIds, this._briefcase);\r\n\r\n this._briefcase.onBufferedModelChanges.raiseEvent(modelIds);\r\n\r\n this._modelIdToGuid.clear();\r\n this._deletedModels.clear();\r\n }\r\n\r\n private invalidateScenes(changedModels: Iterable<Id64String>): void {\r\n for (const user of IModelApp.tileAdmin.tileUsers) {\r\n if (user instanceof Viewport && user.iModel === this._briefcase) {\r\n for (const modelId of changedModels) {\r\n if (user.view.viewsModel(modelId)) {\r\n user.invalidateScene();\r\n user.setFeatureOverrideProviderChanged();\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Provides access to lock information in the iModel.\r\n * @see [[BriefcaseConnection.locks]]\r\n * @alpha\r\n */\r\nexport interface LockService {\r\n /** Get all elements with exclusive locks owned by other briefcases. */\r\n getExclusiveForeignLocks(): Promise<Id64Set>;\r\n /** Get all elements with shared locks owned by other briefcases. */\r\n getSharedForeignLocks(): Promise<Id64Set>;\r\n /** Check whether it's possible to acquire a lock for the element. */\r\n checkElementLockAvailability(elementId: Id64String, lock: LockState): Promise<boolean>;\r\n}\r\n\r\n/** Function for creating a [[LockService]] for a [[BriefcaseConnection]].\r\n * @alpha\r\n */\r\nexport type LockServiceFactory = (iModel: BriefcaseConnection) => Promise<LockService>;\r\n\r\n/** Settings that can be used to control the behavior of [[Tool]]s that modify a [[BriefcaseConnection]].\r\n * For example, tools that want to create new elements can consult the briefcase's editor tool settings to\r\n * determine into which model and category to insert the elements.\r\n * Specialized tools are free to ignore these settings.\r\n * @see [[BriefcaseConnection.editorToolSettings]] to query or modify the current settings for a briefcase.\r\n * @see [CreateElementTool]($editor-frontend) for an example of a tool that uses these settings.\r\n * @beta\r\n */\r\nexport class BriefcaseEditorToolSettings {\r\n private _category?: Id64String;\r\n private _model?: Id64String;\r\n\r\n /** An event raised just after the default [[category]] is changed. */\r\n public readonly onCategoryChanged = new BeEvent<(previousCategory: Id64String | undefined) => void>();\r\n\r\n /** An event raised just after the default [[model]] is changed. */\r\n public readonly onModelChanged = new BeEvent<(previousModel: Id64String | undefined) => void>();\r\n\r\n /** The [Category]($backend) into which new elements should be inserted by default.\r\n * Specialized tools are free to ignore this setting and instead use their own logic to select an appropriate category.\r\n * @see [[onCategoryChanged]] to be notified when this property is modified.\r\n * @see [CreateElementTool.targetCategory]($editor-frontend) for an example of a tool that uses this setting.\r\n */\r\n public get category(): Id64String | undefined {\r\n return this._category;\r\n }\r\n public set category(category: Id64String | undefined) {\r\n const previousCategory = this.category;\r\n if (category !== this.category) {\r\n this._category = category;\r\n this.onCategoryChanged.raiseEvent(previousCategory);\r\n }\r\n }\r\n\r\n /** The [Model]($backend) into which new elements should be inserted by default.\r\n * Specialized tools are free to ignore this setting and instead use their own logic to select an appropriate model.\r\n * @see [[onModelChanged]] to be notified when this property is modified.\r\n * @see [CreateElementTool.targetModelId]($editor-frontend) for an example of a tool that uses this setting.\r\n */\r\n public get model(): Id64String | undefined {\r\n return this._model;\r\n }\r\n public set model(model: Id64String | undefined) {\r\n const previousModel = this.model;\r\n if (model !== this.model) {\r\n this._model = model;\r\n this.onModelChanged.raiseEvent(previousModel);\r\n }\r\n }\r\n}\r\n\r\n/** A connection to an editable briefcase on the backend. This class uses [Ipc]($docs/learning/IpcInterface.md) to communicate\r\n * to the backend and may only be used by [[IpcApp]]s.\r\n * @public\r\n */\r\nexport class BriefcaseConnection extends IModelConnection {\r\n protected _isClosed?: boolean;\r\n private readonly _modelsMonitor: ModelChangeMonitor;\r\n private _locks?: LockService;\r\n\r\n /** The ID of the briefcase.\r\n * @beta\r\n */\r\n public readonly briefcaseId?: number;\r\n\r\n /** Default settings that can be used to control the behavior of [[Tool]]s that modify this briefcase.\r\n * @beta\r\n */\r\n public readonly editorToolSettings = new BriefcaseEditorToolSettings();\r\n\r\n /** Manages local changes to the briefcase via [Txns]($docs/learning/InteractiveEditing.md). */\r\n public readonly txns: BriefcaseTxns;\r\n\r\n /** Information about locks held on this iModel.\r\n * @note This is intended to be used by tools and other UI elements, to provide information about the current lock state. Implementations are expected to cache lock information and so may not reflect changes to locks immediately.\r\n * @alpha\r\n */\r\n public get locks(): LockService | undefined { return this._locks; }\r\n\r\n public override isBriefcaseConnection(): this is BriefcaseConnection { return true; }\r\n\r\n /** The Guid that identifies the iTwin that owns this iModel. */\r\n public override get iTwinId(): GuidString { return super.iTwinId ?? Guid.empty; } // GuidString | undefined for IModelConnection, but required for BriefcaseConnection\r\n\r\n /** The Guid that identifies this iModel. */\r\n public override get iModelId(): GuidString { return super.iModelId ?? Guid.empty; } // GuidString | undefined for IModelConnection, but required for BriefcaseConnection\r\n\r\n protected constructor(props: BriefcaseConnectionProps, openMode: OpenMode) {\r\n super(props);\r\n this._openMode = openMode;\r\n this.briefcaseId = props.briefcaseId;\r\n this.txns = new BriefcaseTxns(this);\r\n this._modelsMonitor = new ModelChangeMonitor(this);\r\n if (OpenMode.ReadWrite === this._openMode)\r\n this.txns.onAfterUndoRedo.addListener(async () => { await IModelApp.toolAdmin.restartPrimitiveTool(); });\r\n\r\n this.categories.cache.attachToBriefcase(this);\r\n }\r\n\r\n /** Open a BriefcaseConnection to a [BriefcaseDb]($backend). */\r\n public static async openFile(briefcaseProps: OpenBriefcaseProps): Promise<BriefcaseConnection>;\r\n\r\n /** Open a BriefcaseConnection to a [BriefcaseDb]($backend).\r\n * @alpha\r\n */\r\n public static async openFile(briefcaseProps: OpenBriefcaseProps, lockServiceFactory?: LockServiceFactory): Promise<BriefcaseConnection>\r\n\r\n public static async openFile(briefcaseProps: OpenBriefcaseProps, lockServiceFactory?: LockServiceFactory): Promise<BriefcaseConnection> {\r\n const iModelProps = await IpcApp.appFunctionIpc.openBriefcase(briefcaseProps);\r\n const connection = new this({ ...briefcaseProps, ...iModelProps }, briefcaseProps.readonly ? OpenMode.Readonly : OpenMode.ReadWrite);\r\n if (lockServiceFactory)\r\n connection._locks = await lockServiceFactory(connection);\r\n\r\n IModelConnection.onOpen.raiseEvent(connection);\r\n return connection;\r\n }\r\n\r\n /** Open a BriefcaseConnection to a [StandaloneDb]($backend)\r\n * @note StandaloneDbs, by definition, may not push or pull changes. Attempting to do so will throw exceptions.\r\n */\r\n public static async openStandalone(filePath: string, openMode: OpenMode = OpenMode.ReadWrite, opts?: StandaloneOpenOptions): Promise<BriefcaseConnection> {\r\n const openResponse = await IpcApp.appFunctionIpc.openStandalone(filePath, openMode, opts);\r\n const connection = new this(openResponse, openMode);\r\n IModelConnection.onOpen.raiseEvent(connection);\r\n return connection;\r\n }\r\n\r\n /** Returns `true` if [[close]] has already been called. */\r\n public get isClosed(): boolean { return this._isClosed === true; }\r\n\r\n /**\r\n * Close this BriefcaseConnection.\r\n * @note make sure to call [[saveChanges]] before calling this method. Unsaved local changes are abandoned.\r\n */\r\n public async close(): Promise<void> {\r\n if (this.isClosed)\r\n return;\r\n\r\n await this._modelsMonitor.close();\r\n\r\n this.beforeClose();\r\n this.txns[Symbol.dispose]();\r\n\r\n this._isClosed = true;\r\n await IpcApp.appFunctionIpc.closeIModel(this._fileKey);\r\n }\r\n\r\n protected requireTimeline() {\r\n if (this.iTwinId === Guid.empty)\r\n throw new IModelError(IModelStatus.WrongIModel, \"iModel has no timeline\");\r\n }\r\n\r\n /** Query if there are any pending Txns in this briefcase that are waiting to be pushed. */\r\n public async hasPendingTxns(): Promise<boolean> { // eslint-disable-line @itwin/prefer-get\r\n return this.txns.hasPendingTxns();\r\n }\r\n\r\n /** Commit pending changes to this briefcase.\r\n * @param description Optional description of the changes.\r\n * @deprecated in 5.1.9 - will not be removed until after 2027-05-04. Use methods on EditCommand instead.\r\n */\r\n public async saveChanges(description?: string): Promise<void> {\r\n await IpcApp.appFunctionIpc.saveChanges(this.key, description); // eslint-disable-line @typescript-eslint/no-deprecated\r\n }\r\n\r\n /** Abandon pending changes to this briefcase.\r\n * @deprecated in 5.1.9 - will not be removed until after 2027-05-04. Use methods on EditCommand instead.\r\n */\r\n public async abandonChanges(): Promise<void> {\r\n await IpcApp.appFunctionIpc.abandonChanges(this.key); // eslint-disable-line @typescript-eslint/no-deprecated\r\n }\r\n\r\n /** Pull (and potentially merge if there are local changes) up to a specified changeset from iModelHub into this briefcase\r\n * @param toIndex The changeset index to pull changes to. If `undefined`, pull all changes.\r\n * @param options Options for pulling changes.\r\n * @see [[BriefcaseTxns.onChangesPulled]] for the event dispatched after changes are pulled.\r\n */\r\n public async pullChanges(toIndex?: ChangesetIndex, options?: PullChangesOptions): Promise<void> {\r\n const removeListeners: VoidFunction[] = [];\r\n const shouldReportProgress = !!options?.downloadProgressCallback;\r\n\r\n if (shouldReportProgress) {\r\n const handleProgress = (_evt: Event, data: { loaded: number, total: number }) => {\r\n options?.downloadProgressCallback?.(data);\r\n };\r\n\r\n const removeProgressListener = IpcApp.addListener(\r\n getPullChangesIpcChannel(this.iModelId),\r\n handleProgress,\r\n );\r\n removeListeners.push(removeProgressListener);\r\n }\r\n\r\n if (options?.abortSignal) {\r\n const abort = () => void IpcApp.appFunctionIpc.cancelPullChangesRequest(this.key);\r\n options?.abortSignal.addEventListener(\"abort\", abort);\r\n removeListeners.push(() => options?.abortSignal?.removeEventListener(\"abort\", abort));\r\n }\r\n\r\n this.requireTimeline();\r\n const ipcAppOptions: IpcAppPullChangesOptions = {\r\n reportProgress: shouldReportProgress,\r\n progressInterval: options?.progressInterval,\r\n enableCancellation: !!options?.abortSignal,\r\n };\r\n try {\r\n this.changeset = await IpcApp.appFunctionIpc.pullChanges(this.key, toIndex, ipcAppOptions);\r\n } finally {\r\n removeListeners.forEach((remove) => remove());\r\n }\r\n }\r\n\r\n /** Create a changeset from local Txns and push to iModelHub. On success, clear Txn table.\r\n * @param description The description for the changeset\r\n * @returns the changesetId of the pushed changes\r\n * @see [[BriefcaseTxns.onChangesPushed]] for the event dispatched after changes are pushed.\r\n */\r\n public async pushChanges(description: string): Promise<ChangesetIndexAndId> {\r\n this.requireTimeline();\r\n return IpcApp.appFunctionIpc.pushChanges(this.key, description);\r\n }\r\n\r\n /** The current graphical editing scope, if one is in progress.\r\n * @see [[enterEditingScope]] to begin graphical editing.\r\n */\r\n public get editingScope(): GraphicalEditingScope | undefined {\r\n return this._modelsMonitor.editingScope;\r\n }\r\n\r\n /** Return whether graphical editing is supported for this briefcase. It is not supported if the briefcase is read-only, or the briefcase contains a version of\r\n * the BisCore ECSchema older than v0.1.11.\r\n * @see [[enterEditingScope]] to enable graphical editing.\r\n */\r\n public async supportsGraphicalEditing(): Promise<boolean> {\r\n return IpcApp.appFunctionIpc.isGraphicalEditingSupported(this.key);\r\n }\r\n\r\n /** Begin a new graphical editing scope.\r\n * @throws Error if an editing scope already exists or one could not be created.\r\n * @see [[GraphicalEditingScope.exit]] to exit the scope.\r\n * @see [[supportsGraphicalEditing]] to determine whether this method should be expected to succeed.\r\n * @see [[editingScope]] to obtain the current editing scope, if one is in progress.\r\n */\r\n public async enterEditingScope(): Promise<GraphicalEditingScope> {\r\n return this._modelsMonitor.enterEditingScope();\r\n }\r\n\r\n /** Strictly for tests - dispatched from ModelChangeMonitor.processBuffered.\r\n * @internal\r\n */\r\n public readonly onBufferedModelChanges = new BeEvent<(changedModelIds: Set<string>) => void>();\r\n}\r\n"]}
1
+ {"version":3,"file":"BriefcaseConnection.js","sourceRoot":"","sources":["../../src/BriefcaseConnection.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,EAAE,IAAI,EAAmC,YAAY,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACxI,OAAO,EAC0D,wBAAwB,EAAE,WAAW,GAErG,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,kCAAkC,EAAE,MAAM,iBAAiB,CAAC;AACrE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AA8CtC;;;GAGG;AACH,MAAM,kBAAkB;IACd,aAAa,CAAyB;IAC7B,UAAU,CAAsB;IAChC,cAAc,GAAG,IAAI,GAAG,EAAU,CAAC;IACnC,cAAc,GAAG,IAAI,GAAG,EAAkB,CAAC;IAC3C,SAAS,GAAmB,EAAE,CAAC;IAEhD,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AM,CAAC,cAAc,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;IAClE,CAAC;IAED;;OAEG;IACH,IAAW,YAAY;QACrB,OAAO,IAAI,CAAC,cAAc,CAAC,YAAY,CAAC;IAC1C,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,wBAAwB;QACnC,OAAO,MAAM,CAAC,cAAc,CAAC,2BAA2B,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACrE,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,iBAAiB;QAC5B,OAAO,IAAI,CAAC,cAAc,CAAC,iBAAiB,EAAE,CAAC;IACjD,CAAC;IAED;;OAEG;IACa,sBAAsB,GAAG,IAAI,OAAO,EAA0C,CAAC;CAChG","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 IModelConnection\r\n */\r\n\r\nimport { assert, BeEvent, CompressedId64Set, Guid, GuidString, Id64Set, Id64String, IModelStatus, OpenMode } from \"@itwin/core-bentley\";\r\nimport {\r\n BriefcaseConnectionProps, ChangesetIndex, ChangesetIndexAndId, getPullChangesIpcChannel, IModelError,\r\n PullChangesOptions as IpcAppPullChangesOptions, LockState, OpenBriefcaseProps, StandaloneOpenOptions,\r\n} from \"@itwin/core-common\";\r\nimport { BriefcaseTxns } from \"./BriefcaseTxns\";\r\nimport { GraphicalEditingScope } from \"./GraphicalEditingScope\";\r\nimport { IModelApp } from \"./IModelApp\";\r\nimport { IModelConnection } from \"./IModelConnection\";\r\nimport { IpcApp } from \"./IpcApp\";\r\nimport { disposeTileTreesForGeometricModels } from \"./tile/internal\";\r\nimport { Viewport } from \"./Viewport\";\r\n\r\n/**\r\n * Download progress information.\r\n * @public\r\n */\r\nexport interface DownloadProgressInfo {\r\n /** Bytes downloaded. */\r\n loaded: number;\r\n /** Total size of the download in bytes. */\r\n total: number;\r\n}\r\n\r\n/**\r\n * Called to show progress during a download.\r\n * @public\r\n */\r\nexport type OnDownloadProgress = (progress: DownloadProgressInfo) => void;\r\n\r\n/**\r\n * Partial interface of AbortSignal.\r\n * @see https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal\r\n * @beta\r\n */\r\nexport interface GenericAbortSignal {\r\n /** Add Listener for abort signal. */\r\n addEventListener: (type: \"abort\", listener: (this: GenericAbortSignal, ev: any) => any) => void;\r\n /** Remove Listener for abort signal. */\r\n removeEventListener: (type: \"abort\", listener: (this: GenericAbortSignal, ev: any) => any) => void;\r\n}\r\n\r\n/**\r\n * Options for pulling iModel changes.\r\n * @public\r\n */\r\nexport interface PullChangesOptions {\r\n /** Function called regularly to report progress of changes download. */\r\n downloadProgressCallback?: OnDownloadProgress;\r\n /** Interval for calling progress callback (in milliseconds). */\r\n progressInterval?: number;\r\n /** Signal for cancelling the download.\r\n * @beta\r\n */\r\n abortSignal?: GenericAbortSignal;\r\n}\r\n\r\n/** Keeps track of changes to models, buffering them until synchronization points.\r\n * While a GraphicalEditingScope is open, the changes are buffered until the scope exits, at which point they are processed.\r\n * Otherwise, the buffered changes are processed after undo/redo, commit, or pull+merge changes.\r\n */\r\nclass ModelChangeMonitor {\r\n private _editingScope?: GraphicalEditingScope;\r\n private readonly _briefcase: BriefcaseConnection;\r\n private readonly _deletedModels = new Set<string>();\r\n private readonly _modelIdToGuid = new Map<string, string>();\r\n private readonly _removals: VoidFunction[] = [];\r\n\r\n public constructor(briefcase: BriefcaseConnection) {\r\n this._briefcase = briefcase;\r\n\r\n // Buffer updated geometry guids.\r\n this._removals.push(briefcase.txns.onModelGeometryChanged.addListener((changes) => {\r\n for (const change of changes) {\r\n this._deletedModels.delete(change.id);\r\n this._modelIdToGuid.set(change.id, change.guid);\r\n }\r\n }));\r\n\r\n // Buffer deletions of models.\r\n this._removals.push(briefcase.txns.onModelsChanged.addListener((changes) => {\r\n if (changes.deleted) {\r\n for (const id of CompressedId64Set.iterable(changes.deleted)) {\r\n this._modelIdToGuid.delete(id);\r\n this._deletedModels.add(id);\r\n }\r\n }\r\n }));\r\n\r\n // Outside of an editing scope, we want to update viewport contents after commit, undo/redo, or merging changes.\r\n const maybeProcess = async () => {\r\n if (this.editingScope)\r\n return;\r\n\r\n const modelIds = Array.from(this._modelIdToGuid.keys());\r\n if (modelIds.length > 0)\r\n await IModelApp.tileAdmin.purgeTileTrees(this._briefcase, modelIds);\r\n\r\n this.processBuffered();\r\n };\r\n\r\n this._removals.push(briefcase.txns.onCommitted.addListener(maybeProcess));\r\n this._removals.push(briefcase.txns.onReplayedExternalTxns.addListener(maybeProcess));\r\n this._removals.push(briefcase.txns.onAfterUndoRedo.addListener(maybeProcess));\r\n this._removals.push(briefcase.txns.onChangesPulled.addListener(maybeProcess));\r\n }\r\n\r\n public async close(): Promise<void> {\r\n for (const removal of this._removals)\r\n removal();\r\n\r\n this._removals.length = 0;\r\n\r\n if (this._editingScope) {\r\n await this._editingScope.exit();\r\n this._editingScope = undefined;\r\n }\r\n }\r\n\r\n public get editingScope(): GraphicalEditingScope | undefined {\r\n return this._editingScope;\r\n }\r\n\r\n public async enterEditingScope(): Promise<GraphicalEditingScope> {\r\n if (this._editingScope)\r\n throw new Error(\"Cannot create an editing scope for an iModel that already has one\");\r\n\r\n this._editingScope = await GraphicalEditingScope.enter(this._briefcase);\r\n\r\n const removeGeomListener = this._editingScope.onGeometryChanges.addListener((changes) => {\r\n const modelIds = [];\r\n for (const change of changes)\r\n modelIds.push(change.id);\r\n\r\n this.invalidateScenes(modelIds);\r\n });\r\n\r\n this._editingScope.onExited.addOnce((scope) => {\r\n assert(scope === this._editingScope);\r\n this._editingScope = undefined;\r\n removeGeomListener();\r\n this.processBuffered();\r\n });\r\n\r\n return this._editingScope;\r\n }\r\n\r\n private processBuffered(): void {\r\n const models = this._briefcase.models;\r\n for (const [id, guid] of this._modelIdToGuid) {\r\n const model = models.getLoaded(id)?.asGeometricModel;\r\n if (model)\r\n model.geometryGuid = guid;\r\n }\r\n\r\n const modelIds = new Set<string>(this._modelIdToGuid.keys());\r\n for (const deleted of this._deletedModels) {\r\n modelIds.add(deleted);\r\n models.unload(deleted);\r\n }\r\n\r\n this.invalidateScenes(modelIds);\r\n disposeTileTreesForGeometricModels(modelIds, this._briefcase);\r\n\r\n this._briefcase.onBufferedModelChanges.raiseEvent(modelIds);\r\n\r\n this._modelIdToGuid.clear();\r\n this._deletedModels.clear();\r\n }\r\n\r\n private invalidateScenes(changedModels: Iterable<Id64String>): void {\r\n for (const user of IModelApp.tileAdmin.tileUsers) {\r\n if (user instanceof Viewport && user.iModel === this._briefcase) {\r\n for (const modelId of changedModels) {\r\n if (user.view.viewsModel(modelId)) {\r\n user.invalidateScene();\r\n user.setFeatureOverrideProviderChanged();\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Provides access to lock information in the iModel.\r\n * @see [[BriefcaseConnection.locks]]\r\n * @alpha\r\n */\r\nexport interface LockService {\r\n /** Get all elements with exclusive locks owned by other briefcases. */\r\n getExclusiveForeignLocks(): Promise<Id64Set>;\r\n /** Get all elements with shared locks owned by other briefcases. */\r\n getSharedForeignLocks(): Promise<Id64Set>;\r\n /** Check whether it's possible to acquire a lock for the element. */\r\n checkElementLockAvailability(elementId: Id64String, lock: LockState): Promise<boolean>;\r\n}\r\n\r\n/** Function for creating a [[LockService]] for a [[BriefcaseConnection]].\r\n * @alpha\r\n */\r\nexport type LockServiceFactory = (iModel: BriefcaseConnection) => Promise<LockService>;\r\n\r\n/** Settings that can be used to control the behavior of [[Tool]]s that modify a [[BriefcaseConnection]].\r\n * For example, tools that want to create new elements can consult the briefcase's editor tool settings to\r\n * determine into which model and category to insert the elements.\r\n * Specialized tools are free to ignore these settings.\r\n * @see [[BriefcaseConnection.editorToolSettings]] to query or modify the current settings for a briefcase.\r\n * @see [CreateElementTool]($editor-frontend) for an example of a tool that uses these settings.\r\n * @beta\r\n */\r\nexport class BriefcaseEditorToolSettings {\r\n private _category?: Id64String;\r\n private _model?: Id64String;\r\n\r\n /** An event raised just after the default [[category]] is changed. */\r\n public readonly onCategoryChanged = new BeEvent<(previousCategory: Id64String | undefined) => void>();\r\n\r\n /** An event raised just after the default [[model]] is changed. */\r\n public readonly onModelChanged = new BeEvent<(previousModel: Id64String | undefined) => void>();\r\n\r\n /** The [Category]($backend) into which new elements should be inserted by default.\r\n * Specialized tools are free to ignore this setting and instead use their own logic to select an appropriate category.\r\n * @see [[onCategoryChanged]] to be notified when this property is modified.\r\n * @see [CreateElementTool.targetCategory]($editor-frontend) for an example of a tool that uses this setting.\r\n */\r\n public get category(): Id64String | undefined {\r\n return this._category;\r\n }\r\n public set category(category: Id64String | undefined) {\r\n const previousCategory = this.category;\r\n if (category !== this.category) {\r\n this._category = category;\r\n this.onCategoryChanged.raiseEvent(previousCategory);\r\n }\r\n }\r\n\r\n /** The [Model]($backend) into which new elements should be inserted by default.\r\n * Specialized tools are free to ignore this setting and instead use their own logic to select an appropriate model.\r\n * @see [[onModelChanged]] to be notified when this property is modified.\r\n * @see [CreateElementTool.targetModelId]($editor-frontend) for an example of a tool that uses this setting.\r\n */\r\n public get model(): Id64String | undefined {\r\n return this._model;\r\n }\r\n public set model(model: Id64String | undefined) {\r\n const previousModel = this.model;\r\n if (model !== this.model) {\r\n this._model = model;\r\n this.onModelChanged.raiseEvent(previousModel);\r\n }\r\n }\r\n}\r\n\r\n/** A connection to an editable briefcase on the backend. This class uses [Ipc]($docs/learning/IpcInterface.md) to communicate\r\n * to the backend and may only be used by [[IpcApp]]s.\r\n * @public\r\n */\r\nexport class BriefcaseConnection extends IModelConnection {\r\n protected _isClosed?: boolean;\r\n private readonly _modelsMonitor: ModelChangeMonitor;\r\n private _locks?: LockService;\r\n\r\n /** The ID of the briefcase.\r\n * @beta\r\n */\r\n public readonly briefcaseId?: number;\r\n\r\n /** Default settings that can be used to control the behavior of [[Tool]]s that modify this briefcase.\r\n * @beta\r\n */\r\n public readonly editorToolSettings = new BriefcaseEditorToolSettings();\r\n\r\n /** Manages local changes to the briefcase via [Txns]($docs/learning/InteractiveEditing.md). */\r\n public readonly txns: BriefcaseTxns;\r\n\r\n /** Information about locks held on this iModel.\r\n * @note This is intended to be used by tools and other UI elements, to provide information about the current lock state. Implementations are expected to cache lock information and so may not reflect changes to locks immediately.\r\n * @alpha\r\n */\r\n public get locks(): LockService | undefined { return this._locks; }\r\n\r\n public override isBriefcaseConnection(): this is BriefcaseConnection { return true; }\r\n\r\n /** The Guid that identifies the iTwin that owns this iModel. */\r\n public override get iTwinId(): GuidString { return super.iTwinId ?? Guid.empty; } // GuidString | undefined for IModelConnection, but required for BriefcaseConnection\r\n\r\n /** The Guid that identifies this iModel. */\r\n public override get iModelId(): GuidString { return super.iModelId ?? Guid.empty; } // GuidString | undefined for IModelConnection, but required for BriefcaseConnection\r\n\r\n protected constructor(props: BriefcaseConnectionProps, openMode: OpenMode) {\r\n super(props);\r\n this._openMode = openMode;\r\n this.briefcaseId = props.briefcaseId;\r\n this.txns = new BriefcaseTxns(this);\r\n this._modelsMonitor = new ModelChangeMonitor(this);\r\n if (OpenMode.ReadWrite === this._openMode)\r\n this.txns.onAfterUndoRedo.addListener(async () => { await IModelApp.toolAdmin.restartPrimitiveTool(); });\r\n\r\n this.categories.cache.attachToBriefcase(this);\r\n }\r\n\r\n /** Open a BriefcaseConnection to a [BriefcaseDb]($backend). */\r\n public static async openFile(briefcaseProps: OpenBriefcaseProps): Promise<BriefcaseConnection>;\r\n\r\n /** Open a BriefcaseConnection to a [BriefcaseDb]($backend).\r\n * @alpha\r\n */\r\n public static async openFile(briefcaseProps: OpenBriefcaseProps, lockServiceFactory?: LockServiceFactory): Promise<BriefcaseConnection>\r\n\r\n public static async openFile(briefcaseProps: OpenBriefcaseProps, lockServiceFactory?: LockServiceFactory): Promise<BriefcaseConnection> {\r\n const iModelProps = await IpcApp.appFunctionIpc.openBriefcase(briefcaseProps);\r\n const connection = new this({ ...briefcaseProps, ...iModelProps }, briefcaseProps.readonly ? OpenMode.Readonly : OpenMode.ReadWrite);\r\n if (lockServiceFactory)\r\n connection._locks = await lockServiceFactory(connection);\r\n\r\n IModelConnection.onOpen.raiseEvent(connection);\r\n return connection;\r\n }\r\n\r\n /** Open a BriefcaseConnection to a [StandaloneDb]($backend)\r\n * @note StandaloneDbs, by definition, may not push or pull changes. Attempting to do so will throw exceptions.\r\n */\r\n public static async openStandalone(filePath: string, openMode: OpenMode = OpenMode.ReadWrite, opts?: StandaloneOpenOptions): Promise<BriefcaseConnection> {\r\n const openResponse = await IpcApp.appFunctionIpc.openStandalone(filePath, openMode, opts);\r\n const connection = new this(openResponse, openMode);\r\n IModelConnection.onOpen.raiseEvent(connection);\r\n return connection;\r\n }\r\n\r\n /** Returns `true` if [[close]] has already been called. */\r\n public get isClosed(): boolean { return this._isClosed === true; }\r\n\r\n /**\r\n * Close this BriefcaseConnection.\r\n * @note make sure to call [[saveChanges]] before calling this method. Unsaved local changes are abandoned.\r\n */\r\n public async close(): Promise<void> {\r\n if (this.isClosed)\r\n return;\r\n\r\n await this._modelsMonitor.close();\r\n\r\n this.beforeClose();\r\n this.txns[Symbol.dispose]();\r\n\r\n this._isClosed = true;\r\n await IpcApp.appFunctionIpc.closeIModel(this._fileKey);\r\n }\r\n\r\n protected requireTimeline() {\r\n if (this.iTwinId === Guid.empty)\r\n throw new IModelError(IModelStatus.WrongIModel, \"iModel has no timeline\");\r\n }\r\n\r\n /** Query if there are any pending Txns in this briefcase that are waiting to be pushed. */\r\n public async hasPendingTxns(): Promise<boolean> { // eslint-disable-line @itwin/prefer-get\r\n return this.txns.hasPendingTxns();\r\n }\r\n\r\n /** Commit pending changes to this briefcase.\r\n * @param description Optional description of the changes.\r\n * @deprecated in 5.9.0 - will not be removed until after 2027-05-04. Use methods on EditCommand instead.\r\n */\r\n public async saveChanges(description?: string): Promise<void> {\r\n await IpcApp.appFunctionIpc.saveChanges(this.key, description); // eslint-disable-line @typescript-eslint/no-deprecated\r\n }\r\n\r\n /** Abandon pending changes to this briefcase.\r\n * @deprecated in 5.9.0 - will not be removed until after 2027-05-04. Use methods on EditCommand instead.\r\n */\r\n public async abandonChanges(): Promise<void> {\r\n await IpcApp.appFunctionIpc.abandonChanges(this.key); // eslint-disable-line @typescript-eslint/no-deprecated\r\n }\r\n\r\n /** Pull (and potentially merge if there are local changes) up to a specified changeset from iModelHub into this briefcase\r\n * @param toIndex The changeset index to pull changes to. If `undefined`, pull all changes.\r\n * @param options Options for pulling changes.\r\n * @see [[BriefcaseTxns.onChangesPulled]] for the event dispatched after changes are pulled.\r\n */\r\n public async pullChanges(toIndex?: ChangesetIndex, options?: PullChangesOptions): Promise<void> {\r\n const removeListeners: VoidFunction[] = [];\r\n const shouldReportProgress = !!options?.downloadProgressCallback;\r\n\r\n if (shouldReportProgress) {\r\n const handleProgress = (_evt: Event, data: { loaded: number, total: number }) => {\r\n options?.downloadProgressCallback?.(data);\r\n };\r\n\r\n const removeProgressListener = IpcApp.addListener(\r\n getPullChangesIpcChannel(this.iModelId),\r\n handleProgress,\r\n );\r\n removeListeners.push(removeProgressListener);\r\n }\r\n\r\n if (options?.abortSignal) {\r\n const abort = () => void IpcApp.appFunctionIpc.cancelPullChangesRequest(this.key);\r\n options?.abortSignal.addEventListener(\"abort\", abort);\r\n removeListeners.push(() => options?.abortSignal?.removeEventListener(\"abort\", abort));\r\n }\r\n\r\n this.requireTimeline();\r\n const ipcAppOptions: IpcAppPullChangesOptions = {\r\n reportProgress: shouldReportProgress,\r\n progressInterval: options?.progressInterval,\r\n enableCancellation: !!options?.abortSignal,\r\n };\r\n try {\r\n this.changeset = await IpcApp.appFunctionIpc.pullChanges(this.key, toIndex, ipcAppOptions);\r\n } finally {\r\n removeListeners.forEach((remove) => remove());\r\n }\r\n }\r\n\r\n /** Create a changeset from local Txns and push to iModelHub. On success, clear Txn table.\r\n * @param description The description for the changeset\r\n * @returns the changesetId of the pushed changes\r\n * @see [[BriefcaseTxns.onChangesPushed]] for the event dispatched after changes are pushed.\r\n */\r\n public async pushChanges(description: string): Promise<ChangesetIndexAndId> {\r\n this.requireTimeline();\r\n return IpcApp.appFunctionIpc.pushChanges(this.key, description);\r\n }\r\n\r\n /** The current graphical editing scope, if one is in progress.\r\n * @see [[enterEditingScope]] to begin graphical editing.\r\n */\r\n public get editingScope(): GraphicalEditingScope | undefined {\r\n return this._modelsMonitor.editingScope;\r\n }\r\n\r\n /** Return whether graphical editing is supported for this briefcase. It is not supported if the briefcase is read-only, or the briefcase contains a version of\r\n * the BisCore ECSchema older than v0.1.11.\r\n * @see [[enterEditingScope]] to enable graphical editing.\r\n */\r\n public async supportsGraphicalEditing(): Promise<boolean> {\r\n return IpcApp.appFunctionIpc.isGraphicalEditingSupported(this.key);\r\n }\r\n\r\n /** Begin a new graphical editing scope.\r\n * @throws Error if an editing scope already exists or one could not be created.\r\n * @see [[GraphicalEditingScope.exit]] to exit the scope.\r\n * @see [[supportsGraphicalEditing]] to determine whether this method should be expected to succeed.\r\n * @see [[editingScope]] to obtain the current editing scope, if one is in progress.\r\n */\r\n public async enterEditingScope(): Promise<GraphicalEditingScope> {\r\n return this._modelsMonitor.enterEditingScope();\r\n }\r\n\r\n /** Strictly for tests - dispatched from ModelChangeMonitor.processBuffered.\r\n * @internal\r\n */\r\n public readonly onBufferedModelChanges = new BeEvent<(changedModelIds: Set<string>) => void>();\r\n}\r\n"]}
@@ -86,7 +86,7 @@ export declare abstract class PrimitiveTool extends InteractiveTool {
86
86
  redoPreviousStep(): Promise<boolean>;
87
87
  /**
88
88
  * If this tool is editing a briefcase, commits any elements that the tool has changed, supplying the tool flyover for the undo description.
89
- * @deprecated in 5.1.9 - will not be removed until after 2027-05-04. Use methods on [[EditCommand]] IPC instead.
89
+ * @deprecated in 5.9.0 - will not be removed until after 2027-05-04. Use methods on [[EditCommand]] IPC instead.
90
90
  */
91
91
  saveChanges(): Promise<void>;
92
92
  }
@@ -166,7 +166,7 @@ export class PrimitiveTool extends InteractiveTool {
166
166
  }
167
167
  /**
168
168
  * If this tool is editing a briefcase, commits any elements that the tool has changed, supplying the tool flyover for the undo description.
169
- * @deprecated in 5.1.9 - will not be removed until after 2027-05-04. Use methods on [[EditCommand]] IPC instead.
169
+ * @deprecated in 5.9.0 - will not be removed until after 2027-05-04. Use methods on [[EditCommand]] IPC instead.
170
170
  */
171
171
  async saveChanges() {
172
172
  if (this.iModel.isBriefcaseConnection())
@@ -1 +1 @@
1
- {"version":3,"file":"PrimitiveTool.js","sourceRoot":"","sources":["../../../src/tools/PrimitiveTool.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAErF,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAiB,uBAAuB,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAEtG;;;;GAIG;AACH,MAAM,OAAgB,aAAc,SAAQ,eAAe;IACzD;;OAEG;IACI,UAAU,CAAY;IACrB,cAAc,CAAU;IAChC,IAAW,aAAa,KAAK,OAAO,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC;IAC1D,IAAW,aAAa,CAAC,CAAqB,IAAI,IAAI,CAAC,cAAc,GAAG,CAAC,CAAC,CAAC,CAAC;IACrE,cAAc,GAAY,KAAK,CAAC,CAAC,yFAAyF;IAEjI;;OAEG;IACH,IAAW,MAAM;QACf,MAAM,CAAC,SAAS,KAAK,IAAI,CAAC,UAAU,CAAC,CAAC;QACtC,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC;IACrC,CAAC;IAED,sIAAsI;IACtI,IAAW,SAAS;QA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O,KAAK,CAAC,CAAC,CAAC;IAErE,gBAAgB;IACT,KAAK,CAAC,gBAAgB;QAC3B,IAAI,CAAC,MAAM,IAAI,CAAC,kBAAkB,EAAE;YAClC,OAAO,KAAK,CAAC;QAEf,iBAAiB,CAAC,mBAAmB,EAAE,CAAC,CAAC,iFAAiF;QAC1H,SAAS,CAAC,WAAW,CAAC,6BAA6B,EAAE,CAAC;QACtD,SAAS,CAAC,SAAS,CAAC,cAAc,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,8CAA8C;QAE9G,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,kBAAkB,KAAuB,OAAO,KAAK,CAAC,CAAC,CAAC;IAErE,gBAAgB;IACT,KAAK,CAAC,gBAAgB;QAC3B,IAAI,CAAC,MAAM,IAAI,CAAC,kBAAkB,EAAE;YAClC,OAAO,KAAK,CAAC;QAEf,iBAAiB,CAAC,mBAAmB,EAAE,CAAC,CAAC,iFAAiF;QAC1H,SAAS,CAAC,WAAW,CAAC,6BAA6B,EAAE,CAAC;QACtD,SAAS,CAAC,SAAS,CAAC,cAAc,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,8CAA8C;QAE9G,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,WAAW;QACtB,IAAI,IAAI,CAAC,MAAM,CAAC,qBAAqB,EAAE;YACrC,OAAO,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,uDAAuD;IACzG,CAAC;CACF","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 Tools\r\n */\r\n\r\nimport { assert } from \"@itwin/core-bentley\";\r\nimport { BriefcaseConnection } from \"../BriefcaseConnection\";\r\nimport { IModelApp } from \"../IModelApp\";\r\nimport { IModelConnection } from \"../IModelConnection\";\r\nimport { NotifyMessageDetails, OutputMessagePriority } from \"../NotificationManager\";\r\nimport { Viewport } from \"../Viewport\";\r\nimport { AccuDrawShortcuts } from \"./AccuDrawTool\";\r\nimport { BeButton, BeButtonEvent, CoordinateLockOverrides, CoreTools, InteractiveTool } from \"./Tool\";\r\n\r\n/** The PrimitiveTool class can be used to implement tools to create or modify geometric elements.\r\n * @see [Writing a PrimitiveTool]($docs/learning/frontend/primitivetools.md)\r\n * @public\r\n * @extensions\r\n */\r\nexport abstract class PrimitiveTool extends InteractiveTool {\r\n /** The viewport within which the tool operates.\r\n * @note This property is only initialized if [[run]] returns `true`, causing the tool to be installed.\r\n */\r\n public targetView?: Viewport;\r\n private _targetModelId?: string;\r\n public get targetModelId() { return this._targetModelId; }\r\n public set targetModelId(v: string | undefined) { this._targetModelId = v; }\r\n public targetIsLocked: boolean = false; // If target model is known, set this to true in constructor and override getTargetModel.\r\n\r\n /** Get the iModel on which this tool operates.\r\n * @note The iModel is obtained from [[targetView]], so should only be invoked if the tool installed successfully.\r\n */\r\n public get iModel(): IModelConnection {\r\n assert(undefined !== this.targetView);\r\n return this.targetView.view.iModel;\r\n }\r\n\r\n /** Get the briefcase on which this tool operates, if the tool has successfully installed and the target [[iModel]] is a briefcase. */\r\n public get briefcase(): BriefcaseConnection | undefined {\r\n const iModel = this.targetView?.view.iModel;\r\n return iModel?.isBriefcaseConnection() ? iModel : undefined;\r\n }\r\n\r\n /**\r\n * Establish this tool as the active PrimitiveTool.\r\n * @return true if this tool was installed (though it may have exited too)\r\n * @note If you override this method you **must** call `super.run` and return false if it returns false.\r\n */\r\n public override async run(..._args: any[]): Promise<boolean> {\r\n const { toolAdmin, viewManager } = IModelApp;\r\n if (!this.isCompatibleViewport(viewManager.selectedView, false))\r\n return false;\r\n\r\n if (!await toolAdmin.onInstallTool(this))\r\n return false;\r\n\r\n await toolAdmin.startPrimitiveTool(this);\r\n // If another tool was installed at the same time (due to concurrent run calls),\r\n // the last start to complete wins. Detect that situation and return false.\r\n if (toolAdmin.primitiveTool !== this)\r\n return false;\r\n\r\n await toolAdmin.onPostInstallTool(this);\r\n return true;\r\n }\r\n\r\n /** Determine whether the supplied Viewport is compatible with this tool.\r\n * @param vp the Viewport to check\r\n */\r\n public override isCompatibleViewport(vp: Viewport | undefined, isSelectedViewChange: boolean): boolean {\r\n if (undefined === vp)\r\n return false; // No views are open...\r\n\r\n const view = vp.view;\r\n const iModel = view.iModel;\r\n\r\n if (this.requireWriteableTarget() && iModel.isReadonly)\r\n return false; // this Tool can't be used when iModel is read only.\r\n\r\n if (undefined === this.targetView || (!this.targetIsLocked && isSelectedViewChange))\r\n this.targetView = vp; // Update target to new view if undefined or still free to change.\r\n\r\n if (undefined === this.targetModelId && (!this.targetIsLocked || vp === this.targetView))\r\n return true; // Accept if this view is current target or any type of model/view is still ok as target is still free to change.\r\n\r\n if (iModel !== this.iModel)\r\n return false; // Once a ViewState has been established, only accept viewport showing the same iModel.\r\n\r\n if (this.targetModelId)\r\n return view.viewsModel(this.targetModelId); // If a specific target model is specified, only allow view that shows it.\r\n\r\n if (view.isSpatialView() && this.targetView.view.isSpatialView())\r\n return true; // No specific target, two spatial views are considered compatible.\r\n\r\n let allowView = false;\r\n const targetView = this.targetView;\r\n view.forEachModel((model) => {\r\n if (!allowView && targetView.view.viewsModel(model.id))\r\n allowView = true;\r\n });\r\n\r\n return allowView; // Accept if this view shares a model in common with target.\r\n }\r\n\r\n /**\r\n * Checks that the adjusted point from the supplied button event is within the project extents for spatial views. The range of physical geometry\r\n * should always be fully inside the project extents. Only checking the adjusted point won't absolutely guarantee that a tool doesn't create/move geometry\r\n * outside the project extents, but it will be sufficient to handle most cases and provide good feedback to the user.\r\n * @return true if ev is acceptable.\r\n */\r\n public override isValidLocation(ev: BeButtonEvent, isButtonEvent: boolean): boolean {\r\n const vp = ev.viewport;\r\n if (undefined === vp)\r\n return false;\r\n\r\n if (isButtonEvent && BeButton.Data !== ev.button)\r\n return true;\r\n\r\n const view = vp.view;\r\n if (!view.isSpatialView())\r\n return true;\r\n\r\n // NOTE: If points aren't being adjusted then the tool shouldn't be creating geometry currently (ex. locating elements) and we shouldn't filter point...\r\n if (0 !== (IModelApp.toolAdmin.toolState.coordLockOvr & CoordinateLockOverrides.ACS))\r\n return true;\r\n\r\n // We know the tool isn't doing a locate, we don't know what it will do with this point. Minimize erroneous filtering by restricting the check to when AccuSnap is tool enable (not user enabled)...\r\n if (!IModelApp.accuSnap.isSnapEnabled)\r\n return true;\r\n\r\n const extents = view.iModel.projectExtents;\r\n if (extents.containsPoint(ev.point))\r\n return true;\r\n\r\n if (isButtonEvent && ev.isDown)\r\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Error, CoreTools.translate(\"ElementSet.Error.ProjectExtents\")));\r\n\r\n return false;\r\n }\r\n\r\n /** Called on data button down event to lock the tool to its current target model. */\r\n public autoLockTarget(): void {\r\n if (undefined === this.targetView)\r\n return;\r\n\r\n this.targetIsLocked = true;\r\n }\r\n\r\n /** Returns the prompt based on the tool's current state. */\r\n public getPrompt(): string { return \"\"; }\r\n\r\n /** Called from isCompatibleViewport to check for a read only iModel, which is not a valid target for tools that create or modify elements. */\r\n public requireWriteableTarget(): boolean { return true; }\r\n\r\n /**\r\n * Called when active view changes. Tool may choose to restart or exit based on current view type.\r\n * @param _previous The previously active view.\r\n * @param current The new active view.\r\n */\r\n public override async onSelectedViewportChanged(_previous: Viewport | undefined, current: Viewport | undefined): Promise<void> {\r\n if (this.isCompatibleViewport(current, true))\r\n return;\r\n return this.onRestartTool();\r\n }\r\n\r\n /**\r\n * Called when an external event may invalidate the current tool's state.\r\n * Examples are undo, which may invalidate any references to elements, or an incompatible active view change.\r\n * The active tool is expected to call installTool with a new instance, or exitTool to start the default tool.\r\n * ```ts\r\n * const tool = new MyPrimitiveTool();\r\n * if (!await tool.run())\r\n * return this.exitTool(); // Don't leave current instance active if new instance rejects install...\r\n * ```\r\n */\r\n public abstract onRestartTool(): Promise<void>;\r\n\r\n /**\r\n * Called to reset tool to initial state. PrimitiveTool implements this method to call onRestartTool.\r\n */\r\n public override async onReinitialize(): Promise<void> { return this.onRestartTool(); }\r\n\r\n public async exitTool() { return IModelApp.toolAdmin.startDefaultTool(); }\r\n\r\n /**\r\n * Called to reverse to a previous tool state (ex. undo last data button).\r\n * @return false to instead reverse the most recent transaction.\r\n */\r\n public async onUndoPreviousStep(): Promise<boolean> { return false; }\r\n\r\n /** @internal */\r\n public async undoPreviousStep(): Promise<boolean> {\r\n if (!await this.onUndoPreviousStep())\r\n return false;\r\n\r\n AccuDrawShortcuts.processPendingHints(); // Process pending hints from onUndoPreviousStep before calling updateDynamics...\r\n IModelApp.viewManager.invalidateDecorationsAllViews();\r\n IModelApp.toolAdmin.updateDynamics(undefined, undefined, true); // Don't wait for motion to update dynamics...\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Called to reinstate to a previous tool state (ex. redo last data button).\r\n * @return false to instead reinstate the most recent transaction.\r\n */\r\n public async onRedoPreviousStep(): Promise<boolean> { return false; }\r\n\r\n /** @internal */\r\n public async redoPreviousStep(): Promise<boolean> {\r\n if (!await this.onRedoPreviousStep())\r\n return false;\r\n\r\n AccuDrawShortcuts.processPendingHints(); // Process pending hints from onRedoPreviousStep before calling updateDynamics...\r\n IModelApp.viewManager.invalidateDecorationsAllViews();\r\n IModelApp.toolAdmin.updateDynamics(undefined, undefined, true); // Don't wait for motion to update dynamics...\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * If this tool is editing a briefcase, commits any elements that the tool has changed, supplying the tool flyover for the undo description.\r\n * @deprecated in 5.1.9 - will not be removed until after 2027-05-04. Use methods on [[EditCommand]] IPC instead.\r\n */\r\n public async saveChanges(): Promise<void> {\r\n if (this.iModel.isBriefcaseConnection())\r\n return this.iModel.saveChanges(this.flyover); // eslint-disable-line @typescript-eslint/no-depr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CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,8CAA8C;QAE9G,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,kBAAkB,KAAuB,OAAO,KAAK,CAAC,CAAC,CAAC;IAErE,gBAAgB;IACT,KAAK,CAAC,gBAAgB;QAC3B,IAAI,CAAC,MAAM,IAAI,CAAC,kBAAkB,EAAE;YAClC,OAAO,KAAK,CAAC;QAEf,iBAAiB,CAAC,mBAAmB,EAAE,CAAC,CAAC,iFAAiF;QAC1H,SAAS,CAAC,WAAW,CAAC,6BAA6B,EAAE,CAAC;QACtD,SAAS,CAAC,SAAS,CAAC,cAAc,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,8CAA8C;QAE9G,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,WAAW;QACtB,IAAI,IAAI,CAAC,MAAM,CAAC,qBAAqB,EAAE;YACrC,OAAO,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,uDAAuD;IACzG,CAAC;CACF","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 Tools\r\n */\r\n\r\nimport { assert } from \"@itwin/core-bentley\";\r\nimport { BriefcaseConnection } from \"../BriefcaseConnection\";\r\nimport { IModelApp } from \"../IModelApp\";\r\nimport { IModelConnection } from \"../IModelConnection\";\r\nimport { NotifyMessageDetails, OutputMessagePriority } from \"../NotificationManager\";\r\nimport { Viewport } from \"../Viewport\";\r\nimport { AccuDrawShortcuts } from \"./AccuDrawTool\";\r\nimport { BeButton, BeButtonEvent, CoordinateLockOverrides, CoreTools, InteractiveTool } from \"./Tool\";\r\n\r\n/** The PrimitiveTool class can be used to implement tools to create or modify geometric elements.\r\n * @see [Writing a PrimitiveTool]($docs/learning/frontend/primitivetools.md)\r\n * @public\r\n * @extensions\r\n */\r\nexport abstract class PrimitiveTool extends InteractiveTool {\r\n /** The viewport within which the tool operates.\r\n * @note This property is only initialized if [[run]] returns `true`, causing the tool to be installed.\r\n */\r\n public targetView?: Viewport;\r\n private _targetModelId?: string;\r\n public get targetModelId() { return this._targetModelId; }\r\n public set targetModelId(v: string | undefined) { this._targetModelId = v; }\r\n public targetIsLocked: boolean = false; // If target model is known, set this to true in constructor and override getTargetModel.\r\n\r\n /** Get the iModel on which this tool operates.\r\n * @note The iModel is obtained from [[targetView]], so should only be invoked if the tool installed successfully.\r\n */\r\n public get iModel(): IModelConnection {\r\n assert(undefined !== this.targetView);\r\n return this.targetView.view.iModel;\r\n }\r\n\r\n /** Get the briefcase on which this tool operates, if the tool has successfully installed and the target [[iModel]] is a briefcase. */\r\n public get briefcase(): BriefcaseConnection | undefined {\r\n const iModel = this.targetView?.view.iModel;\r\n return iModel?.isBriefcaseConnection() ? iModel : undefined;\r\n }\r\n\r\n /**\r\n * Establish this tool as the active PrimitiveTool.\r\n * @return true if this tool was installed (though it may have exited too)\r\n * @note If you override this method you **must** call `super.run` and return false if it returns false.\r\n */\r\n public override async run(..._args: any[]): Promise<boolean> {\r\n const { toolAdmin, viewManager } = IModelApp;\r\n if (!this.isCompatibleViewport(viewManager.selectedView, false))\r\n return false;\r\n\r\n if (!await toolAdmin.onInstallTool(this))\r\n return false;\r\n\r\n await toolAdmin.startPrimitiveTool(this);\r\n // If another tool was installed at the same time (due to concurrent run calls),\r\n // the last start to complete wins. Detect that situation and return false.\r\n if (toolAdmin.primitiveTool !== this)\r\n return false;\r\n\r\n await toolAdmin.onPostInstallTool(this);\r\n return true;\r\n }\r\n\r\n /** Determine whether the supplied Viewport is compatible with this tool.\r\n * @param vp the Viewport to check\r\n */\r\n public override isCompatibleViewport(vp: Viewport | undefined, isSelectedViewChange: boolean): boolean {\r\n if (undefined === vp)\r\n return false; // No views are open...\r\n\r\n const view = vp.view;\r\n const iModel = view.iModel;\r\n\r\n if (this.requireWriteableTarget() && iModel.isReadonly)\r\n return false; // this Tool can't be used when iModel is read only.\r\n\r\n if (undefined === this.targetView || (!this.targetIsLocked && isSelectedViewChange))\r\n this.targetView = vp; // Update target to new view if undefined or still free to change.\r\n\r\n if (undefined === this.targetModelId && (!this.targetIsLocked || vp === this.targetView))\r\n return true; // Accept if this view is current target or any type of model/view is still ok as target is still free to change.\r\n\r\n if (iModel !== this.iModel)\r\n return false; // Once a ViewState has been established, only accept viewport showing the same iModel.\r\n\r\n if (this.targetModelId)\r\n return view.viewsModel(this.targetModelId); // If a specific target model is specified, only allow view that shows it.\r\n\r\n if (view.isSpatialView() && this.targetView.view.isSpatialView())\r\n return true; // No specific target, two spatial views are considered compatible.\r\n\r\n let allowView = false;\r\n const targetView = this.targetView;\r\n view.forEachModel((model) => {\r\n if (!allowView && targetView.view.viewsModel(model.id))\r\n allowView = true;\r\n });\r\n\r\n return allowView; // Accept if this view shares a model in common with target.\r\n }\r\n\r\n /**\r\n * Checks that the adjusted point from the supplied button event is within the project extents for spatial views. The range of physical geometry\r\n * should always be fully inside the project extents. Only checking the adjusted point won't absolutely guarantee that a tool doesn't create/move geometry\r\n * outside the project extents, but it will be sufficient to handle most cases and provide good feedback to the user.\r\n * @return true if ev is acceptable.\r\n */\r\n public override isValidLocation(ev: BeButtonEvent, isButtonEvent: boolean): boolean {\r\n const vp = ev.viewport;\r\n if (undefined === vp)\r\n return false;\r\n\r\n if (isButtonEvent && BeButton.Data !== ev.button)\r\n return true;\r\n\r\n const view = vp.view;\r\n if (!view.isSpatialView())\r\n return true;\r\n\r\n // NOTE: If points aren't being adjusted then the tool shouldn't be creating geometry currently (ex. locating elements) and we shouldn't filter point...\r\n if (0 !== (IModelApp.toolAdmin.toolState.coordLockOvr & CoordinateLockOverrides.ACS))\r\n return true;\r\n\r\n // We know the tool isn't doing a locate, we don't know what it will do with this point. Minimize erroneous filtering by restricting the check to when AccuSnap is tool enable (not user enabled)...\r\n if (!IModelApp.accuSnap.isSnapEnabled)\r\n return true;\r\n\r\n const extents = view.iModel.projectExtents;\r\n if (extents.containsPoint(ev.point))\r\n return true;\r\n\r\n if (isButtonEvent && ev.isDown)\r\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Error, CoreTools.translate(\"ElementSet.Error.ProjectExtents\")));\r\n\r\n return false;\r\n }\r\n\r\n /** Called on data button down event to lock the tool to its current target model. */\r\n public autoLockTarget(): void {\r\n if (undefined === this.targetView)\r\n return;\r\n\r\n this.targetIsLocked = true;\r\n }\r\n\r\n /** Returns the prompt based on the tool's current state. */\r\n public getPrompt(): string { return \"\"; }\r\n\r\n /** Called from isCompatibleViewport to check for a read only iModel, which is not a valid target for tools that create or modify elements. */\r\n public requireWriteableTarget(): boolean { return true; }\r\n\r\n /**\r\n * Called when active view changes. Tool may choose to restart or exit based on current view type.\r\n * @param _previous The previously active view.\r\n * @param current The new active view.\r\n */\r\n public override async onSelectedViewportChanged(_previous: Viewport | undefined, current: Viewport | undefined): Promise<void> {\r\n if (this.isCompatibleViewport(current, true))\r\n return;\r\n return this.onRestartTool();\r\n }\r\n\r\n /**\r\n * Called when an external event may invalidate the current tool's state.\r\n * Examples are undo, which may invalidate any references to elements, or an incompatible active view change.\r\n * The active tool is expected to call installTool with a new instance, or exitTool to start the default tool.\r\n * ```ts\r\n * const tool = new MyPrimitiveTool();\r\n * if (!await tool.run())\r\n * return this.exitTool(); // Don't leave current instance active if new instance rejects install...\r\n * ```\r\n */\r\n public abstract onRestartTool(): Promise<void>;\r\n\r\n /**\r\n * Called to reset tool to initial state. PrimitiveTool implements this method to call onRestartTool.\r\n */\r\n public override async onReinitialize(): Promise<void> { return this.onRestartTool(); }\r\n\r\n public async exitTool() { return IModelApp.toolAdmin.startDefaultTool(); }\r\n\r\n /**\r\n * Called to reverse to a previous tool state (ex. undo last data button).\r\n * @return false to instead reverse the most recent transaction.\r\n */\r\n public async onUndoPreviousStep(): Promise<boolean> { return false; }\r\n\r\n /** @internal */\r\n public async undoPreviousStep(): Promise<boolean> {\r\n if (!await this.onUndoPreviousStep())\r\n return false;\r\n\r\n AccuDrawShortcuts.processPendingHints(); // Process pending hints from onUndoPreviousStep before calling updateDynamics...\r\n IModelApp.viewManager.invalidateDecorationsAllViews();\r\n IModelApp.toolAdmin.updateDynamics(undefined, undefined, true); // Don't wait for motion to update dynamics...\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Called to reinstate to a previous tool state (ex. redo last data button).\r\n * @return false to instead reinstate the most recent transaction.\r\n */\r\n public async onRedoPreviousStep(): Promise<boolean> { return false; }\r\n\r\n /** @internal */\r\n public async redoPreviousStep(): Promise<boolean> {\r\n if (!await this.onRedoPreviousStep())\r\n return false;\r\n\r\n AccuDrawShortcuts.processPendingHints(); // Process pending hints from onRedoPreviousStep before calling updateDynamics...\r\n IModelApp.viewManager.invalidateDecorationsAllViews();\r\n IModelApp.toolAdmin.updateDynamics(undefined, undefined, true); // Don't wait for motion to update dynamics...\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * If this tool is editing a briefcase, commits any elements that the tool has changed, supplying the tool flyover for the undo description.\r\n * @deprecated in 5.9.0 - will not be removed until after 2027-05-04. Use methods on [[EditCommand]] IPC instead.\r\n */\r\n public async saveChanges(): Promise<void> {\r\n if (this.iModel.isBriefcaseConnection())\r\n return this.iModel.saveChanges(this.flyover); // eslint-disable-line @typescript-eslint/no-deprecated\r\n }\r\n}\r\n"]}