@itwin/core-frontend 5.4.0-dev.5 → 5.4.0-dev.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,6 +1,26 @@
1
1
  # Change Log - @itwin/core-frontend
2
2
 
3
- This log was last generated on Fri, 24 Oct 2025 16:22:31 GMT and should not be manually modified.
3
+ This log was last generated on Thu, 06 Nov 2025 20:30:21 GMT and should not be manually modified.
4
+
5
+ ## 5.3.1
6
+ Thu, 06 Nov 2025 20:29:06 GMT
7
+
8
+ ### Updates
9
+
10
+ - Update frontend cache when the backend modifies categories and subcategories.
11
+
12
+ ## 5.3.0
13
+ Mon, 03 Nov 2025 19:02:35 GMT
14
+
15
+ ### Updates
16
+
17
+ - Added custom `portal` property for ArcGIS map-layers, to support OAuth2 authentication.
18
+ - Added `MapLayerImageryProvider.status` API.
19
+ - Add range validation for WMS maplayers
20
+ - Fix unsafe-inline CSP violation
21
+ - Ensure viewport contents update when the view's category selector changes.
22
+ - Remove beta support for reading contour line information from the GPU.
23
+ - Increase logo card width in attribution popup to fix Google Maps image clipping
4
24
 
5
25
  ## 5.2.4
6
26
  Fri, 24 Oct 2025 16:20:38 GMT
@@ -1 +1 @@
1
- {"version":3,"file":"BriefcaseConnection.d.ts","sourceRoot":"","sources":["../../src/BriefcaseConnection.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAU,OAAO,EAA2B,UAAU,EAAE,UAAU,EAAgB,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/H,OAAO,EACL,cAAc,EAAE,mBAAmB,EAA4B,qBAAqB,EACpC,kBAAkB,EAAE,qBAAqB,EAC1F,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBA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193,7 @@ class BriefcaseConnection extends IModelConnection_1.IModelConnection {
193
193
  this._modelsMonitor = new ModelChangeMonitor(this);
194
194
  if (core_bentley_1.OpenMode.ReadWrite === this._openMode)
195
195
  this.txns.onAfterUndoRedo.addListener(async () => { await IModelApp_1.IModelApp.toolAdmin.restartPrimitiveTool(); });
196
+ this.categories.cache.attachToBriefcase(this);
196
197
  }
197
198
  /** Open a BriefcaseConnection to a [BriefcaseDb]($backend). */
198
199
  static async openFile(briefcaseProps) {
@@ -1 +1 @@
1
- {"version":3,"file":"BriefcaseConnection.js","sourceRoot":"","sources":["../../src/BriefcaseConnection.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA+H;AAC/H,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,8BAA8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B,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;AAvKD,kDAuKC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module IModelConnection\n */\n\nimport { assert, BeEvent, CompressedId64Set, Guid, GuidString, Id64String, IModelStatus, OpenMode } from \"@itwin/core-bentley\";\nimport {\n ChangesetIndex, ChangesetIndexAndId, getPullChangesIpcChannel, IModelConnectionProps, IModelError,\n PullChangesOptions as IpcAppPullChangesOptions, OpenBriefcaseProps, StandaloneOpenOptions,\n} from \"@itwin/core-common\";\nimport { BriefcaseTxns } from \"./BriefcaseTxns\";\nimport { GraphicalEditingScope } from \"./GraphicalEditingScope\";\nimport { IModelApp } from \"./IModelApp\";\nimport { IModelConnection } from \"./IModelConnection\";\nimport { IpcApp } from \"./IpcApp\";\nimport { disposeTileTreesForGeometricModels } from \"./tile/internal\";\nimport { Viewport } from \"./Viewport\";\n\n/**\n * Download progress information.\n * @public\n */\nexport interface DownloadProgressInfo {\n /** Bytes downloaded. */\n loaded: number;\n /** Total size of the download in bytes. */\n total: number;\n}\n\n/**\n * Called to show progress during a download.\n * @public\n */\nexport type OnDownloadProgress = (progress: DownloadProgressInfo) => void;\n\n/**\n * Partial interface of AbortSignal.\n * @see https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal\n * @beta\n */\nexport interface GenericAbortSignal {\n /** Add Listener for abort signal. */\n addEventListener: (type: \"abort\", listener: (this: GenericAbortSignal, ev: any) => any) => void;\n /** Remove Listener for abort signal. */\n removeEventListener: (type: \"abort\", listener: (this: GenericAbortSignal, ev: any) => any) => void;\n}\n\n/**\n * Options for pulling iModel changes.\n * @public\n */\nexport interface PullChangesOptions {\n /** Function called regularly to report progress of changes download. */\n downloadProgressCallback?: OnDownloadProgress;\n /** Interval for calling progress callback (in milliseconds). */\n progressInterval?: number;\n /** Signal for cancelling the download.\n * @beta\n */\n abortSignal?: GenericAbortSignal;\n}\n\n/** Keeps track of changes to models, buffering them until synchronization points.\n * While a GraphicalEditingScope is open, the changes are buffered until the scope exits, at which point they are processed.\n * Otherwise, the buffered changes are processed after undo/redo, commit, or pull+merge changes.\n */\nclass ModelChangeMonitor {\n private _editingScope?: GraphicalEditingScope;\n private readonly _briefcase: BriefcaseConnection;\n private readonly _deletedModels = new Set<string>();\n private readonly _modelIdToGuid = new Map<string, string>();\n private readonly _removals: VoidFunction[] = [];\n\n public constructor(briefcase: BriefcaseConnection) {\n this._briefcase = briefcase;\n\n // Buffer updated geometry guids.\n this._removals.push(briefcase.txns.onModelGeometryChanged.addListener((changes) => {\n for (const change of changes) {\n this._deletedModels.delete(change.id);\n this._modelIdToGuid.set(change.id, change.guid);\n }\n }));\n\n // Buffer deletions of models.\n this._removals.push(briefcase.txns.onModelsChanged.addListener((changes) => {\n if (changes.deleted) {\n for (const id of CompressedId64Set.iterable(changes.deleted)) {\n this._modelIdToGuid.delete(id);\n this._deletedModels.add(id);\n }\n }\n }));\n\n // Outside of an editing scope, we want to update viewport contents after commit, undo/redo, or merging changes.\n const maybeProcess = async () => {\n if (this.editingScope)\n return;\n\n const modelIds = Array.from(this._modelIdToGuid.keys());\n if (modelIds.length > 0)\n await IModelApp.tileAdmin.purgeTileTrees(this._briefcase, modelIds);\n\n this.processBuffered();\n };\n\n this._removals.push(briefcase.txns.onCommitted.addListener(maybeProcess));\n this._removals.push(briefcase.txns.onReplayedExternalTxns.addListener(maybeProcess));\n this._removals.push(briefcase.txns.onAfterUndoRedo.addListener(maybeProcess));\n this._removals.push(briefcase.txns.onChangesPulled.addListener(maybeProcess));\n }\n\n public async close(): Promise<void> {\n for (const removal of this._removals)\n removal();\n\n this._removals.length = 0;\n\n if (this._editingScope) {\n await this._editingScope.exit();\n this._editingScope = undefined;\n }\n }\n\n public get editingScope(): GraphicalEditingScope | undefined {\n return this._editingScope;\n }\n\n public async enterEditingScope(): Promise<GraphicalEditingScope> {\n if (this._editingScope)\n throw new Error(\"Cannot create an editing scope for an iModel that already has one\");\n\n this._editingScope = await GraphicalEditingScope.enter(this._briefcase);\n\n const removeGeomListener = this._editingScope.onGeometryChanges.addListener((changes) => {\n const modelIds = [];\n for (const change of changes)\n modelIds.push(change.id);\n\n this.invalidateScenes(modelIds);\n });\n\n this._editingScope.onExited.addOnce((scope) => {\n assert(scope === this._editingScope);\n this._editingScope = undefined;\n removeGeomListener();\n this.processBuffered();\n });\n\n return this._editingScope;\n }\n\n private processBuffered(): void {\n const models = this._briefcase.models;\n for (const [id, guid] of this._modelIdToGuid) {\n const model = models.getLoaded(id)?.asGeometricModel;\n if (model)\n model.geometryGuid = guid;\n }\n\n const modelIds = new Set<string>(this._modelIdToGuid.keys());\n for (const deleted of this._deletedModels) {\n modelIds.add(deleted);\n models.unload(deleted);\n }\n\n this.invalidateScenes(modelIds);\n disposeTileTreesForGeometricModels(modelIds, this._briefcase);\n\n this._briefcase.onBufferedModelChanges.raiseEvent(modelIds);\n\n this._modelIdToGuid.clear();\n this._deletedModels.clear();\n }\n\n private invalidateScenes(changedModels: Iterable<Id64String>): void {\n for (const user of IModelApp.tileAdmin.tileUsers) {\n if (user instanceof Viewport && user.iModel === this._briefcase) {\n for (const modelId of changedModels) {\n if (user.view.viewsModel(modelId)) {\n user.invalidateScene();\n user.setFeatureOverrideProviderChanged();\n break;\n }\n }\n }\n }\n }\n}\n\n/** Settings that can be used to control the behavior of [[Tool]]s that modify a [[BriefcaseConnection]].\n * For example, tools that want to create new elements can consult the briefcase's editor tool settings to\n * determine into which model and category to insert the elements.\n * Specialized tools are free to ignore these settings.\n * @see [[BriefcaseConnection.editorToolSettings]] to query or modify the current settings for a briefcase.\n * @see [CreateElementTool]($editor-frontend) for an example of a tool that uses these settings.\n * @beta\n */\nexport class BriefcaseEditorToolSettings {\n private _category?: Id64String;\n private _model?: Id64String;\n\n /** An event raised just after the default [[category]] is changed. */\n public readonly onCategoryChanged = new BeEvent<(previousCategory: Id64String | undefined) => void>();\n\n /** An event raised just after the default [[model]] is changed. */\n public readonly onModelChanged = new BeEvent<(previousModel: Id64String | undefined) => void>();\n\n /** The [Category]($backend) into which new elements should be inserted by default.\n * Specialized tools are free to ignore this setting and instead use their own logic to select an appropriate category.\n * @see [[onCategoryChanged]] to be notified when this property is modified.\n * @see [CreateElementTool.targetCategory]($editor-frontend) for an example of a tool that uses this setting.\n */\n public get category(): Id64String | undefined {\n return this._category;\n }\n public set category(category: Id64String | undefined) {\n const previousCategory = this.category;\n if (category !== this.category) {\n this._category = category;\n this.onCategoryChanged.raiseEvent(previousCategory);\n }\n }\n\n /** The [Model]($backend) into which new elements should be inserted by default.\n * Specialized tools are free to ignore this setting and instead use their own logic to select an appropriate model.\n * @see [[onModelChanged]] to be notified when this property is modified.\n * @see [CreateElementTool.targetModelId]($editor-frontend) for an example of a tool that uses this setting.\n */\n public get model(): Id64String | undefined {\n return this._model;\n }\n public set model(model: Id64String | undefined) {\n const previousModel = this.model;\n if (model !== this.model) {\n this._model = model;\n this.onModelChanged.raiseEvent(previousModel);\n }\n }\n}\n\n/** A connection to an editable briefcase on the backend. This class uses [Ipc]($docs/learning/IpcInterface.md) to communicate\n * to the backend and may only be used by [[IpcApp]]s.\n * @public\n */\nexport class BriefcaseConnection extends IModelConnection {\n protected _isClosed?: boolean;\n private readonly _modelsMonitor: ModelChangeMonitor;\n /** Default settings that can be used to control the behavior of [[Tool]]s that modify this briefcase.\n * @beta\n */\n public readonly editorToolSettings = new BriefcaseEditorToolSettings();\n\n /** Manages local changes to the briefcase via [Txns]($docs/learning/InteractiveEditing.md). */\n public readonly txns: BriefcaseTxns;\n\n public override isBriefcaseConnection(): this is BriefcaseConnection { return true; }\n\n /** The Guid that identifies the iTwin that owns this iModel. */\n public override get iTwinId(): GuidString { return super.iTwinId ?? Guid.empty; } // GuidString | undefined for IModelConnection, but required for BriefcaseConnection\n\n /** The Guid that identifies this iModel. */\n public override get iModelId(): GuidString { return super.iModelId ?? Guid.empty; } // GuidString | undefined for IModelConnection, but required for BriefcaseConnection\n\n protected constructor(props: IModelConnectionProps, openMode: OpenMode) {\n super(props);\n this._openMode = openMode;\n this.txns = new BriefcaseTxns(this);\n this._modelsMonitor = new ModelChangeMonitor(this);\n if (OpenMode.ReadWrite === this._openMode)\n this.txns.onAfterUndoRedo.addListener(async () => { await IModelApp.toolAdmin.restartPrimitiveTool(); });\n }\n\n /** Open a BriefcaseConnection to a [BriefcaseDb]($backend). */\n public static async openFile(briefcaseProps: OpenBriefcaseProps): Promise<BriefcaseConnection> {\n const iModelProps = await IpcApp.appFunctionIpc.openBriefcase(briefcaseProps);\n const connection = new this({ ...briefcaseProps, ...iModelProps }, briefcaseProps.readonly ? OpenMode.Readonly : OpenMode.ReadWrite);\n IModelConnection.onOpen.raiseEvent(connection);\n return connection;\n }\n\n /** Open a BriefcaseConnection to a [StandaloneDb]($backend)\n * @note StandaloneDbs, by definition, may not push or pull changes. Attempting to do so will throw exceptions.\n */\n public static async openStandalone(filePath: string, openMode: OpenMode = OpenMode.ReadWrite, opts?: StandaloneOpenOptions): Promise<BriefcaseConnection> {\n const openResponse = await IpcApp.appFunctionIpc.openStandalone(filePath, openMode, opts);\n const connection = new this(openResponse, openMode);\n IModelConnection.onOpen.raiseEvent(connection);\n return connection;\n }\n\n /** Returns `true` if [[close]] has already been called. */\n public get isClosed(): boolean { return this._isClosed === true; }\n\n /**\n * Close this BriefcaseConnection.\n * @note make sure to call [[saveChanges]] before calling this method. Unsaved local changes are abandoned.\n */\n public async close(): Promise<void> {\n if (this.isClosed)\n return;\n\n await this._modelsMonitor.close();\n\n this.beforeClose();\n this.txns[Symbol.dispose]();\n\n this._isClosed = true;\n await IpcApp.appFunctionIpc.closeIModel(this._fileKey);\n }\n\n protected requireTimeline() {\n if (this.iTwinId === Guid.empty)\n throw new IModelError(IModelStatus.WrongIModel, \"iModel has no timeline\");\n }\n\n /** Query if there are any pending Txns in this briefcase that are waiting to be pushed. */\n public async hasPendingTxns(): Promise<boolean> { // eslint-disable-line @itwin/prefer-get\n return this.txns.hasPendingTxns();\n }\n\n /** Commit pending changes to this briefcase.\n * @param description Optional description of the changes.\n */\n public async saveChanges(description?: string): Promise<void> {\n await IpcApp.appFunctionIpc.saveChanges(this.key, description);\n }\n\n /** Abandon pending changes to this briefcase. */\n public async abandonChanges(): Promise<void> {\n await IpcApp.appFunctionIpc.abandonChanges(this.key);\n }\n\n /** Pull (and potentially merge if there are local changes) up to a specified changeset from iModelHub into this briefcase\n * @param toIndex The changeset index to pull changes to. If `undefined`, pull all changes.\n * @param options Options for pulling changes.\n * @see [[BriefcaseTxns.onChangesPulled]] for the event dispatched after changes are pulled.\n */\n public async pullChanges(toIndex?: ChangesetIndex, options?: PullChangesOptions): Promise<void> {\n const removeListeners: VoidFunction[] = [];\n const shouldReportProgress = !!options?.downloadProgressCallback;\n\n if (shouldReportProgress) {\n const handleProgress = (_evt: Event, data: { loaded: number, total: number }) => {\n options?.downloadProgressCallback?.(data);\n };\n\n const removeProgressListener = IpcApp.addListener(\n getPullChangesIpcChannel(this.iModelId),\n handleProgress,\n );\n removeListeners.push(removeProgressListener);\n }\n\n if (options?.abortSignal) {\n const abort = () => void IpcApp.appFunctionIpc.cancelPullChangesRequest(this.key);\n options?.abortSignal.addEventListener(\"abort\", abort);\n removeListeners.push(() => options?.abortSignal?.removeEventListener(\"abort\", abort));\n }\n\n this.requireTimeline();\n const ipcAppOptions: IpcAppPullChangesOptions = {\n reportProgress: shouldReportProgress,\n progressInterval: options?.progressInterval,\n enableCancellation: !!options?.abortSignal,\n };\n try {\n this.changeset = await IpcApp.appFunctionIpc.pullChanges(this.key, toIndex, ipcAppOptions);\n } finally {\n removeListeners.forEach((remove) => remove());\n }\n }\n\n /** Create a changeset from local Txns and push to iModelHub. On success, clear Txn table.\n * @param description The description for the changeset\n * @returns the changesetId of the pushed changes\n * @see [[BriefcaseTxns.onChangesPushed]] for the event dispatched after changes are pushed.\n */\n public async pushChanges(description: string): Promise<ChangesetIndexAndId> {\n this.requireTimeline();\n return IpcApp.appFunctionIpc.pushChanges(this.key, description);\n }\n\n /** The current graphical editing scope, if one is in progress.\n * @see [[enterEditingScope]] to begin graphical editing.\n */\n public get editingScope(): GraphicalEditingScope | undefined {\n return this._modelsMonitor.editingScope;\n }\n\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\n * the BisCore ECSchema older than v0.1.11.\n * @see [[enterEditingScope]] to enable graphical editing.\n */\n public async supportsGraphicalEditing(): Promise<boolean> {\n return IpcApp.appFunctionIpc.isGraphicalEditingSupported(this.key);\n }\n\n /** Begin a new graphical editing scope.\n * @throws Error if an editing scope already exists or one could not be created.\n * @see [[GraphicalEditingScope.exit]] to exit the scope.\n * @see [[supportsGraphicalEditing]] to determine whether this method should be expected to succeed.\n * @see [[editingScope]] to obtain the current editing scope, if one is in progress.\n */\n public async enterEditingScope(): Promise<GraphicalEditingScope> {\n return this._modelsMonitor.enterEditingScope();\n }\n\n /** Strictly for tests - dispatched from ModelChangeMonitor.processBuffered.\n * @internal\n */\n public readonly onBufferedModelChanges = new BeEvent<(changedModelIds: Set<string>) => void>();\n}\n"]}
1
+ {"version":3,"file":"BriefcaseConnection.js","sourceRoot":"","sources":["../../src/BriefcaseConnection.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA+H;AAC/H,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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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;AAzKD,kDAyKC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module IModelConnection\n */\n\nimport { assert, BeEvent, CompressedId64Set, Guid, GuidString, Id64String, IModelStatus, OpenMode } from \"@itwin/core-bentley\";\nimport {\n ChangesetIndex, ChangesetIndexAndId, getPullChangesIpcChannel, IModelConnectionProps, IModelError,\n PullChangesOptions as IpcAppPullChangesOptions, OpenBriefcaseProps, StandaloneOpenOptions,\n} from \"@itwin/core-common\";\nimport { BriefcaseTxns } from \"./BriefcaseTxns\";\nimport { GraphicalEditingScope } from \"./GraphicalEditingScope\";\nimport { IModelApp } from \"./IModelApp\";\nimport { IModelConnection } from \"./IModelConnection\";\nimport { IpcApp } from \"./IpcApp\";\nimport { disposeTileTreesForGeometricModels } from \"./tile/internal\";\nimport { Viewport } from \"./Viewport\";\n\n/**\n * Download progress information.\n * @public\n */\nexport interface DownloadProgressInfo {\n /** Bytes downloaded. */\n loaded: number;\n /** Total size of the download in bytes. */\n total: number;\n}\n\n/**\n * Called to show progress during a download.\n * @public\n */\nexport type OnDownloadProgress = (progress: DownloadProgressInfo) => void;\n\n/**\n * Partial interface of AbortSignal.\n * @see https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal\n * @beta\n */\nexport interface GenericAbortSignal {\n /** Add Listener for abort signal. */\n addEventListener: (type: \"abort\", listener: (this: GenericAbortSignal, ev: any) => any) => void;\n /** Remove Listener for abort signal. */\n removeEventListener: (type: \"abort\", listener: (this: GenericAbortSignal, ev: any) => any) => void;\n}\n\n/**\n * Options for pulling iModel changes.\n * @public\n */\nexport interface PullChangesOptions {\n /** Function called regularly to report progress of changes download. */\n downloadProgressCallback?: OnDownloadProgress;\n /** Interval for calling progress callback (in milliseconds). */\n progressInterval?: number;\n /** Signal for cancelling the download.\n * @beta\n */\n abortSignal?: GenericAbortSignal;\n}\n\n/** Keeps track of changes to models, buffering them until synchronization points.\n * While a GraphicalEditingScope is open, the changes are buffered until the scope exits, at which point they are processed.\n * Otherwise, the buffered changes are processed after undo/redo, commit, or pull+merge changes.\n */\nclass ModelChangeMonitor {\n private _editingScope?: GraphicalEditingScope;\n private readonly _briefcase: BriefcaseConnection;\n private readonly _deletedModels = new Set<string>();\n private readonly _modelIdToGuid = new Map<string, string>();\n private readonly _removals: VoidFunction[] = [];\n\n public constructor(briefcase: BriefcaseConnection) {\n this._briefcase = briefcase;\n\n // Buffer updated geometry guids.\n this._removals.push(briefcase.txns.onModelGeometryChanged.addListener((changes) => {\n for (const change of changes) {\n this._deletedModels.delete(change.id);\n this._modelIdToGuid.set(change.id, change.guid);\n }\n }));\n\n // Buffer deletions of models.\n this._removals.push(briefcase.txns.onModelsChanged.addListener((changes) => {\n if (changes.deleted) {\n for (const id of CompressedId64Set.iterable(changes.deleted)) {\n this._modelIdToGuid.delete(id);\n this._deletedModels.add(id);\n }\n }\n }));\n\n // Outside of an editing scope, we want to update viewport contents after commit, undo/redo, or merging changes.\n const maybeProcess = async () => {\n if (this.editingScope)\n return;\n\n const modelIds = Array.from(this._modelIdToGuid.keys());\n if (modelIds.length > 0)\n await IModelApp.tileAdmin.purgeTileTrees(this._briefcase, modelIds);\n\n this.processBuffered();\n };\n\n this._removals.push(briefcase.txns.onCommitted.addListener(maybeProcess));\n this._removals.push(briefcase.txns.onReplayedExternalTxns.addListener(maybeProcess));\n this._removals.push(briefcase.txns.onAfterUndoRedo.addListener(maybeProcess));\n this._removals.push(briefcase.txns.onChangesPulled.addListener(maybeProcess));\n }\n\n public async close(): Promise<void> {\n for (const removal of this._removals)\n removal();\n\n this._removals.length = 0;\n\n if (this._editingScope) {\n await this._editingScope.exit();\n this._editingScope = undefined;\n }\n }\n\n public get editingScope(): GraphicalEditingScope | undefined {\n return this._editingScope;\n }\n\n public async enterEditingScope(): Promise<GraphicalEditingScope> {\n if (this._editingScope)\n throw new Error(\"Cannot create an editing scope for an iModel that already has one\");\n\n this._editingScope = await GraphicalEditingScope.enter(this._briefcase);\n\n const removeGeomListener = this._editingScope.onGeometryChanges.addListener((changes) => {\n const modelIds = [];\n for (const change of changes)\n modelIds.push(change.id);\n\n this.invalidateScenes(modelIds);\n });\n\n this._editingScope.onExited.addOnce((scope) => {\n assert(scope === this._editingScope);\n this._editingScope = undefined;\n removeGeomListener();\n this.processBuffered();\n });\n\n return this._editingScope;\n }\n\n private processBuffered(): void {\n const models = this._briefcase.models;\n for (const [id, guid] of this._modelIdToGuid) {\n const model = models.getLoaded(id)?.asGeometricModel;\n if (model)\n model.geometryGuid = guid;\n }\n\n const modelIds = new Set<string>(this._modelIdToGuid.keys());\n for (const deleted of this._deletedModels) {\n modelIds.add(deleted);\n models.unload(deleted);\n }\n\n this.invalidateScenes(modelIds);\n disposeTileTreesForGeometricModels(modelIds, this._briefcase);\n\n this._briefcase.onBufferedModelChanges.raiseEvent(modelIds);\n\n this._modelIdToGuid.clear();\n this._deletedModels.clear();\n }\n\n private invalidateScenes(changedModels: Iterable<Id64String>): void {\n for (const user of IModelApp.tileAdmin.tileUsers) {\n if (user instanceof Viewport && user.iModel === this._briefcase) {\n for (const modelId of changedModels) {\n if (user.view.viewsModel(modelId)) {\n user.invalidateScene();\n user.setFeatureOverrideProviderChanged();\n break;\n }\n }\n }\n }\n }\n}\n\n/** Settings that can be used to control the behavior of [[Tool]]s that modify a [[BriefcaseConnection]].\n * For example, tools that want to create new elements can consult the briefcase's editor tool settings to\n * determine into which model and category to insert the elements.\n * Specialized tools are free to ignore these settings.\n * @see [[BriefcaseConnection.editorToolSettings]] to query or modify the current settings for a briefcase.\n * @see [CreateElementTool]($editor-frontend) for an example of a tool that uses these settings.\n * @beta\n */\nexport class BriefcaseEditorToolSettings {\n private _category?: Id64String;\n private _model?: Id64String;\n\n /** An event raised just after the default [[category]] is changed. */\n public readonly onCategoryChanged = new BeEvent<(previousCategory: Id64String | undefined) => void>();\n\n /** An event raised just after the default [[model]] is changed. */\n public readonly onModelChanged = new BeEvent<(previousModel: Id64String | undefined) => void>();\n\n /** The [Category]($backend) into which new elements should be inserted by default.\n * Specialized tools are free to ignore this setting and instead use their own logic to select an appropriate category.\n * @see [[onCategoryChanged]] to be notified when this property is modified.\n * @see [CreateElementTool.targetCategory]($editor-frontend) for an example of a tool that uses this setting.\n */\n public get category(): Id64String | undefined {\n return this._category;\n }\n public set category(category: Id64String | undefined) {\n const previousCategory = this.category;\n if (category !== this.category) {\n this._category = category;\n this.onCategoryChanged.raiseEvent(previousCategory);\n }\n }\n\n /** The [Model]($backend) into which new elements should be inserted by default.\n * Specialized tools are free to ignore this setting and instead use their own logic to select an appropriate model.\n * @see [[onModelChanged]] to be notified when this property is modified.\n * @see [CreateElementTool.targetModelId]($editor-frontend) for an example of a tool that uses this setting.\n */\n public get model(): Id64String | undefined {\n return this._model;\n }\n public set model(model: Id64String | undefined) {\n const previousModel = this.model;\n if (model !== this.model) {\n this._model = model;\n this.onModelChanged.raiseEvent(previousModel);\n }\n }\n}\n\n/** A connection to an editable briefcase on the backend. This class uses [Ipc]($docs/learning/IpcInterface.md) to communicate\n * to the backend and may only be used by [[IpcApp]]s.\n * @public\n */\nexport class BriefcaseConnection extends IModelConnection {\n protected _isClosed?: boolean;\n private readonly _modelsMonitor: ModelChangeMonitor;\n /** Default settings that can be used to control the behavior of [[Tool]]s that modify this briefcase.\n * @beta\n */\n public readonly editorToolSettings = new BriefcaseEditorToolSettings();\n\n /** Manages local changes to the briefcase via [Txns]($docs/learning/InteractiveEditing.md). */\n public readonly txns: BriefcaseTxns;\n\n public override isBriefcaseConnection(): this is BriefcaseConnection { return true; }\n\n /** The Guid that identifies the iTwin that owns this iModel. */\n public override get iTwinId(): GuidString { return super.iTwinId ?? Guid.empty; } // GuidString | undefined for IModelConnection, but required for BriefcaseConnection\n\n /** The Guid that identifies this iModel. */\n public override get iModelId(): GuidString { return super.iModelId ?? Guid.empty; } // GuidString | undefined for IModelConnection, but required for BriefcaseConnection\n\n protected constructor(props: IModelConnectionProps, openMode: OpenMode) {\n super(props);\n this._openMode = openMode;\n this.txns = new BriefcaseTxns(this);\n this._modelsMonitor = new ModelChangeMonitor(this);\n if (OpenMode.ReadWrite === this._openMode)\n this.txns.onAfterUndoRedo.addListener(async () => { await IModelApp.toolAdmin.restartPrimitiveTool(); });\n\n this.categories.cache.attachToBriefcase(this);\n }\n\n /** Open a BriefcaseConnection to a [BriefcaseDb]($backend). */\n public static async openFile(briefcaseProps: OpenBriefcaseProps): Promise<BriefcaseConnection> {\n const iModelProps = await IpcApp.appFunctionIpc.openBriefcase(briefcaseProps);\n const connection = new this({ ...briefcaseProps, ...iModelProps }, briefcaseProps.readonly ? OpenMode.Readonly : OpenMode.ReadWrite);\n IModelConnection.onOpen.raiseEvent(connection);\n return connection;\n }\n\n /** Open a BriefcaseConnection to a [StandaloneDb]($backend)\n * @note StandaloneDbs, by definition, may not push or pull changes. Attempting to do so will throw exceptions.\n */\n public static async openStandalone(filePath: string, openMode: OpenMode = OpenMode.ReadWrite, opts?: StandaloneOpenOptions): Promise<BriefcaseConnection> {\n const openResponse = await IpcApp.appFunctionIpc.openStandalone(filePath, openMode, opts);\n const connection = new this(openResponse, openMode);\n IModelConnection.onOpen.raiseEvent(connection);\n return connection;\n }\n\n /** Returns `true` if [[close]] has already been called. */\n public get isClosed(): boolean { return this._isClosed === true; }\n\n /**\n * Close this BriefcaseConnection.\n * @note make sure to call [[saveChanges]] before calling this method. Unsaved local changes are abandoned.\n */\n public async close(): Promise<void> {\n if (this.isClosed)\n return;\n\n await this._modelsMonitor.close();\n\n this.beforeClose();\n this.txns[Symbol.dispose]();\n\n this._isClosed = true;\n await IpcApp.appFunctionIpc.closeIModel(this._fileKey);\n }\n\n protected requireTimeline() {\n if (this.iTwinId === Guid.empty)\n throw new IModelError(IModelStatus.WrongIModel, \"iModel has no timeline\");\n }\n\n /** Query if there are any pending Txns in this briefcase that are waiting to be pushed. */\n public async hasPendingTxns(): Promise<boolean> { // eslint-disable-line @itwin/prefer-get\n return this.txns.hasPendingTxns();\n }\n\n /** Commit pending changes to this briefcase.\n * @param description Optional description of the changes.\n */\n public async saveChanges(description?: string): Promise<void> {\n await IpcApp.appFunctionIpc.saveChanges(this.key, description);\n }\n\n /** Abandon pending changes to this briefcase. */\n public async abandonChanges(): Promise<void> {\n await IpcApp.appFunctionIpc.abandonChanges(this.key);\n }\n\n /** Pull (and potentially merge if there are local changes) up to a specified changeset from iModelHub into this briefcase\n * @param toIndex The changeset index to pull changes to. If `undefined`, pull all changes.\n * @param options Options for pulling changes.\n * @see [[BriefcaseTxns.onChangesPulled]] for the event dispatched after changes are pulled.\n */\n public async pullChanges(toIndex?: ChangesetIndex, options?: PullChangesOptions): Promise<void> {\n const removeListeners: VoidFunction[] = [];\n const shouldReportProgress = !!options?.downloadProgressCallback;\n\n if (shouldReportProgress) {\n const handleProgress = (_evt: Event, data: { loaded: number, total: number }) => {\n options?.downloadProgressCallback?.(data);\n };\n\n const removeProgressListener = IpcApp.addListener(\n getPullChangesIpcChannel(this.iModelId),\n handleProgress,\n );\n removeListeners.push(removeProgressListener);\n }\n\n if (options?.abortSignal) {\n const abort = () => void IpcApp.appFunctionIpc.cancelPullChangesRequest(this.key);\n options?.abortSignal.addEventListener(\"abort\", abort);\n removeListeners.push(() => options?.abortSignal?.removeEventListener(\"abort\", abort));\n }\n\n this.requireTimeline();\n const ipcAppOptions: IpcAppPullChangesOptions = {\n reportProgress: shouldReportProgress,\n progressInterval: options?.progressInterval,\n enableCancellation: !!options?.abortSignal,\n };\n try {\n this.changeset = await IpcApp.appFunctionIpc.pullChanges(this.key, toIndex, ipcAppOptions);\n } finally {\n removeListeners.forEach((remove) => remove());\n }\n }\n\n /** Create a changeset from local Txns and push to iModelHub. On success, clear Txn table.\n * @param description The description for the changeset\n * @returns the changesetId of the pushed changes\n * @see [[BriefcaseTxns.onChangesPushed]] for the event dispatched after changes are pushed.\n */\n public async pushChanges(description: string): Promise<ChangesetIndexAndId> {\n this.requireTimeline();\n return IpcApp.appFunctionIpc.pushChanges(this.key, description);\n }\n\n /** The current graphical editing scope, if one is in progress.\n * @see [[enterEditingScope]] to begin graphical editing.\n */\n public get editingScope(): GraphicalEditingScope | undefined {\n return this._modelsMonitor.editingScope;\n }\n\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\n * the BisCore ECSchema older than v0.1.11.\n * @see [[enterEditingScope]] to enable graphical editing.\n */\n public async supportsGraphicalEditing(): Promise<boolean> {\n return IpcApp.appFunctionIpc.isGraphicalEditingSupported(this.key);\n }\n\n /** Begin a new graphical editing scope.\n * @throws Error if an editing scope already exists or one could not be created.\n * @see [[GraphicalEditingScope.exit]] to exit the scope.\n * @see [[supportsGraphicalEditing]] to determine whether this method should be expected to succeed.\n * @see [[editingScope]] to obtain the current editing scope, if one is in progress.\n */\n public async enterEditingScope(): Promise<GraphicalEditingScope> {\n return this._modelsMonitor.enterEditingScope();\n }\n\n /** Strictly for tests - dispatched from ModelChangeMonitor.processBuffered.\n * @internal\n */\n public readonly onBufferedModelChanges = new BeEvent<(changedModelIds: Set<string>) => void>();\n}\n"]}
@@ -24,6 +24,7 @@ export declare class SubCategoriesCache {
24
24
  private readonly _imodel;
25
25
  private _missingAtTimeOfPreload;
26
26
  constructor(imodel: IModelConnection);
27
+ attachToBriefcase(imodel: IModelConnection): void;
27
28
  /** Get the Ids of all subcategories belonging to the category with the specified Id, or undefined if no such information is present. */
28
29
  getSubCategories(categoryId: string): Id64Set | undefined;
29
30
  /** Get the base appearance of the subcategory with the specified Id, or undefined if no such information is present. */
@@ -1 +1 @@
1
- {"version":3,"file":"SubCategoriesCache.d.ts","sourceRoot":"","sources":["../../src/SubCategoriesCache.ts"],"names":[],"mappings":"AAKA,OAAO,EAAmC,OAAO,EAAE,OAAO,EAAE,UAAU,EAAuB,MAAM,qBAAqB,CAAC;AACzH,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AACjF,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACnC,8EAA8E;IAC9E,QAAQ,CAAC,kBAAkB,EAAE,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AAO,CAAC;QACrC,SAAgB,KAAK,EAAE,SAAS,EAAE,CAAC;oBAEhB,WAAW,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS;KAIzD;IAED;;;;;OAKG;IACH,MAAa,KAAK;QAEhB,SAAS,CAAC,QAAQ,CAAC,EAAE,UAAU,CAAC;QAChC,SAAS,CAAC,KAAK,CAAC,EAAE,UAAU,CAAC;QAC7B,SAAS,CAAC,QAAQ,CAAC,EAAE,oBAAoB,CAAC;QAC1C,SAAS,CAAC,SAAS,UAAS;QAE5B;;WAEG;QACI,IAAI,CAAC,KAAK,EAAE,kBAAkB,EAAE,WAAW,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,GAAG,IAAI;QASnF,+CAA+C;QACxC,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI;QAW/B,IAAW,OAAO,IAAI,OAAO,CAE5B;QAED,OAAO,CAAC,WAAW;QAgBnB,OAAO,CAAC,cAAc;QAoCtB,OAAO,CAAC,QAAQ;KAgBjB;CACF"}
@@ -16,7 +16,46 @@ class SubCategoriesCache {
16
16
  _appearances = new Map();
17
17
  _imodel;
18
18
  _missingAtTimeOfPreload;
19
- constructor(imodel) { this._imodel = imodel; }
19
+ constructor(imodel) {
20
+ this._imodel = imodel;
21
+ }
22
+ attachToBriefcase(imodel) {
23
+ // We want to do this in the constructor but can't, because IModelConnection.subcategories is initialized before
24
+ // BriefcaseConnection.txns.
25
+ (0, core_bentley_1.assert)(imodel === this._imodel);
26
+ (0, core_bentley_1.assert)(imodel.isBriefcaseConnection());
27
+ imodel.txns.onElementsChanged.addListener((changes) => {
28
+ const affectedSubCategories = new Set();
29
+ for (const change of changes) {
30
+ if (change.metadata.is("BisCore:Category")) {
31
+ if (change.type === "deleted") {
32
+ this._byCategoryId.delete(change.id);
33
+ }
34
+ }
35
+ else if (change.metadata.is("BisCore:SubCategory")) {
36
+ if (change.type === "inserted") {
37
+ // We don't know to which category the subcategory belongs. Blow away the entire cache.
38
+ this._byCategoryId.clear();
39
+ this._appearances.clear();
40
+ return;
41
+ }
42
+ this._appearances.delete(change.id);
43
+ affectedSubCategories.add(change.id);
44
+ }
45
+ }
46
+ if (affectedSubCategories.size > 0) {
47
+ for (const [catId, subCatIds] of this._byCategoryId) {
48
+ for (const subCatId of affectedSubCategories) {
49
+ if (subCatIds.has(subCatId)) {
50
+ this._byCategoryId.delete(catId);
51
+ affectedSubCategories.delete(subCatId);
52
+ break;
53
+ }
54
+ }
55
+ }
56
+ }
57
+ });
58
+ }
20
59
  /** Get the Ids of all subcategories belonging to the category with the specified Id, or undefined if no such information is present. */
21
60
  getSubCategories(categoryId) { return this._byCategoryId.get(categoryId); }
22
61
  /** Get the base appearance of the subcategory with the specified Id, or undefined if no such information is present. */
@@ -1 +1 @@
1
- {"version":3,"file":"SubCategoriesCache.js","sourceRoot":"","sources":["../../src/SubCategoriesCache.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,sDAAyH;AACzH,oDAAiF;AAkBjF,MAAM,sBAAsB,GAAG,IAAI,GAAG,EAAU,CAAC;AAEjD;;GAEG;AACH,MAAa,kBAAkB;IACZ,aAAa,GAAG,IAAI,GAAG,EAAmB,CAAC;IAC3C,YAAY,GAAG,IAAI,GAAG,EAAiC,CAAC;IACxD,OAAO,CAAmB;IACnC,uBAAuB,CAAsB;IAErD,YAAmB,MAAwB,IAAI,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,CAAC,CAAC;IAEvE,wIAAwI;IACjI,gBAAgB,CAAC,UAAkB,IAAyB,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IAE/G,wHAAwH;IACjH,wBAAwB,CAAC,aAAyB,IAAuC,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,aAAa,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC;IAEzJ;;;;OAIG;IACI,IAAI,CAAC,WAAoB;QAC9B,MAAM,OAAO,GAAG,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AAU,IAAI,mBAAI,CAAC,QAAQ,CAAC,WAAW,CAAC;oBACjD,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;YAC3C,CAAC;QACH,CAAC;KACF;IAvGY,wBAAK,QAuGjB,CAAA;AACH,CAAC,EAjLgB,kBAAkB,kCAAlB,kBAAkB,QAiLlC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nimport { assert, CompressedId64Set, Id64, Id64Arg, Id64Set, Id64String, OrderedId64Iterable } from \"@itwin/core-bentley\";\nimport { SubCategoryAppearance, SubCategoryResultRow } from \"@itwin/core-common\";\nimport { IModelConnection } from \"./IModelConnection\";\n\n/** A cancelable paginated request for subcategory information.\n * @see SubCategoriesCache\n * @internal\n */\nexport interface SubCategoriesRequest {\n /** The Ids of any categories which were requested but were not yet loaded. */\n readonly missingCategoryIds: Id64Set;\n /** A promise which resolves to true when all of the requested categories have been loaded, or to false if not all categories were loaded.\n * Categories may fail to load if the request is explicitly canceled or if the IModelConnection is closed before all categories are loaded.\n */\n readonly promise: Promise<boolean>;\n /** Cancels the request. */\n cancel(): void;\n}\n\nconst invalidCategoryIdEntry = new Set<string>();\n\n/** A cache of information about the subcategories contained within an [[IModelConnection]]. It is populated on demand.\n * @internal\n */\nexport class SubCategoriesCache {\n private readonly _byCategoryId = new Map<string, Id64Set>();\n private readonly _appearances = new Map<string, SubCategoryAppearance>();\n private readonly _imodel: IModelConnection;\n private _missingAtTimeOfPreload: Id64Set | undefined;\n\n public constructor(imodel: IModelConnection) { this._imodel = imodel; }\n\n /** Get the Ids of all subcategories belonging to the category with the specified Id, or undefined if no such information is present. */\n public getSubCategories(categoryId: string): Id64Set | undefined { return this._byCategoryId.get(categoryId); }\n\n /** Get the base appearance of the subcategory with the specified Id, or undefined if no such information is present. */\n public getSubCategoryAppearance(subCategoryId: Id64String): SubCategoryAppearance | undefined { return this._appearances.get(subCategoryId.toString()); }\n\n /** Request that the subcategory information for all of the specified categories is loaded.\n * If all such information has already been loaded, returns undefined.\n * Otherwise, dispatches an asynchronous request to load those categories which are not already loaded and returns a cancellable request object\n * containing the corresponding promise and the set of categories still to be loaded.\n */\n public load(categoryIds: Id64Arg): SubCategoriesRequest | undefined {\n const missing = this.getMissing(categoryIds);\n if (undefined === missing)\n return undefined;\n\n const request = new SubCategoriesCache.Request(missing, this._imodel);\n const promise = request.dispatch().then((result?: SubCategoriesCache.Result) => {\n if (undefined !== result)\n this.processResults(result, missing);\n\n return !request.wasCanceled;\n });\n return {\n missingCategoryIds: missing,\n promise,\n cancel: () => request.cancel(),\n };\n }\n\n /** Load all subcategories that come from used spatial categories of the iModel into the cache. */\n public async loadAllUsedSpatialSubCategories(): Promise<void> {\n try {\n const results = await this._imodel.queryAllUsedSpatialSubCategories();\n if (undefined !== results) {\n this.processResults(results, new Set<string>(), false);\n }\n } catch {\n // In case of a truncated response, gracefully handle the error and exit.\n }\n\n }\n /** Given categoryIds, return which of these are not cached. */\n private getMissing(categoryIds: Id64Arg): Id64Set | undefined {\n let missing: Id64Set | undefined;\n for (const catId of Id64.iterable(categoryIds)) {\n if (undefined === this._byCategoryId.get(catId)) {\n if (undefined === missing)\n missing = new Set<string>();\n\n missing.add(catId);\n }\n }\n\n return missing;\n }\n\n public clear(): void {\n this._byCategoryId.clear();\n this._appearances.clear();\n }\n\n public onIModelConnectionClose(): void {\n this.clear();\n }\n\n private static createSubCategoryAppearance(json?: any) {\n let props: SubCategoryAppearance.Props | undefined;\n if (\"string\" === typeof json && 0 < json.length)\n props = JSON.parse(json);\n\n return new SubCategoryAppearance(props);\n }\n\n private processResults(result: SubCategoriesCache.Result, missing: Id64Set, override: boolean = true): void {\n for (const row of result) {\n this.add(row.parentId, row.id, SubCategoriesCache.createSubCategoryAppearance(row.appearance), override);\n }\n\n // Ensure that any category Ids which returned no results (e.g., non-existent category, invalid Id, etc) are still recorded so they are not repeatedly re-requested\n for (const id of missing)\n if (undefined === this._byCategoryId.get(id))\n this._byCategoryId.set(id, invalidCategoryIdEntry);\n }\n\n /** Exposed strictly for tests.\n * @internal\n */\n public add(categoryId: string, subCategoryId: string, appearance: SubCategoryAppearance, override: boolean) {\n let set = this._byCategoryId.get(categoryId);\n if (undefined === set)\n this._byCategoryId.set(categoryId, set = new Set<string>());\n\n set.add(subCategoryId);\n if (override || !this._appearances.has(subCategoryId))\n this._appearances.set(subCategoryId, appearance);\n }\n\n public async getCategoryInfo(inputCategoryIds: Id64String | Iterable<Id64String>): Promise<Map<Id64String, IModelConnection.Categories.CategoryInfo>> {\n // Eliminate duplicates...\n const categoryIds = new Set<string>(typeof inputCategoryIds === \"string\" ? [inputCategoryIds] : inputCategoryIds);\n const req = this.load(categoryIds);\n if (req)\n await req.promise;\n\n const map = new Map<Id64String, IModelConnection.Categories.CategoryInfo>();\n for (const categoryId of categoryIds) {\n const subCategoryIds = this._byCategoryId.get(categoryId);\n if (!subCategoryIds)\n continue;\n\n const subCategories = this.mapSubCategoryInfos(categoryId, subCategoryIds);\n map.set(categoryId, { id: categoryId, subCategories });\n }\n\n return map;\n }\n\n public async getSubCategoryInfo(categoryId: Id64String, inputSubCategoryIds: Id64String | Iterable<Id64String>): Promise<Map<Id64String, IModelConnection.Categories.SubCategoryInfo>> {\n // Eliminate duplicates...\n const subCategoryIds = new Set<string>(typeof inputSubCategoryIds === \"string\" ? [inputSubCategoryIds] : inputSubCategoryIds);\n const req = this.load(categoryId);\n if (req)\n await req.promise;\n\n return this.mapSubCategoryInfos(categoryId, subCategoryIds);\n }\n\n private mapSubCategoryInfos(categoryId: Id64String, subCategoryIds: Set<Id64String>): Map<Id64String, IModelConnection.Categories.SubCategoryInfo> {\n const map = new Map<Id64String, IModelConnection.Categories.SubCategoryInfo>();\n for (const id of subCategoryIds) {\n const appearance = this._appearances.get(id);\n if (appearance)\n map.set(id, { id, categoryId, appearance });\n }\n\n return map;\n }\n}\n\n/** This namespace and the types within it are exported strictly for use in tests.\n * @internal\n */\nexport namespace SubCategoriesCache {\n export type Result = SubCategoryResultRow[];\n\n export class Request {\n private readonly _imodel: IModelConnection;\n private readonly _categoryIds: CompressedId64Set[] = [];\n private readonly _result: Result = [];\n private _canceled = false;\n private _curCategoryIdsIndex = 0;\n\n public get wasCanceled() { return this._canceled || this._imodel.isClosed; }\n\n public constructor(categoryIds: Set<string>, imodel: IModelConnection, maxCategoriesPerQuery = 2500) {\n this._imodel = imodel;\n\n const catIds = [...categoryIds];\n OrderedId64Iterable.sortArray(catIds); // sort categories, so that given the same set of categoryIds we will always create the same batches.\n while (catIds.length !== 0) {\n const end = (catIds.length > maxCategoriesPerQuery) ? maxCategoriesPerQuery : catIds.length;\n const compressedIds = CompressedId64Set.compressArray(catIds.splice(0, end));\n this._categoryIds.push(compressedIds);\n }\n }\n\n public cancel() { this._canceled = true; }\n\n public async dispatch(): Promise<Result | undefined> {\n if (this.wasCanceled || this._curCategoryIdsIndex >= this._categoryIds.length) // handle case of empty category Id set...\n return undefined;\n\n try {\n const catIds = this._categoryIds[this._curCategoryIdsIndex];\n const result = await this._imodel.querySubCategories(catIds);\n this._result.push(...result);\n if (this.wasCanceled)\n return undefined;\n } catch {\n // ###TODO: detect cases in which retry is warranted\n // Note that currently, if we succeed in obtaining some pages of results and fail to retrieve another page, we will end up processing the\n // incomplete results. Since we're not retrying, that's the best we can do.\n }\n\n // Finished with current batch of categoryIds. Dispatch the next batch if one exists.\n if (++this._curCategoryIdsIndex < this._categoryIds.length) {\n if (this.wasCanceled)\n return undefined;\n else\n return this.dispatch();\n }\n\n // Even if we were canceled, we've retrieved all the rows. Might as well process them to prevent another request for some of the same rows from being enqueued.\n return this._result;\n }\n }\n\n export type QueueFunc = (anySubCategoriesLoaded: boolean) => void;\n\n export class QueueEntry {\n public readonly categoryIds: Id64Set;\n public readonly funcs: QueueFunc[];\n\n public constructor(categoryIds: Id64Set, func: QueueFunc) {\n this.categoryIds = categoryIds;\n this.funcs = [func];\n }\n }\n\n /** A \"queue\" of SubCategoriesRequests, which consists of between 0 and 2 entries. Each entry specifies the set of category IDs to be loaded and a list of functions to be executed\n * when loading is completed. This is used to enforce ordering of operations upon subcategories despite the need to asynchronously load them. It incidentally also provides an\n * opportunity to reduce the number of backend requests by batching consecutive requests.\n * Chiefly used by [[Viewport]].\n * @internal\n */\n export class Queue {\n /* NB: Members marked protected for use in tests only. */\n protected _current?: QueueEntry;\n protected _next?: QueueEntry;\n protected _request?: SubCategoriesRequest;\n protected _disposed = false;\n\n /** Push a request onto the queue. The requested categories will be loaded if necessary, and then\n * the supplied function will be invoked. Any previously-pushed requests are guaranteed to be processed before this one.\n */\n public push(cache: SubCategoriesCache, categoryIds: Id64Arg, func: QueueFunc): void {\n if (this._disposed)\n return;\n else if (undefined === this._current)\n this.pushCurrent(cache, categoryIds, func);\n else\n this.pushNext(categoryIds, func);\n }\n\n /** Cancel all requests and empty the queue. */\n public [Symbol.dispose](): void {\n if (undefined !== this._request) {\n assert(undefined !== this._current);\n this._request.cancel();\n this._request = undefined;\n }\n\n this._current = this._next = undefined;\n this._disposed = true;\n }\n\n public get isEmpty(): boolean {\n return undefined === this._current && undefined === this._next;\n }\n\n private pushCurrent(cache: SubCategoriesCache, categoryIds: Id64Arg, func: QueueFunc): void {\n assert(undefined === this._next);\n assert(undefined === this._current);\n assert(undefined === this._request);\n\n this._request = cache.load(categoryIds);\n if (undefined === this._request) {\n // All requested categories are already loaded.\n func(false);\n return;\n } else {\n // We need to load the requested categories before invoking the function.\n this.processCurrent(cache, new QueueEntry(Id64.toIdSet(categoryIds, true), func));\n }\n }\n\n private processCurrent(cache: SubCategoriesCache, entry: QueueEntry): void {\n assert(undefined !== this._request);\n assert(undefined === this._current);\n assert(undefined === this._next);\n\n this._current = entry;\n this._request.promise.then((completed: boolean) => { // eslint-disable-line @typescript-eslint/no-floating-promises\n if (this._disposed)\n return;\n\n // Invoke all the functions which were awaiting this set of IModelConnection.Categories.\n assert(undefined !== this._current);\n if (completed)\n for (const func of this._current.funcs)\n func(true);\n\n this._request = undefined;\n this._current = undefined;\n\n // If we have more requests, process them.\n const next = this._next;\n this._next = undefined;\n if (undefined !== next) {\n this._request = cache.load(next.categoryIds);\n if (undefined === this._request) {\n // All categories loaded.\n for (const func of next.funcs)\n func(true);\n } else {\n // We need to load the requested categories before invoking the pending functions.\n this.processCurrent(cache, next);\n }\n }\n });\n }\n\n private pushNext(categoryIds: Id64Arg, func: QueueFunc): void {\n assert(undefined !== this._current);\n assert(undefined !== this._request);\n\n if (undefined === this._next) {\n // We have a request currently in process and none pending.\n // We could potentially determine that this request doesn't require any categories that are not already loaded or being loaded by the current request.\n // But we will find that out (synchronously) when current request completes, unless more requests come in. Probably not worth it.\n this._next = new QueueEntry(Id64.toIdSet(categoryIds, true), func);\n } else {\n // We have a request currently in process, and one or more pending. Append this one to the pending.\n this._next.funcs.push(func);\n for (const categoryId of Id64.iterable(categoryIds))\n this._next.categoryIds.add(categoryId);\n }\n }\n }\n}\n"]}
1
+ {"version":3,"file":"SubCategoriesCache.js","sourceRoot":"","sources":["../../src/SubCategoriesCache.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,sDAAyH;AACzH,oDAAiF;AAkBjF,MAAM,sBAAsB,GAAG,IAAI,GAAG,EAAU,CAAC;AAEjD;;GAEG;AACH,MAAa,kBAAkB;IACZ,aAAa,GAAG,IAAI,GAAG,EAAmB,CAAC;IAC3C,YAAY,GAAG,IAAI,GAAG,EAAiC,CAAC;IACxD,OAAO,CAAmB;IACnC,uBAAuB,CAAsB;IAErD,YAAmB,MAAwB;QACzC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IAEM,iBAAiB,CAAC,MAAwB;QAC/C,gHAAgH;QAChH,4BAA4B;QAC5B,IAAA,qBAAM,EAAC,MAAM,KAAK,IAAI,CAAC,OAAO,CAAC,CAAC;QAChC,IAAA,qBAAM,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CAAC,QAAQ,CAAC,CAAC;YACpC,IAAA,qBAAM,EAAC,SAAS,KAAK,IAAI,CAAC,QAAQ,CAAC,CAAC;YAEpC,IAAI,SAAS,KAAK,IAAI,CAAC,KAAK,EAAE,CAAC;gBAC7B,2DAA2D;gBAC3D,sJAAsJ;gBACtJ,iIAAiI;gBACjI,IAAI,CAAC,KAAK,GAAG,IAAI,UAAU,CAAC,mBAAI,CAAC,OAAO,CAAC,WAAW,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC;YACrE,CAAC;iBAAM,CAAC;gBACN,mGAAmG;gBACnG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBAC5B,KAAK,MAAM,UAAU,IAAI,mBAAI,CAAC,QAAQ,CAAC,WAAW,CAAC;oBACjD,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;YAC3C,CAAC;QACH,CAAC;KACF;IAvGY,wBAAK,QAuGjB,CAAA;AACH,CAAC,EAjLgB,kBAAkB,kCAAlB,kBAAkB,QAiLlC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nimport { assert, CompressedId64Set, Id64, Id64Arg, Id64Set, Id64String, OrderedId64Iterable } from \"@itwin/core-bentley\";\nimport { SubCategoryAppearance, SubCategoryResultRow } from \"@itwin/core-common\";\nimport { IModelConnection } from \"./IModelConnection\";\n\n/** A cancelable paginated request for subcategory information.\n * @see SubCategoriesCache\n * @internal\n */\nexport interface SubCategoriesRequest {\n /** The Ids of any categories which were requested but were not yet loaded. */\n readonly missingCategoryIds: Id64Set;\n /** A promise which resolves to true when all of the requested categories have been loaded, or to false if not all categories were loaded.\n * Categories may fail to load if the request is explicitly canceled or if the IModelConnection is closed before all categories are loaded.\n */\n readonly promise: Promise<boolean>;\n /** Cancels the request. */\n cancel(): void;\n}\n\nconst invalidCategoryIdEntry = new Set<string>();\n\n/** A cache of information about the subcategories contained within an [[IModelConnection]]. It is populated on demand.\n * @internal\n */\nexport class SubCategoriesCache {\n private readonly _byCategoryId = new Map<string, Id64Set>();\n private readonly _appearances = new Map<string, SubCategoryAppearance>();\n private readonly _imodel: IModelConnection;\n private _missingAtTimeOfPreload: Id64Set | undefined;\n\n public constructor(imodel: IModelConnection) {\n this._imodel = imodel;\n }\n\n public attachToBriefcase(imodel: IModelConnection): void {\n // We want to do this in the constructor but can't, because IModelConnection.subcategories is initialized before\n // BriefcaseConnection.txns.\n assert(imodel === this._imodel);\n assert(imodel.isBriefcaseConnection());\n imodel.txns.onElementsChanged.addListener((changes) => {\n const affectedSubCategories = new Set<string>();\n for (const change of changes) {\n if (change.metadata.is(\"BisCore:Category\")) {\n if (change.type === \"deleted\") {\n this._byCategoryId.delete(change.id);\n }\n } else if (change.metadata.is(\"BisCore:SubCategory\")) {\n if (change.type === \"inserted\") {\n // We don't know to which category the subcategory belongs. Blow away the entire cache.\n this._byCategoryId.clear();\n this._appearances.clear();\n return;\n }\n\n this._appearances.delete(change.id);\n affectedSubCategories.add(change.id);\n }\n }\n\n if (affectedSubCategories.size > 0) {\n for (const [catId, subCatIds] of this._byCategoryId) {\n for (const subCatId of affectedSubCategories) {\n if (subCatIds.has(subCatId)) {\n this._byCategoryId.delete(catId);\n affectedSubCategories.delete(subCatId);\n break;\n }\n }\n }\n }\n });\n }\n /** Get the Ids of all subcategories belonging to the category with the specified Id, or undefined if no such information is present. */\n public getSubCategories(categoryId: string): Id64Set | undefined { return this._byCategoryId.get(categoryId); }\n\n /** Get the base appearance of the subcategory with the specified Id, or undefined if no such information is present. */\n public getSubCategoryAppearance(subCategoryId: Id64String): SubCategoryAppearance | undefined { return this._appearances.get(subCategoryId.toString()); }\n\n /** Request that the subcategory information for all of the specified categories is loaded.\n * If all such information has already been loaded, returns undefined.\n * Otherwise, dispatches an asynchronous request to load those categories which are not already loaded and returns a cancellable request object\n * containing the corresponding promise and the set of categories still to be loaded.\n */\n public load(categoryIds: Id64Arg): SubCategoriesRequest | undefined {\n const missing = this.getMissing(categoryIds);\n if (undefined === missing)\n return undefined;\n\n const request = new SubCategoriesCache.Request(missing, this._imodel);\n const promise = request.dispatch().then((result?: SubCategoriesCache.Result) => {\n if (undefined !== result)\n this.processResults(result, missing);\n\n return !request.wasCanceled;\n });\n return {\n missingCategoryIds: missing,\n promise,\n cancel: () => request.cancel(),\n };\n }\n\n /** Load all subcategories that come from used spatial categories of the iModel into the cache. */\n public async loadAllUsedSpatialSubCategories(): Promise<void> {\n try {\n const results = await this._imodel.queryAllUsedSpatialSubCategories();\n if (undefined !== results) {\n this.processResults(results, new Set<string>(), false);\n }\n } catch {\n // In case of a truncated response, gracefully handle the error and exit.\n }\n\n }\n /** Given categoryIds, return which of these are not cached. */\n private getMissing(categoryIds: Id64Arg): Id64Set | undefined {\n let missing: Id64Set | undefined;\n for (const catId of Id64.iterable(categoryIds)) {\n if (undefined === this._byCategoryId.get(catId)) {\n if (undefined === missing)\n missing = new Set<string>();\n\n missing.add(catId);\n }\n }\n\n return missing;\n }\n\n public clear(): void {\n this._byCategoryId.clear();\n this._appearances.clear();\n }\n\n public onIModelConnectionClose(): void {\n this.clear();\n }\n\n private static createSubCategoryAppearance(json?: any) {\n let props: SubCategoryAppearance.Props | undefined;\n if (\"string\" === typeof json && 0 < json.length)\n props = JSON.parse(json);\n\n return new SubCategoryAppearance(props);\n }\n\n private processResults(result: SubCategoriesCache.Result, missing: Id64Set, override: boolean = true): void {\n for (const row of result) {\n this.add(row.parentId, row.id, SubCategoriesCache.createSubCategoryAppearance(row.appearance), override);\n }\n\n // Ensure that any category Ids which returned no results (e.g., non-existent category, invalid Id, etc) are still recorded so they are not repeatedly re-requested\n for (const id of missing)\n if (undefined === this._byCategoryId.get(id))\n this._byCategoryId.set(id, invalidCategoryIdEntry);\n }\n\n /** Exposed strictly for tests.\n * @internal\n */\n public add(categoryId: string, subCategoryId: string, appearance: SubCategoryAppearance, override: boolean) {\n let set = this._byCategoryId.get(categoryId);\n if (undefined === set)\n this._byCategoryId.set(categoryId, set = new Set<string>());\n\n set.add(subCategoryId);\n if (override || !this._appearances.has(subCategoryId))\n this._appearances.set(subCategoryId, appearance);\n }\n\n public async getCategoryInfo(inputCategoryIds: Id64String | Iterable<Id64String>): Promise<Map<Id64String, IModelConnection.Categories.CategoryInfo>> {\n // Eliminate duplicates...\n const categoryIds = new Set<string>(typeof inputCategoryIds === \"string\" ? [inputCategoryIds] : inputCategoryIds);\n const req = this.load(categoryIds);\n if (req)\n await req.promise;\n\n const map = new Map<Id64String, IModelConnection.Categories.CategoryInfo>();\n for (const categoryId of categoryIds) {\n const subCategoryIds = this._byCategoryId.get(categoryId);\n if (!subCategoryIds)\n continue;\n\n const subCategories = this.mapSubCategoryInfos(categoryId, subCategoryIds);\n map.set(categoryId, { id: categoryId, subCategories });\n }\n\n return map;\n }\n\n public async getSubCategoryInfo(categoryId: Id64String, inputSubCategoryIds: Id64String | Iterable<Id64String>): Promise<Map<Id64String, IModelConnection.Categories.SubCategoryInfo>> {\n // Eliminate duplicates...\n const subCategoryIds = new Set<string>(typeof inputSubCategoryIds === \"string\" ? [inputSubCategoryIds] : inputSubCategoryIds);\n const req = this.load(categoryId);\n if (req)\n await req.promise;\n\n return this.mapSubCategoryInfos(categoryId, subCategoryIds);\n }\n\n private mapSubCategoryInfos(categoryId: Id64String, subCategoryIds: Set<Id64String>): Map<Id64String, IModelConnection.Categories.SubCategoryInfo> {\n const map = new Map<Id64String, IModelConnection.Categories.SubCategoryInfo>();\n for (const id of subCategoryIds) {\n const appearance = this._appearances.get(id);\n if (appearance)\n map.set(id, { id, categoryId, appearance });\n }\n\n return map;\n }\n}\n\n/** This namespace and the types within it are exported strictly for use in tests.\n * @internal\n */\nexport namespace SubCategoriesCache {\n export type Result = SubCategoryResultRow[];\n\n export class Request {\n private readonly _imodel: IModelConnection;\n private readonly _categoryIds: CompressedId64Set[] = [];\n private readonly _result: Result = [];\n private _canceled = false;\n private _curCategoryIdsIndex = 0;\n\n public get wasCanceled() { return this._canceled || this._imodel.isClosed; }\n\n public constructor(categoryIds: Set<string>, imodel: IModelConnection, maxCategoriesPerQuery = 2500) {\n this._imodel = imodel;\n\n const catIds = [...categoryIds];\n OrderedId64Iterable.sortArray(catIds); // sort categories, so that given the same set of categoryIds we will always create the same batches.\n while (catIds.length !== 0) {\n const end = (catIds.length > maxCategoriesPerQuery) ? maxCategoriesPerQuery : catIds.length;\n const compressedIds = CompressedId64Set.compressArray(catIds.splice(0, end));\n this._categoryIds.push(compressedIds);\n }\n }\n\n public cancel() { this._canceled = true; }\n\n public async dispatch(): Promise<Result | undefined> {\n if (this.wasCanceled || this._curCategoryIdsIndex >= this._categoryIds.length) // handle case of empty category Id set...\n return undefined;\n\n try {\n const catIds = this._categoryIds[this._curCategoryIdsIndex];\n const result = await this._imodel.querySubCategories(catIds);\n this._result.push(...result);\n if (this.wasCanceled)\n return undefined;\n } catch {\n // ###TODO: detect cases in which retry is warranted\n // Note that currently, if we succeed in obtaining some pages of results and fail to retrieve another page, we will end up processing the\n // incomplete results. Since we're not retrying, that's the best we can do.\n }\n\n // Finished with current batch of categoryIds. Dispatch the next batch if one exists.\n if (++this._curCategoryIdsIndex < this._categoryIds.length) {\n if (this.wasCanceled)\n return undefined;\n else\n return this.dispatch();\n }\n\n // Even if we were canceled, we've retrieved all the rows. Might as well process them to prevent another request for some of the same rows from being enqueued.\n return this._result;\n }\n }\n\n export type QueueFunc = (anySubCategoriesLoaded: boolean) => void;\n\n export class QueueEntry {\n public readonly categoryIds: Id64Set;\n public readonly funcs: QueueFunc[];\n\n public constructor(categoryIds: Id64Set, func: QueueFunc) {\n this.categoryIds = categoryIds;\n this.funcs = [func];\n }\n }\n\n /** A \"queue\" of SubCategoriesRequests, which consists of between 0 and 2 entries. Each entry specifies the set of category IDs to be loaded and a list of functions to be executed\n * when loading is completed. This is used to enforce ordering of operations upon subcategories despite the need to asynchronously load them. It incidentally also provides an\n * opportunity to reduce the number of backend requests by batching consecutive requests.\n * Chiefly used by [[Viewport]].\n * @internal\n */\n export class Queue {\n /* NB: Members marked protected for use in tests only. */\n protected _current?: QueueEntry;\n protected _next?: QueueEntry;\n protected _request?: SubCategoriesRequest;\n protected _disposed = false;\n\n /** Push a request onto the queue. The requested categories will be loaded if necessary, and then\n * the supplied function will be invoked. Any previously-pushed requests are guaranteed to be processed before this one.\n */\n public push(cache: SubCategoriesCache, categoryIds: Id64Arg, func: QueueFunc): void {\n if (this._disposed)\n return;\n else if (undefined === this._current)\n this.pushCurrent(cache, categoryIds, func);\n else\n this.pushNext(categoryIds, func);\n }\n\n /** Cancel all requests and empty the queue. */\n public [Symbol.dispose](): void {\n if (undefined !== this._request) {\n assert(undefined !== this._current);\n this._request.cancel();\n this._request = undefined;\n }\n\n this._current = this._next = undefined;\n this._disposed = true;\n }\n\n public get isEmpty(): boolean {\n return undefined === this._current && undefined === this._next;\n }\n\n private pushCurrent(cache: SubCategoriesCache, categoryIds: Id64Arg, func: QueueFunc): void {\n assert(undefined === this._next);\n assert(undefined === this._current);\n assert(undefined === this._request);\n\n this._request = cache.load(categoryIds);\n if (undefined === this._request) {\n // All requested categories are already loaded.\n func(false);\n return;\n } else {\n // We need to load the requested categories before invoking the function.\n this.processCurrent(cache, new QueueEntry(Id64.toIdSet(categoryIds, true), func));\n }\n }\n\n private processCurrent(cache: SubCategoriesCache, entry: QueueEntry): void {\n assert(undefined !== this._request);\n assert(undefined === this._current);\n assert(undefined === this._next);\n\n this._current = entry;\n this._request.promise.then((completed: boolean) => { // eslint-disable-line @typescript-eslint/no-floating-promises\n if (this._disposed)\n return;\n\n // Invoke all the functions which were awaiting this set of IModelConnection.Categories.\n assert(undefined !== this._current);\n if (completed)\n for (const func of this._current.funcs)\n func(true);\n\n this._request = undefined;\n this._current = undefined;\n\n // If we have more requests, process them.\n const next = this._next;\n this._next = undefined;\n if (undefined !== next) {\n this._request = cache.load(next.categoryIds);\n if (undefined === this._request) {\n // All categories loaded.\n for (const func of next.funcs)\n func(true);\n } else {\n // We need to load the requested categories before invoking the pending functions.\n this.processCurrent(cache, next);\n }\n }\n });\n }\n\n private pushNext(categoryIds: Id64Arg, func: QueueFunc): void {\n assert(undefined !== this._current);\n assert(undefined !== this._request);\n\n if (undefined === this._next) {\n // We have a request currently in process and none pending.\n // We could potentially determine that this request doesn't require any categories that are not already loaded or being loaded by the current request.\n // But we will find that out (synchronously) when current request completes, unless more requests come in. Probably not worth it.\n this._next = new QueueEntry(Id64.toIdSet(categoryIds, true), func);\n } else {\n // We have a request currently in process, and one or more pending. Append this one to the pending.\n this._next.funcs.push(func);\n for (const categoryId of Id64.iterable(categoryIds))\n this._next.categoryIds.add(categoryId);\n }\n }\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"BriefcaseConnection.d.ts","sourceRoot":"","sources":["../../src/BriefcaseConnection.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAU,OAAO,EAA2B,UAAU,EAAE,UAAU,EAAgB,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/H,OAAO,EACL,cAAc,EAAE,mBAAmB,EAA4B,qBAAqB,EACpC,kBAAkB,EAAE,qBAAqB,EAC1F,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAKtD;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACnC,wBAAwB;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,2CAA2C;IAC3C,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,QAAQ,EAAE,oBAAoB,KAAK,IAAI,CAAC;AAE1E;;;;GAI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AAC;IAO9F;;OAEG;WACiB,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,GAAE,QAA6B,EAAE,IAAI,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAOzJ,2DAA2D;IAC3D,IAAW,QAAQ,IAAI,OAAO,CAAoC;IAElE;;;OAGG;IACU,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAanC,SAAS,CAAC,eAAe;IAKzB,2FAA2F;IAC9E,cAAc,IAAI,OAAO,CAAC,OAAO,CAAC;IAI/C;;OAEG;IACU,WAAW,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI7D,iDAAiD;IACpC,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;IAI5C;;;;OAIG;IACU,WAAW,CAAC,OAAO,CAAC,EAAE,cAAc,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;IAmC/F;;;;OAIG;IACU,WAAW,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAK3E;;OAEG;IACH,IAAW,YAAY,IAAI,qBAAqB,GAAG,SAAS,CAE3D;IAED;;;OAGG;IACU,wBAAwB,IAAI,OAAO,CAAC,OAAO,CAAC;IAIzD;;;;;OAKG;IACU,iBAAiB,IAAI,OAAO,CAAC,qBAAqB,CAAC;IAIhE;;OAEG;IACH,SAAgB,sBAAsB,4BAAiC,GAAG,CAAC,MAAM,CAAC,KAAK,IAAI,EAAI;CAChG"}
@@ -189,6 +189,7 @@ export class BriefcaseConnection extends IModelConnection {
189
189
  this._modelsMonitor = new ModelChangeMonitor(this);
190
190
  if (OpenMode.ReadWrite === this._openMode)
191
191
  this.txns.onAfterUndoRedo.addListener(async () => { await IModelApp.toolAdmin.restartPrimitiveTool(); });
192
+ this.categories.cache.attachToBriefcase(this);
192
193
  }
193
194
  /** Open a BriefcaseConnection to a [BriefcaseDb]($backend). */
194
195
  static async openFile(briefcaseProps) {
@@ -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,EAAE,OAAO,EAAE,iBAAiB,EAAE,IAAI,EAA0B,YAAY,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/H,OAAO,EACgC,wBAAwB,EAAyB,WAAW,GAElG,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,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,C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;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":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module IModelConnection\n */\n\nimport { assert, BeEvent, CompressedId64Set, Guid, GuidString, Id64String, IModelStatus, OpenMode } from \"@itwin/core-bentley\";\nimport {\n ChangesetIndex, ChangesetIndexAndId, getPullChangesIpcChannel, IModelConnectionProps, IModelError,\n PullChangesOptions as IpcAppPullChangesOptions, OpenBriefcaseProps, StandaloneOpenOptions,\n} from \"@itwin/core-common\";\nimport { BriefcaseTxns } from \"./BriefcaseTxns\";\nimport { GraphicalEditingScope } from \"./GraphicalEditingScope\";\nimport { IModelApp } from \"./IModelApp\";\nimport { IModelConnection } from \"./IModelConnection\";\nimport { IpcApp } from \"./IpcApp\";\nimport { disposeTileTreesForGeometricModels } from \"./tile/internal\";\nimport { Viewport } from \"./Viewport\";\n\n/**\n * Download progress information.\n * @public\n */\nexport interface DownloadProgressInfo {\n /** Bytes downloaded. */\n loaded: number;\n /** Total size of the download in bytes. */\n total: number;\n}\n\n/**\n * Called to show progress during a download.\n * @public\n */\nexport type OnDownloadProgress = (progress: DownloadProgressInfo) => void;\n\n/**\n * Partial interface of AbortSignal.\n * @see https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal\n * @beta\n */\nexport interface GenericAbortSignal {\n /** Add Listener for abort signal. */\n addEventListener: (type: \"abort\", listener: (this: GenericAbortSignal, ev: any) => any) => void;\n /** Remove Listener for abort signal. */\n removeEventListener: (type: \"abort\", listener: (this: GenericAbortSignal, ev: any) => any) => void;\n}\n\n/**\n * Options for pulling iModel changes.\n * @public\n */\nexport interface PullChangesOptions {\n /** Function called regularly to report progress of changes download. */\n downloadProgressCallback?: OnDownloadProgress;\n /** Interval for calling progress callback (in milliseconds). */\n progressInterval?: number;\n /** Signal for cancelling the download.\n * @beta\n */\n abortSignal?: GenericAbortSignal;\n}\n\n/** Keeps track of changes to models, buffering them until synchronization points.\n * While a GraphicalEditingScope is open, the changes are buffered until the scope exits, at which point they are processed.\n * Otherwise, the buffered changes are processed after undo/redo, commit, or pull+merge changes.\n */\nclass ModelChangeMonitor {\n private _editingScope?: GraphicalEditingScope;\n private readonly _briefcase: BriefcaseConnection;\n private readonly _deletedModels = new Set<string>();\n private readonly _modelIdToGuid = new Map<string, string>();\n private readonly _removals: VoidFunction[] = [];\n\n public constructor(briefcase: BriefcaseConnection) {\n this._briefcase = briefcase;\n\n // Buffer updated geometry guids.\n this._removals.push(briefcase.txns.onModelGeometryChanged.addListener((changes) => {\n for (const change of changes) {\n this._deletedModels.delete(change.id);\n this._modelIdToGuid.set(change.id, change.guid);\n }\n }));\n\n // Buffer deletions of models.\n this._removals.push(briefcase.txns.onModelsChanged.addListener((changes) => {\n if (changes.deleted) {\n for (const id of CompressedId64Set.iterable(changes.deleted)) {\n this._modelIdToGuid.delete(id);\n this._deletedModels.add(id);\n }\n }\n }));\n\n // Outside of an editing scope, we want to update viewport contents after commit, undo/redo, or merging changes.\n const maybeProcess = async () => {\n if (this.editingScope)\n return;\n\n const modelIds = Array.from(this._modelIdToGuid.keys());\n if (modelIds.length > 0)\n await IModelApp.tileAdmin.purgeTileTrees(this._briefcase, modelIds);\n\n this.processBuffered();\n };\n\n this._removals.push(briefcase.txns.onCommitted.addListener(maybeProcess));\n this._removals.push(briefcase.txns.onReplayedExternalTxns.addListener(maybeProcess));\n this._removals.push(briefcase.txns.onAfterUndoRedo.addListener(maybeProcess));\n this._removals.push(briefcase.txns.onChangesPulled.addListener(maybeProcess));\n }\n\n public async close(): Promise<void> {\n for (const removal of this._removals)\n removal();\n\n this._removals.length = 0;\n\n if (this._editingScope) {\n await this._editingScope.exit();\n this._editingScope = undefined;\n }\n }\n\n public get editingScope(): GraphicalEditingScope | undefined {\n return this._editingScope;\n }\n\n public async enterEditingScope(): Promise<GraphicalEditingScope> {\n if (this._editingScope)\n throw new Error(\"Cannot create an editing scope for an iModel that already has one\");\n\n this._editingScope = await GraphicalEditingScope.enter(this._briefcase);\n\n const removeGeomListener = this._editingScope.onGeometryChanges.addListener((changes) => {\n const modelIds = [];\n for (const change of changes)\n modelIds.push(change.id);\n\n this.invalidateScenes(modelIds);\n });\n\n this._editingScope.onExited.addOnce((scope) => {\n assert(scope === this._editingScope);\n this._editingScope = undefined;\n removeGeomListener();\n this.processBuffered();\n });\n\n return this._editingScope;\n }\n\n private processBuffered(): void {\n const models = this._briefcase.models;\n for (const [id, guid] of this._modelIdToGuid) {\n const model = models.getLoaded(id)?.asGeometricModel;\n if (model)\n model.geometryGuid = guid;\n }\n\n const modelIds = new Set<string>(this._modelIdToGuid.keys());\n for (const deleted of this._deletedModels) {\n modelIds.add(deleted);\n models.unload(deleted);\n }\n\n this.invalidateScenes(modelIds);\n disposeTileTreesForGeometricModels(modelIds, this._briefcase);\n\n this._briefcase.onBufferedModelChanges.raiseEvent(modelIds);\n\n this._modelIdToGuid.clear();\n this._deletedModels.clear();\n }\n\n private invalidateScenes(changedModels: Iterable<Id64String>): void {\n for (const user of IModelApp.tileAdmin.tileUsers) {\n if (user instanceof Viewport && user.iModel === this._briefcase) {\n for (const modelId of changedModels) {\n if (user.view.viewsModel(modelId)) {\n user.invalidateScene();\n user.setFeatureOverrideProviderChanged();\n break;\n }\n }\n }\n }\n }\n}\n\n/** Settings that can be used to control the behavior of [[Tool]]s that modify a [[BriefcaseConnection]].\n * For example, tools that want to create new elements can consult the briefcase's editor tool settings to\n * determine into which model and category to insert the elements.\n * Specialized tools are free to ignore these settings.\n * @see [[BriefcaseConnection.editorToolSettings]] to query or modify the current settings for a briefcase.\n * @see [CreateElementTool]($editor-frontend) for an example of a tool that uses these settings.\n * @beta\n */\nexport class BriefcaseEditorToolSettings {\n private _category?: Id64String;\n private _model?: Id64String;\n\n /** An event raised just after the default [[category]] is changed. */\n public readonly onCategoryChanged = new BeEvent<(previousCategory: Id64String | undefined) => void>();\n\n /** An event raised just after the default [[model]] is changed. */\n public readonly onModelChanged = new BeEvent<(previousModel: Id64String | undefined) => void>();\n\n /** The [Category]($backend) into which new elements should be inserted by default.\n * Specialized tools are free to ignore this setting and instead use their own logic to select an appropriate category.\n * @see [[onCategoryChanged]] to be notified when this property is modified.\n * @see [CreateElementTool.targetCategory]($editor-frontend) for an example of a tool that uses this setting.\n */\n public get category(): Id64String | undefined {\n return this._category;\n }\n public set category(category: Id64String | undefined) {\n const previousCategory = this.category;\n if (category !== this.category) {\n this._category = category;\n this.onCategoryChanged.raiseEvent(previousCategory);\n }\n }\n\n /** The [Model]($backend) into which new elements should be inserted by default.\n * Specialized tools are free to ignore this setting and instead use their own logic to select an appropriate model.\n * @see [[onModelChanged]] to be notified when this property is modified.\n * @see [CreateElementTool.targetModelId]($editor-frontend) for an example of a tool that uses this setting.\n */\n public get model(): Id64String | undefined {\n return this._model;\n }\n public set model(model: Id64String | undefined) {\n const previousModel = this.model;\n if (model !== this.model) {\n this._model = model;\n this.onModelChanged.raiseEvent(previousModel);\n }\n }\n}\n\n/** A connection to an editable briefcase on the backend. This class uses [Ipc]($docs/learning/IpcInterface.md) to communicate\n * to the backend and may only be used by [[IpcApp]]s.\n * @public\n */\nexport class BriefcaseConnection extends IModelConnection {\n protected _isClosed?: boolean;\n private readonly _modelsMonitor: ModelChangeMonitor;\n /** Default settings that can be used to control the behavior of [[Tool]]s that modify this briefcase.\n * @beta\n */\n public readonly editorToolSettings = new BriefcaseEditorToolSettings();\n\n /** Manages local changes to the briefcase via [Txns]($docs/learning/InteractiveEditing.md). */\n public readonly txns: BriefcaseTxns;\n\n public override isBriefcaseConnection(): this is BriefcaseConnection { return true; }\n\n /** The Guid that identifies the iTwin that owns this iModel. */\n public override get iTwinId(): GuidString { return super.iTwinId ?? Guid.empty; } // GuidString | undefined for IModelConnection, but required for BriefcaseConnection\n\n /** The Guid that identifies this iModel. */\n public override get iModelId(): GuidString { return super.iModelId ?? Guid.empty; } // GuidString | undefined for IModelConnection, but required for BriefcaseConnection\n\n protected constructor(props: IModelConnectionProps, openMode: OpenMode) {\n super(props);\n this._openMode = openMode;\n this.txns = new BriefcaseTxns(this);\n this._modelsMonitor = new ModelChangeMonitor(this);\n if (OpenMode.ReadWrite === this._openMode)\n this.txns.onAfterUndoRedo.addListener(async () => { await IModelApp.toolAdmin.restartPrimitiveTool(); });\n }\n\n /** Open a BriefcaseConnection to a [BriefcaseDb]($backend). */\n public static async openFile(briefcaseProps: OpenBriefcaseProps): Promise<BriefcaseConnection> {\n const iModelProps = await IpcApp.appFunctionIpc.openBriefcase(briefcaseProps);\n const connection = new this({ ...briefcaseProps, ...iModelProps }, briefcaseProps.readonly ? OpenMode.Readonly : OpenMode.ReadWrite);\n IModelConnection.onOpen.raiseEvent(connection);\n return connection;\n }\n\n /** Open a BriefcaseConnection to a [StandaloneDb]($backend)\n * @note StandaloneDbs, by definition, may not push or pull changes. Attempting to do so will throw exceptions.\n */\n public static async openStandalone(filePath: string, openMode: OpenMode = OpenMode.ReadWrite, opts?: StandaloneOpenOptions): Promise<BriefcaseConnection> {\n const openResponse = await IpcApp.appFunctionIpc.openStandalone(filePath, openMode, opts);\n const connection = new this(openResponse, openMode);\n IModelConnection.onOpen.raiseEvent(connection);\n return connection;\n }\n\n /** Returns `true` if [[close]] has already been called. */\n public get isClosed(): boolean { return this._isClosed === true; }\n\n /**\n * Close this BriefcaseConnection.\n * @note make sure to call [[saveChanges]] before calling this method. Unsaved local changes are abandoned.\n */\n public async close(): Promise<void> {\n if (this.isClosed)\n return;\n\n await this._modelsMonitor.close();\n\n this.beforeClose();\n this.txns[Symbol.dispose]();\n\n this._isClosed = true;\n await IpcApp.appFunctionIpc.closeIModel(this._fileKey);\n }\n\n protected requireTimeline() {\n if (this.iTwinId === Guid.empty)\n throw new IModelError(IModelStatus.WrongIModel, \"iModel has no timeline\");\n }\n\n /** Query if there are any pending Txns in this briefcase that are waiting to be pushed. */\n public async hasPendingTxns(): Promise<boolean> { // eslint-disable-line @itwin/prefer-get\n return this.txns.hasPendingTxns();\n }\n\n /** Commit pending changes to this briefcase.\n * @param description Optional description of the changes.\n */\n public async saveChanges(description?: string): Promise<void> {\n await IpcApp.appFunctionIpc.saveChanges(this.key, description);\n }\n\n /** Abandon pending changes to this briefcase. */\n public async abandonChanges(): Promise<void> {\n await IpcApp.appFunctionIpc.abandonChanges(this.key);\n }\n\n /** Pull (and potentially merge if there are local changes) up to a specified changeset from iModelHub into this briefcase\n * @param toIndex The changeset index to pull changes to. If `undefined`, pull all changes.\n * @param options Options for pulling changes.\n * @see [[BriefcaseTxns.onChangesPulled]] for the event dispatched after changes are pulled.\n */\n public async pullChanges(toIndex?: ChangesetIndex, options?: PullChangesOptions): Promise<void> {\n const removeListeners: VoidFunction[] = [];\n const shouldReportProgress = !!options?.downloadProgressCallback;\n\n if (shouldReportProgress) {\n const handleProgress = (_evt: Event, data: { loaded: number, total: number }) => {\n options?.downloadProgressCallback?.(data);\n };\n\n const removeProgressListener = IpcApp.addListener(\n getPullChangesIpcChannel(this.iModelId),\n handleProgress,\n );\n removeListeners.push(removeProgressListener);\n }\n\n if (options?.abortSignal) {\n const abort = () => void IpcApp.appFunctionIpc.cancelPullChangesRequest(this.key);\n options?.abortSignal.addEventListener(\"abort\", abort);\n removeListeners.push(() => options?.abortSignal?.removeEventListener(\"abort\", abort));\n }\n\n this.requireTimeline();\n const ipcAppOptions: IpcAppPullChangesOptions = {\n reportProgress: shouldReportProgress,\n progressInterval: options?.progressInterval,\n enableCancellation: !!options?.abortSignal,\n };\n try {\n this.changeset = await IpcApp.appFunctionIpc.pullChanges(this.key, toIndex, ipcAppOptions);\n } finally {\n removeListeners.forEach((remove) => remove());\n }\n }\n\n /** Create a changeset from local Txns and push to iModelHub. On success, clear Txn table.\n * @param description The description for the changeset\n * @returns the changesetId of the pushed changes\n * @see [[BriefcaseTxns.onChangesPushed]] for the event dispatched after changes are pushed.\n */\n public async pushChanges(description: string): Promise<ChangesetIndexAndId> {\n this.requireTimeline();\n return IpcApp.appFunctionIpc.pushChanges(this.key, description);\n }\n\n /** The current graphical editing scope, if one is in progress.\n * @see [[enterEditingScope]] to begin graphical editing.\n */\n public get editingScope(): GraphicalEditingScope | undefined {\n return this._modelsMonitor.editingScope;\n }\n\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\n * the BisCore ECSchema older than v0.1.11.\n * @see [[enterEditingScope]] to enable graphical editing.\n */\n public async supportsGraphicalEditing(): Promise<boolean> {\n return IpcApp.appFunctionIpc.isGraphicalEditingSupported(this.key);\n }\n\n /** Begin a new graphical editing scope.\n * @throws Error if an editing scope already exists or one could not be created.\n * @see [[GraphicalEditingScope.exit]] to exit the scope.\n * @see [[supportsGraphicalEditing]] to determine whether this method should be expected to succeed.\n * @see [[editingScope]] to obtain the current editing scope, if one is in progress.\n */\n public async enterEditingScope(): Promise<GraphicalEditingScope> {\n return this._modelsMonitor.enterEditingScope();\n }\n\n /** Strictly for tests - dispatched from ModelChangeMonitor.processBuffered.\n * @internal\n */\n public readonly onBufferedModelChanges = new BeEvent<(changedModelIds: Set<string>) => void>();\n}\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,EAA0B,YAAY,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/H,OAAO,EACgC,wBAAwB,EAAyB,WAAW,GAElG,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;IACn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,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":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module IModelConnection\n */\n\nimport { assert, BeEvent, CompressedId64Set, Guid, GuidString, Id64String, IModelStatus, OpenMode } from \"@itwin/core-bentley\";\nimport {\n ChangesetIndex, ChangesetIndexAndId, getPullChangesIpcChannel, IModelConnectionProps, IModelError,\n PullChangesOptions as IpcAppPullChangesOptions, OpenBriefcaseProps, StandaloneOpenOptions,\n} from \"@itwin/core-common\";\nimport { BriefcaseTxns } from \"./BriefcaseTxns\";\nimport { GraphicalEditingScope } from \"./GraphicalEditingScope\";\nimport { IModelApp } from \"./IModelApp\";\nimport { IModelConnection } from \"./IModelConnection\";\nimport { IpcApp } from \"./IpcApp\";\nimport { disposeTileTreesForGeometricModels } from \"./tile/internal\";\nimport { Viewport } from \"./Viewport\";\n\n/**\n * Download progress information.\n * @public\n */\nexport interface DownloadProgressInfo {\n /** Bytes downloaded. */\n loaded: number;\n /** Total size of the download in bytes. */\n total: number;\n}\n\n/**\n * Called to show progress during a download.\n * @public\n */\nexport type OnDownloadProgress = (progress: DownloadProgressInfo) => void;\n\n/**\n * Partial interface of AbortSignal.\n * @see https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal\n * @beta\n */\nexport interface GenericAbortSignal {\n /** Add Listener for abort signal. */\n addEventListener: (type: \"abort\", listener: (this: GenericAbortSignal, ev: any) => any) => void;\n /** Remove Listener for abort signal. */\n removeEventListener: (type: \"abort\", listener: (this: GenericAbortSignal, ev: any) => any) => void;\n}\n\n/**\n * Options for pulling iModel changes.\n * @public\n */\nexport interface PullChangesOptions {\n /** Function called regularly to report progress of changes download. */\n downloadProgressCallback?: OnDownloadProgress;\n /** Interval for calling progress callback (in milliseconds). */\n progressInterval?: number;\n /** Signal for cancelling the download.\n * @beta\n */\n abortSignal?: GenericAbortSignal;\n}\n\n/** Keeps track of changes to models, buffering them until synchronization points.\n * While a GraphicalEditingScope is open, the changes are buffered until the scope exits, at which point they are processed.\n * Otherwise, the buffered changes are processed after undo/redo, commit, or pull+merge changes.\n */\nclass ModelChangeMonitor {\n private _editingScope?: GraphicalEditingScope;\n private readonly _briefcase: BriefcaseConnection;\n private readonly _deletedModels = new Set<string>();\n private readonly _modelIdToGuid = new Map<string, string>();\n private readonly _removals: VoidFunction[] = [];\n\n public constructor(briefcase: BriefcaseConnection) {\n this._briefcase = briefcase;\n\n // Buffer updated geometry guids.\n this._removals.push(briefcase.txns.onModelGeometryChanged.addListener((changes) => {\n for (const change of changes) {\n this._deletedModels.delete(change.id);\n this._modelIdToGuid.set(change.id, change.guid);\n }\n }));\n\n // Buffer deletions of models.\n this._removals.push(briefcase.txns.onModelsChanged.addListener((changes) => {\n if (changes.deleted) {\n for (const id of CompressedId64Set.iterable(changes.deleted)) {\n this._modelIdToGuid.delete(id);\n this._deletedModels.add(id);\n }\n }\n }));\n\n // Outside of an editing scope, we want to update viewport contents after commit, undo/redo, or merging changes.\n const maybeProcess = async () => {\n if (this.editingScope)\n return;\n\n const modelIds = Array.from(this._modelIdToGuid.keys());\n if (modelIds.length > 0)\n await IModelApp.tileAdmin.purgeTileTrees(this._briefcase, modelIds);\n\n this.processBuffered();\n };\n\n this._removals.push(briefcase.txns.onCommitted.addListener(maybeProcess));\n this._removals.push(briefcase.txns.onReplayedExternalTxns.addListener(maybeProcess));\n this._removals.push(briefcase.txns.onAfterUndoRedo.addListener(maybeProcess));\n this._removals.push(briefcase.txns.onChangesPulled.addListener(maybeProcess));\n }\n\n public async close(): Promise<void> {\n for (const removal of this._removals)\n removal();\n\n this._removals.length = 0;\n\n if (this._editingScope) {\n await this._editingScope.exit();\n this._editingScope = undefined;\n }\n }\n\n public get editingScope(): GraphicalEditingScope | undefined {\n return this._editingScope;\n }\n\n public async enterEditingScope(): Promise<GraphicalEditingScope> {\n if (this._editingScope)\n throw new Error(\"Cannot create an editing scope for an iModel that already has one\");\n\n this._editingScope = await GraphicalEditingScope.enter(this._briefcase);\n\n const removeGeomListener = this._editingScope.onGeometryChanges.addListener((changes) => {\n const modelIds = [];\n for (const change of changes)\n modelIds.push(change.id);\n\n this.invalidateScenes(modelIds);\n });\n\n this._editingScope.onExited.addOnce((scope) => {\n assert(scope === this._editingScope);\n this._editingScope = undefined;\n removeGeomListener();\n this.processBuffered();\n });\n\n return this._editingScope;\n }\n\n private processBuffered(): void {\n const models = this._briefcase.models;\n for (const [id, guid] of this._modelIdToGuid) {\n const model = models.getLoaded(id)?.asGeometricModel;\n if (model)\n model.geometryGuid = guid;\n }\n\n const modelIds = new Set<string>(this._modelIdToGuid.keys());\n for (const deleted of this._deletedModels) {\n modelIds.add(deleted);\n models.unload(deleted);\n }\n\n this.invalidateScenes(modelIds);\n disposeTileTreesForGeometricModels(modelIds, this._briefcase);\n\n this._briefcase.onBufferedModelChanges.raiseEvent(modelIds);\n\n this._modelIdToGuid.clear();\n this._deletedModels.clear();\n }\n\n private invalidateScenes(changedModels: Iterable<Id64String>): void {\n for (const user of IModelApp.tileAdmin.tileUsers) {\n if (user instanceof Viewport && user.iModel === this._briefcase) {\n for (const modelId of changedModels) {\n if (user.view.viewsModel(modelId)) {\n user.invalidateScene();\n user.setFeatureOverrideProviderChanged();\n break;\n }\n }\n }\n }\n }\n}\n\n/** Settings that can be used to control the behavior of [[Tool]]s that modify a [[BriefcaseConnection]].\n * For example, tools that want to create new elements can consult the briefcase's editor tool settings to\n * determine into which model and category to insert the elements.\n * Specialized tools are free to ignore these settings.\n * @see [[BriefcaseConnection.editorToolSettings]] to query or modify the current settings for a briefcase.\n * @see [CreateElementTool]($editor-frontend) for an example of a tool that uses these settings.\n * @beta\n */\nexport class BriefcaseEditorToolSettings {\n private _category?: Id64String;\n private _model?: Id64String;\n\n /** An event raised just after the default [[category]] is changed. */\n public readonly onCategoryChanged = new BeEvent<(previousCategory: Id64String | undefined) => void>();\n\n /** An event raised just after the default [[model]] is changed. */\n public readonly onModelChanged = new BeEvent<(previousModel: Id64String | undefined) => void>();\n\n /** The [Category]($backend) into which new elements should be inserted by default.\n * Specialized tools are free to ignore this setting and instead use their own logic to select an appropriate category.\n * @see [[onCategoryChanged]] to be notified when this property is modified.\n * @see [CreateElementTool.targetCategory]($editor-frontend) for an example of a tool that uses this setting.\n */\n public get category(): Id64String | undefined {\n return this._category;\n }\n public set category(category: Id64String | undefined) {\n const previousCategory = this.category;\n if (category !== this.category) {\n this._category = category;\n this.onCategoryChanged.raiseEvent(previousCategory);\n }\n }\n\n /** The [Model]($backend) into which new elements should be inserted by default.\n * Specialized tools are free to ignore this setting and instead use their own logic to select an appropriate model.\n * @see [[onModelChanged]] to be notified when this property is modified.\n * @see [CreateElementTool.targetModelId]($editor-frontend) for an example of a tool that uses this setting.\n */\n public get model(): Id64String | undefined {\n return this._model;\n }\n public set model(model: Id64String | undefined) {\n const previousModel = this.model;\n if (model !== this.model) {\n this._model = model;\n this.onModelChanged.raiseEvent(previousModel);\n }\n }\n}\n\n/** A connection to an editable briefcase on the backend. This class uses [Ipc]($docs/learning/IpcInterface.md) to communicate\n * to the backend and may only be used by [[IpcApp]]s.\n * @public\n */\nexport class BriefcaseConnection extends IModelConnection {\n protected _isClosed?: boolean;\n private readonly _modelsMonitor: ModelChangeMonitor;\n /** Default settings that can be used to control the behavior of [[Tool]]s that modify this briefcase.\n * @beta\n */\n public readonly editorToolSettings = new BriefcaseEditorToolSettings();\n\n /** Manages local changes to the briefcase via [Txns]($docs/learning/InteractiveEditing.md). */\n public readonly txns: BriefcaseTxns;\n\n public override isBriefcaseConnection(): this is BriefcaseConnection { return true; }\n\n /** The Guid that identifies the iTwin that owns this iModel. */\n public override get iTwinId(): GuidString { return super.iTwinId ?? Guid.empty; } // GuidString | undefined for IModelConnection, but required for BriefcaseConnection\n\n /** The Guid that identifies this iModel. */\n public override get iModelId(): GuidString { return super.iModelId ?? Guid.empty; } // GuidString | undefined for IModelConnection, but required for BriefcaseConnection\n\n protected constructor(props: IModelConnectionProps, openMode: OpenMode) {\n super(props);\n this._openMode = openMode;\n this.txns = new BriefcaseTxns(this);\n this._modelsMonitor = new ModelChangeMonitor(this);\n if (OpenMode.ReadWrite === this._openMode)\n this.txns.onAfterUndoRedo.addListener(async () => { await IModelApp.toolAdmin.restartPrimitiveTool(); });\n\n this.categories.cache.attachToBriefcase(this);\n }\n\n /** Open a BriefcaseConnection to a [BriefcaseDb]($backend). */\n public static async openFile(briefcaseProps: OpenBriefcaseProps): Promise<BriefcaseConnection> {\n const iModelProps = await IpcApp.appFunctionIpc.openBriefcase(briefcaseProps);\n const connection = new this({ ...briefcaseProps, ...iModelProps }, briefcaseProps.readonly ? OpenMode.Readonly : OpenMode.ReadWrite);\n IModelConnection.onOpen.raiseEvent(connection);\n return connection;\n }\n\n /** Open a BriefcaseConnection to a [StandaloneDb]($backend)\n * @note StandaloneDbs, by definition, may not push or pull changes. Attempting to do so will throw exceptions.\n */\n public static async openStandalone(filePath: string, openMode: OpenMode = OpenMode.ReadWrite, opts?: StandaloneOpenOptions): Promise<BriefcaseConnection> {\n const openResponse = await IpcApp.appFunctionIpc.openStandalone(filePath, openMode, opts);\n const connection = new this(openResponse, openMode);\n IModelConnection.onOpen.raiseEvent(connection);\n return connection;\n }\n\n /** Returns `true` if [[close]] has already been called. */\n public get isClosed(): boolean { return this._isClosed === true; }\n\n /**\n * Close this BriefcaseConnection.\n * @note make sure to call [[saveChanges]] before calling this method. Unsaved local changes are abandoned.\n */\n public async close(): Promise<void> {\n if (this.isClosed)\n return;\n\n await this._modelsMonitor.close();\n\n this.beforeClose();\n this.txns[Symbol.dispose]();\n\n this._isClosed = true;\n await IpcApp.appFunctionIpc.closeIModel(this._fileKey);\n }\n\n protected requireTimeline() {\n if (this.iTwinId === Guid.empty)\n throw new IModelError(IModelStatus.WrongIModel, \"iModel has no timeline\");\n }\n\n /** Query if there are any pending Txns in this briefcase that are waiting to be pushed. */\n public async hasPendingTxns(): Promise<boolean> { // eslint-disable-line @itwin/prefer-get\n return this.txns.hasPendingTxns();\n }\n\n /** Commit pending changes to this briefcase.\n * @param description Optional description of the changes.\n */\n public async saveChanges(description?: string): Promise<void> {\n await IpcApp.appFunctionIpc.saveChanges(this.key, description);\n }\n\n /** Abandon pending changes to this briefcase. */\n public async abandonChanges(): Promise<void> {\n await IpcApp.appFunctionIpc.abandonChanges(this.key);\n }\n\n /** Pull (and potentially merge if there are local changes) up to a specified changeset from iModelHub into this briefcase\n * @param toIndex The changeset index to pull changes to. If `undefined`, pull all changes.\n * @param options Options for pulling changes.\n * @see [[BriefcaseTxns.onChangesPulled]] for the event dispatched after changes are pulled.\n */\n public async pullChanges(toIndex?: ChangesetIndex, options?: PullChangesOptions): Promise<void> {\n const removeListeners: VoidFunction[] = [];\n const shouldReportProgress = !!options?.downloadProgressCallback;\n\n if (shouldReportProgress) {\n const handleProgress = (_evt: Event, data: { loaded: number, total: number }) => {\n options?.downloadProgressCallback?.(data);\n };\n\n const removeProgressListener = IpcApp.addListener(\n getPullChangesIpcChannel(this.iModelId),\n handleProgress,\n );\n removeListeners.push(removeProgressListener);\n }\n\n if (options?.abortSignal) {\n const abort = () => void IpcApp.appFunctionIpc.cancelPullChangesRequest(this.key);\n options?.abortSignal.addEventListener(\"abort\", abort);\n removeListeners.push(() => options?.abortSignal?.removeEventListener(\"abort\", abort));\n }\n\n this.requireTimeline();\n const ipcAppOptions: IpcAppPullChangesOptions = {\n reportProgress: shouldReportProgress,\n progressInterval: options?.progressInterval,\n enableCancellation: !!options?.abortSignal,\n };\n try {\n this.changeset = await IpcApp.appFunctionIpc.pullChanges(this.key, toIndex, ipcAppOptions);\n } finally {\n removeListeners.forEach((remove) => remove());\n }\n }\n\n /** Create a changeset from local Txns and push to iModelHub. On success, clear Txn table.\n * @param description The description for the changeset\n * @returns the changesetId of the pushed changes\n * @see [[BriefcaseTxns.onChangesPushed]] for the event dispatched after changes are pushed.\n */\n public async pushChanges(description: string): Promise<ChangesetIndexAndId> {\n this.requireTimeline();\n return IpcApp.appFunctionIpc.pushChanges(this.key, description);\n }\n\n /** The current graphical editing scope, if one is in progress.\n * @see [[enterEditingScope]] to begin graphical editing.\n */\n public get editingScope(): GraphicalEditingScope | undefined {\n return this._modelsMonitor.editingScope;\n }\n\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\n * the BisCore ECSchema older than v0.1.11.\n * @see [[enterEditingScope]] to enable graphical editing.\n */\n public async supportsGraphicalEditing(): Promise<boolean> {\n return IpcApp.appFunctionIpc.isGraphicalEditingSupported(this.key);\n }\n\n /** Begin a new graphical editing scope.\n * @throws Error if an editing scope already exists or one could not be created.\n * @see [[GraphicalEditingScope.exit]] to exit the scope.\n * @see [[supportsGraphicalEditing]] to determine whether this method should be expected to succeed.\n * @see [[editingScope]] to obtain the current editing scope, if one is in progress.\n */\n public async enterEditingScope(): Promise<GraphicalEditingScope> {\n return this._modelsMonitor.enterEditingScope();\n }\n\n /** Strictly for tests - dispatched from ModelChangeMonitor.processBuffered.\n * @internal\n */\n public readonly onBufferedModelChanges = new BeEvent<(changedModelIds: Set<string>) => void>();\n}\n"]}
@@ -24,6 +24,7 @@ export declare class SubCategoriesCache {
24
24
  private readonly _imodel;
25
25
  private _missingAtTimeOfPreload;
26
26
  constructor(imodel: IModelConnection);
27
+ attachToBriefcase(imodel: IModelConnection): void;
27
28
  /** Get the Ids of all subcategories belonging to the category with the specified Id, or undefined if no such information is present. */
28
29
  getSubCategories(categoryId: string): Id64Set | undefined;
29
30
  /** Get the base appearance of the subcategory with the specified Id, or undefined if no such information is present. */
@@ -1 +1 @@
1
- {"version":3,"file":"SubCategoriesCache.d.ts","sourceRoot":"","sources":["../../src/SubCategoriesCache.ts"],"names":[],"mappings":"AAKA,OAAO,EAAmC,OAAO,EAAE,OAAO,EAAE,UAAU,EAAuB,MAAM,qBAAqB,CAAC;AACzH,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AACjF,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACnC,8EAA8E;IAC9E,QAAQ,CAAC,kBAAkB,EAAE,OAAO,CAAC;IACrC;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IACnC,2BAA2B;IAC3B,MAAM,IAAI,IAAI,CAAC;CAChB;AAID;;GAEG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,QAAQ,CAAC,aAAa,CAA8B;IAC5D,OAAO,CAAC,QAAQ,CAAC,YAAY,CAA4C;IACzE,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAmB;IAC3C,OAAO,CAAC,uBAAuB,CAAsB;gBAElC,MAAM,EAAE,gBAAgB;IAE3C,wIAAwI;IACjI,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS;IAEhE,wHAAwH;IACjH,wBAAwB,CAAC,aAAa,EAAE,UAAU,GAAG,qBAAqB,GAAG,SAAS;IAE7F;;;;OAIG;IACI,IAAI,CAAC,WAAW,EAAE,OAAO,GAAG,oBAAoB,GAAG,SAAS;IAmBnE,kGAAkG;IACrF,+BAA+B,IAAI,OAAO,CAAC,IAAI,CAAC;IAW7D,+DAA+D;IAC/D,OAAO,CAAC,UAAU;IAcX,KAAK,IAAI,IAAI;IAKb,uBAAuB,IAAI,IAAI;IAItC,OAAO,CAAC,MAAM,CAAC,2BAA2B;IAQ1C,OAAO,CAAC,cAA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xD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAc;QACtC,OAAO,CAAC,SAAS,CAAS;QAC1B,OAAO,CAAC,oBAAoB,CAAK;QAEjC,IAAW,WAAW,YAAsD;oBAEzD,WAAW,EAAE,GAAG,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,gBAAgB,EAAE,qBAAqB,SAAO;QAY5F,MAAM;QAEA,QAAQ,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;KA2BrD;IAED,KAAY,SAAS,GAAG,CAAC,sBAAsB,EAAE,OAAO,KAAK,IAAI,CAAC;IAElE,MAAa,UAAU;QACrB,SAAgB,WAAW,EAAE,OAAO,CAAC;QACrC,SAAgB,KAAK,EAAE,SAAS,EAAE,CAAC;oBAEhB,WAAW,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS;KAIzD;IAED;;;;;OAKG;IACH,MAAa,KAAK;QAEhB,SAAS,CAAC,QAAQ,CAAC,EAAE,UAAU,CAAC;QAChC,SAAS,CAAC,KAAK,CAAC,EAAE,UAAU,CAAC;QAC7B,SAAS,CAAC,QAAQ,CAAC,EAAE,oBAAoB,CAAC;QAC1C,SAAS,CAAC,SAAS,UAAS;QAE5B;;WAEG;QACI,IAAI,CAAC,KAAK,EAAE,kBAAkB,EAAE,WAAW,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,GAAG,IAAI;QASnF,+CAA+C;QACxC,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI;QAW/B,IAAW,OAAO,IAAI,OAAO,CAE5B;QAED,OAAO,CAAC,WAAW;QAgBnB,OAAO,CAAC,cAAc;QAoCtB,OAAO,CAAC,QAAQ;KAgBjB;CACF"}
@@ -13,7 +13,46 @@ export class SubCategoriesCache {
13
13
  _appearances = new Map();
14
14
  _imodel;
15
15
  _missingAtTimeOfPreload;
16
- constructor(imodel) { this._imodel = imodel; }
16
+ constructor(imodel) {
17
+ this._imodel = imodel;
18
+ }
19
+ attachToBriefcase(imodel) {
20
+ // We want to do this in the constructor but can't, because IModelConnection.subcategories is initialized before
21
+ // BriefcaseConnection.txns.
22
+ assert(imodel === this._imodel);
23
+ assert(imodel.isBriefcaseConnection());
24
+ imodel.txns.onElementsChanged.addListener((changes) => {
25
+ const affectedSubCategories = new Set();
26
+ for (const change of changes) {
27
+ if (change.metadata.is("BisCore:Category")) {
28
+ if (change.type === "deleted") {
29
+ this._byCategoryId.delete(change.id);
30
+ }
31
+ }
32
+ else if (change.metadata.is("BisCore:SubCategory")) {
33
+ if (change.type === "inserted") {
34
+ // We don't know to which category the subcategory belongs. Blow away the entire cache.
35
+ this._byCategoryId.clear();
36
+ this._appearances.clear();
37
+ return;
38
+ }
39
+ this._appearances.delete(change.id);
40
+ affectedSubCategories.add(change.id);
41
+ }
42
+ }
43
+ if (affectedSubCategories.size > 0) {
44
+ for (const [catId, subCatIds] of this._byCategoryId) {
45
+ for (const subCatId of affectedSubCategories) {
46
+ if (subCatIds.has(subCatId)) {
47
+ this._byCategoryId.delete(catId);
48
+ affectedSubCategories.delete(subCatId);
49
+ break;
50
+ }
51
+ }
52
+ }
53
+ }
54
+ });
55
+ }
17
56
  /** Get the Ids of all subcategories belonging to the category with the specified Id, or undefined if no such information is present. */
18
57
  getSubCategories(categoryId) { return this._byCategoryId.get(categoryId); }
19
58
  /** Get the base appearance of the subcategory with the specified Id, or undefined if no such information is present. */
@@ -1 +1 @@
1
- {"version":3,"file":"SubCategoriesCache.js","sourceRoot":"","sources":["../../src/SubCategoriesCache.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,IAAI,EAAgC,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AACzH,OAAO,EAAE,qBAAqB,EAAwB,MAAM,oBAAoB,CAAC;AAkBjF,MAAM,sBAAsB,GAAG,IAAI,GAAG,EAAU,CAAC;AAEjD;;GAEG;AACH,MAAM,OAAO,kBAAkB;IACZ,aAAa,GAAG,IAAI,GAAG,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,CAAC,SAAS,KAAK,IAAI,CAAC,QAAQ,CAAC,CAAC;YAEpC,IAAI,SAAS,KAAK,IAAI,CAAC,KAAK,EAAE,CAAC;gBAC7B,2DAA2D;gBAC3D,sJAAsJ;gBACtJ,iIAAiI;gBACjI,IAAI,CAAC,KAAK,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC;YACrE,CAAC;iBAAM,CAAC;gBACN,mGAAmG;gBACnG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBAC5B,KAAK,MAAM,UAAU,IAAI,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC;oBACjD,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;YAC3C,CAAC;QACH,CAAC;KACF;IAvGY,wBAAK,QAuGjB,CAAA;AACH,CAAC,EAjLgB,kBAAkB,KAAlB,kBAAkB,QAiLlC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nimport { assert, CompressedId64Set, Id64, Id64Arg, Id64Set, Id64String, OrderedId64Iterable } from \"@itwin/core-bentley\";\nimport { SubCategoryAppearance, SubCategoryResultRow } from \"@itwin/core-common\";\nimport { IModelConnection } from \"./IModelConnection\";\n\n/** A cancelable paginated request for subcategory information.\n * @see SubCategoriesCache\n * @internal\n */\nexport interface SubCategoriesRequest {\n /** The Ids of any categories which were requested but were not yet loaded. */\n readonly missingCategoryIds: Id64Set;\n /** A promise which resolves to true when all of the requested categories have been loaded, or to false if not all categories were loaded.\n * Categories may fail to load if the request is explicitly canceled or if the IModelConnection is closed before all categories are loaded.\n */\n readonly promise: Promise<boolean>;\n /** Cancels the request. */\n cancel(): void;\n}\n\nconst invalidCategoryIdEntry = new Set<string>();\n\n/** A cache of information about the subcategories contained within an [[IModelConnection]]. It is populated on demand.\n * @internal\n */\nexport class SubCategoriesCache {\n private readonly _byCategoryId = new Map<string, Id64Set>();\n private readonly _appearances = new Map<string, SubCategoryAppearance>();\n private readonly _imodel: IModelConnection;\n private _missingAtTimeOfPreload: Id64Set | undefined;\n\n public constructor(imodel: IModelConnection) { this._imodel = imodel; }\n\n /** Get the Ids of all subcategories belonging to the category with the specified Id, or undefined if no such information is present. */\n public getSubCategories(categoryId: string): Id64Set | undefined { return this._byCategoryId.get(categoryId); }\n\n /** Get the base appearance of the subcategory with the specified Id, or undefined if no such information is present. */\n public getSubCategoryAppearance(subCategoryId: Id64String): SubCategoryAppearance | undefined { return this._appearances.get(subCategoryId.toString()); }\n\n /** Request that the subcategory information for all of the specified categories is loaded.\n * If all such information has already been loaded, returns undefined.\n * Otherwise, dispatches an asynchronous request to load those categories which are not already loaded and returns a cancellable request object\n * containing the corresponding promise and the set of categories still to be loaded.\n */\n public load(categoryIds: Id64Arg): SubCategoriesRequest | undefined {\n const missing = this.getMissing(categoryIds);\n if (undefined === missing)\n return undefined;\n\n const request = new SubCategoriesCache.Request(missing, this._imodel);\n const promise = request.dispatch().then((result?: SubCategoriesCache.Result) => {\n if (undefined !== result)\n this.processResults(result, missing);\n\n return !request.wasCanceled;\n });\n return {\n missingCategoryIds: missing,\n promise,\n cancel: () => request.cancel(),\n };\n }\n\n /** Load all subcategories that come from used spatial categories of the iModel into the cache. */\n public async loadAllUsedSpatialSubCategories(): Promise<void> {\n try {\n const results = await this._imodel.queryAllUsedSpatialSubCategories();\n if (undefined !== results) {\n this.processResults(results, new Set<string>(), false);\n }\n } catch {\n // In case of a truncated response, gracefully handle the error and exit.\n }\n\n }\n /** Given categoryIds, return which of these are not cached. */\n private getMissing(categoryIds: Id64Arg): Id64Set | undefined {\n let missing: Id64Set | undefined;\n for (const catId of Id64.iterable(categoryIds)) {\n if (undefined === this._byCategoryId.get(catId)) {\n if (undefined === missing)\n missing = new Set<string>();\n\n missing.add(catId);\n }\n }\n\n return missing;\n }\n\n public clear(): void {\n this._byCategoryId.clear();\n this._appearances.clear();\n }\n\n public onIModelConnectionClose(): void {\n this.clear();\n }\n\n private static createSubCategoryAppearance(json?: any) {\n let props: SubCategoryAppearance.Props | undefined;\n if (\"string\" === typeof json && 0 < json.length)\n props = JSON.parse(json);\n\n return new SubCategoryAppearance(props);\n }\n\n private processResults(result: SubCategoriesCache.Result, missing: Id64Set, override: boolean = true): void {\n for (const row of result) {\n this.add(row.parentId, row.id, SubCategoriesCache.createSubCategoryAppearance(row.appearance), override);\n }\n\n // Ensure that any category Ids which returned no results (e.g., non-existent category, invalid Id, etc) are still recorded so they are not repeatedly re-requested\n for (const id of missing)\n if (undefined === this._byCategoryId.get(id))\n this._byCategoryId.set(id, invalidCategoryIdEntry);\n }\n\n /** Exposed strictly for tests.\n * @internal\n */\n public add(categoryId: string, subCategoryId: string, appearance: SubCategoryAppearance, override: boolean) {\n let set = this._byCategoryId.get(categoryId);\n if (undefined === set)\n this._byCategoryId.set(categoryId, set = new Set<string>());\n\n set.add(subCategoryId);\n if (override || !this._appearances.has(subCategoryId))\n this._appearances.set(subCategoryId, appearance);\n }\n\n public async getCategoryInfo(inputCategoryIds: Id64String | Iterable<Id64String>): Promise<Map<Id64String, IModelConnection.Categories.CategoryInfo>> {\n // Eliminate duplicates...\n const categoryIds = new Set<string>(typeof inputCategoryIds === \"string\" ? [inputCategoryIds] : inputCategoryIds);\n const req = this.load(categoryIds);\n if (req)\n await req.promise;\n\n const map = new Map<Id64String, IModelConnection.Categories.CategoryInfo>();\n for (const categoryId of categoryIds) {\n const subCategoryIds = this._byCategoryId.get(categoryId);\n if (!subCategoryIds)\n continue;\n\n const subCategories = this.mapSubCategoryInfos(categoryId, subCategoryIds);\n map.set(categoryId, { id: categoryId, subCategories });\n }\n\n return map;\n }\n\n public async getSubCategoryInfo(categoryId: Id64String, inputSubCategoryIds: Id64String | Iterable<Id64String>): Promise<Map<Id64String, IModelConnection.Categories.SubCategoryInfo>> {\n // Eliminate duplicates...\n const subCategoryIds = new Set<string>(typeof inputSubCategoryIds === \"string\" ? [inputSubCategoryIds] : inputSubCategoryIds);\n const req = this.load(categoryId);\n if (req)\n await req.promise;\n\n return this.mapSubCategoryInfos(categoryId, subCategoryIds);\n }\n\n private mapSubCategoryInfos(categoryId: Id64String, subCategoryIds: Set<Id64String>): Map<Id64String, IModelConnection.Categories.SubCategoryInfo> {\n const map = new Map<Id64String, IModelConnection.Categories.SubCategoryInfo>();\n for (const id of subCategoryIds) {\n const appearance = this._appearances.get(id);\n if (appearance)\n map.set(id, { id, categoryId, appearance });\n }\n\n return map;\n }\n}\n\n/** This namespace and the types within it are exported strictly for use in tests.\n * @internal\n */\nexport namespace SubCategoriesCache {\n export type Result = SubCategoryResultRow[];\n\n export class Request {\n private readonly _imodel: IModelConnection;\n private readonly _categoryIds: CompressedId64Set[] = [];\n private readonly _result: Result = [];\n private _canceled = false;\n private _curCategoryIdsIndex = 0;\n\n public get wasCanceled() { return this._canceled || this._imodel.isClosed; }\n\n public constructor(categoryIds: Set<string>, imodel: IModelConnection, maxCategoriesPerQuery = 2500) {\n this._imodel = imodel;\n\n const catIds = [...categoryIds];\n OrderedId64Iterable.sortArray(catIds); // sort categories, so that given the same set of categoryIds we will always create the same batches.\n while (catIds.length !== 0) {\n const end = (catIds.length > maxCategoriesPerQuery) ? maxCategoriesPerQuery : catIds.length;\n const compressedIds = CompressedId64Set.compressArray(catIds.splice(0, end));\n this._categoryIds.push(compressedIds);\n }\n }\n\n public cancel() { this._canceled = true; }\n\n public async dispatch(): Promise<Result | undefined> {\n if (this.wasCanceled || this._curCategoryIdsIndex >= this._categoryIds.length) // handle case of empty category Id set...\n return undefined;\n\n try {\n const catIds = this._categoryIds[this._curCategoryIdsIndex];\n const result = await this._imodel.querySubCategories(catIds);\n this._result.push(...result);\n if (this.wasCanceled)\n return undefined;\n } catch {\n // ###TODO: detect cases in which retry is warranted\n // Note that currently, if we succeed in obtaining some pages of results and fail to retrieve another page, we will end up processing the\n // incomplete results. Since we're not retrying, that's the best we can do.\n }\n\n // Finished with current batch of categoryIds. Dispatch the next batch if one exists.\n if (++this._curCategoryIdsIndex < this._categoryIds.length) {\n if (this.wasCanceled)\n return undefined;\n else\n return this.dispatch();\n }\n\n // Even if we were canceled, we've retrieved all the rows. Might as well process them to prevent another request for some of the same rows from being enqueued.\n return this._result;\n }\n }\n\n export type QueueFunc = (anySubCategoriesLoaded: boolean) => void;\n\n export class QueueEntry {\n public readonly categoryIds: Id64Set;\n public readonly funcs: QueueFunc[];\n\n public constructor(categoryIds: Id64Set, func: QueueFunc) {\n this.categoryIds = categoryIds;\n this.funcs = [func];\n }\n }\n\n /** A \"queue\" of SubCategoriesRequests, which consists of between 0 and 2 entries. Each entry specifies the set of category IDs to be loaded and a list of functions to be executed\n * when loading is completed. This is used to enforce ordering of operations upon subcategories despite the need to asynchronously load them. It incidentally also provides an\n * opportunity to reduce the number of backend requests by batching consecutive requests.\n * Chiefly used by [[Viewport]].\n * @internal\n */\n export class Queue {\n /* NB: Members marked protected for use in tests only. */\n protected _current?: QueueEntry;\n protected _next?: QueueEntry;\n protected _request?: SubCategoriesRequest;\n protected _disposed = false;\n\n /** Push a request onto the queue. The requested categories will be loaded if necessary, and then\n * the supplied function will be invoked. Any previously-pushed requests are guaranteed to be processed before this one.\n */\n public push(cache: SubCategoriesCache, categoryIds: Id64Arg, func: QueueFunc): void {\n if (this._disposed)\n return;\n else if (undefined === this._current)\n this.pushCurrent(cache, categoryIds, func);\n else\n this.pushNext(categoryIds, func);\n }\n\n /** Cancel all requests and empty the queue. */\n public [Symbol.dispose](): void {\n if (undefined !== this._request) {\n assert(undefined !== this._current);\n this._request.cancel();\n this._request = undefined;\n }\n\n this._current = this._next = undefined;\n this._disposed = true;\n }\n\n public get isEmpty(): boolean {\n return undefined === this._current && undefined === this._next;\n }\n\n private pushCurrent(cache: SubCategoriesCache, categoryIds: Id64Arg, func: QueueFunc): void {\n assert(undefined === this._next);\n assert(undefined === this._current);\n assert(undefined === this._request);\n\n this._request = cache.load(categoryIds);\n if (undefined === this._request) {\n // All requested categories are already loaded.\n func(false);\n return;\n } else {\n // We need to load the requested categories before invoking the function.\n this.processCurrent(cache, new QueueEntry(Id64.toIdSet(categoryIds, true), func));\n }\n }\n\n private processCurrent(cache: SubCategoriesCache, entry: QueueEntry): void {\n assert(undefined !== this._request);\n assert(undefined === this._current);\n assert(undefined === this._next);\n\n this._current = entry;\n this._request.promise.then((completed: boolean) => { // eslint-disable-line @typescript-eslint/no-floating-promises\n if (this._disposed)\n return;\n\n // Invoke all the functions which were awaiting this set of IModelConnection.Categories.\n assert(undefined !== this._current);\n if (completed)\n for (const func of this._current.funcs)\n func(true);\n\n this._request = undefined;\n this._current = undefined;\n\n // If we have more requests, process them.\n const next = this._next;\n this._next = undefined;\n if (undefined !== next) {\n this._request = cache.load(next.categoryIds);\n if (undefined === this._request) {\n // All categories loaded.\n for (const func of next.funcs)\n func(true);\n } else {\n // We need to load the requested categories before invoking the pending functions.\n this.processCurrent(cache, next);\n }\n }\n });\n }\n\n private pushNext(categoryIds: Id64Arg, func: QueueFunc): void {\n assert(undefined !== this._current);\n assert(undefined !== this._request);\n\n if (undefined === this._next) {\n // We have a request currently in process and none pending.\n // We could potentially determine that this request doesn't require any categories that are not already loaded or being loaded by the current request.\n // But we will find that out (synchronously) when current request completes, unless more requests come in. Probably not worth it.\n this._next = new QueueEntry(Id64.toIdSet(categoryIds, true), func);\n } else {\n // We have a request currently in process, and one or more pending. Append this one to the pending.\n this._next.funcs.push(func);\n for (const categoryId of Id64.iterable(categoryIds))\n this._next.categoryIds.add(categoryId);\n }\n }\n }\n}\n"]}
1
+ {"version":3,"file":"SubCategoriesCache.js","sourceRoot":"","sources":["../../src/SubCategoriesCache.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,IAAI,EAAg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AI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;oBAC7C,IAAI,SAAS,KAAK,IAAI,CAAC,QAAQ,EAAE,CAAC;wBAChC,yBAAyB;wBACzB,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK;4BAC3B,IAAI,CAAC,IAAI,CAAC,CAAC;oBACf,CAAC;yBAAM,CAAC;wBACN,kFAAkF;wBAClF,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;oBACnC,CAAC;gBACH,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC;QAEO,QAAQ,CAAC,WAAoB,EAAE,IAAe;YACpD,MAAM,CAAC,SAAS,KAAK,IAAI,CAAC,QAAQ,CAAC,CAAC;YACpC,MAAM,CAAC,SAAS,KAAK,IAAI,CAAC,QAAQ,CAAC,CAAC;YAEpC,IAAI,SAAS,KAAK,IAAI,CAAC,KAAK,EAAE,CAAC;gBAC7B,2DAA2D;gBAC3D,sJAAsJ;gBACtJ,iIAAiI;gBACjI,IAAI,CAAC,KAAK,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC;YACrE,CAAC;iBAAM,CAAC;gBACN,mGAAmG;gBACnG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBAC5B,KAAK,MAAM,UAAU,IAAI,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC;oBACjD,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;YAC3C,CAAC;QACH,CAAC;KACF;IAvGY,wBAAK,QAuGjB,CAAA;AACH,CAAC,EAjLgB,kBAAkB,KAAlB,kBAAkB,QAiLlC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nimport { assert, CompressedId64Set, Id64, Id64Arg, Id64Set, Id64String, OrderedId64Iterable } from \"@itwin/core-bentley\";\nimport { SubCategoryAppearance, SubCategoryResultRow } from \"@itwin/core-common\";\nimport { IModelConnection } from \"./IModelConnection\";\n\n/** A cancelable paginated request for subcategory information.\n * @see SubCategoriesCache\n * @internal\n */\nexport interface SubCategoriesRequest {\n /** The Ids of any categories which were requested but were not yet loaded. */\n readonly missingCategoryIds: Id64Set;\n /** A promise which resolves to true when all of the requested categories have been loaded, or to false if not all categories were loaded.\n * Categories may fail to load if the request is explicitly canceled or if the IModelConnection is closed before all categories are loaded.\n */\n readonly promise: Promise<boolean>;\n /** Cancels the request. */\n cancel(): void;\n}\n\nconst invalidCategoryIdEntry = new Set<string>();\n\n/** A cache of information about the subcategories contained within an [[IModelConnection]]. It is populated on demand.\n * @internal\n */\nexport class SubCategoriesCache {\n private readonly _byCategoryId = new Map<string, Id64Set>();\n private readonly _appearances = new Map<string, SubCategoryAppearance>();\n private readonly _imodel: IModelConnection;\n private _missingAtTimeOfPreload: Id64Set | undefined;\n\n public constructor(imodel: IModelConnection) {\n this._imodel = imodel;\n }\n\n public attachToBriefcase(imodel: IModelConnection): void {\n // We want to do this in the constructor but can't, because IModelConnection.subcategories is initialized before\n // BriefcaseConnection.txns.\n assert(imodel === this._imodel);\n assert(imodel.isBriefcaseConnection());\n imodel.txns.onElementsChanged.addListener((changes) => {\n const affectedSubCategories = new Set<string>();\n for (const change of changes) {\n if (change.metadata.is(\"BisCore:Category\")) {\n if (change.type === \"deleted\") {\n this._byCategoryId.delete(change.id);\n }\n } else if (change.metadata.is(\"BisCore:SubCategory\")) {\n if (change.type === \"inserted\") {\n // We don't know to which category the subcategory belongs. Blow away the entire cache.\n this._byCategoryId.clear();\n this._appearances.clear();\n return;\n }\n\n this._appearances.delete(change.id);\n affectedSubCategories.add(change.id);\n }\n }\n\n if (affectedSubCategories.size > 0) {\n for (const [catId, subCatIds] of this._byCategoryId) {\n for (const subCatId of affectedSubCategories) {\n if (subCatIds.has(subCatId)) {\n this._byCategoryId.delete(catId);\n affectedSubCategories.delete(subCatId);\n break;\n }\n }\n }\n }\n });\n }\n /** Get the Ids of all subcategories belonging to the category with the specified Id, or undefined if no such information is present. */\n public getSubCategories(categoryId: string): Id64Set | undefined { return this._byCategoryId.get(categoryId); }\n\n /** Get the base appearance of the subcategory with the specified Id, or undefined if no such information is present. */\n public getSubCategoryAppearance(subCategoryId: Id64String): SubCategoryAppearance | undefined { return this._appearances.get(subCategoryId.toString()); }\n\n /** Request that the subcategory information for all of the specified categories is loaded.\n * If all such information has already been loaded, returns undefined.\n * Otherwise, dispatches an asynchronous request to load those categories which are not already loaded and returns a cancellable request object\n * containing the corresponding promise and the set of categories still to be loaded.\n */\n public load(categoryIds: Id64Arg): SubCategoriesRequest | undefined {\n const missing = this.getMissing(categoryIds);\n if (undefined === missing)\n return undefined;\n\n const request = new SubCategoriesCache.Request(missing, this._imodel);\n const promise = request.dispatch().then((result?: SubCategoriesCache.Result) => {\n if (undefined !== result)\n this.processResults(result, missing);\n\n return !request.wasCanceled;\n });\n return {\n missingCategoryIds: missing,\n promise,\n cancel: () => request.cancel(),\n };\n }\n\n /** Load all subcategories that come from used spatial categories of the iModel into the cache. */\n public async loadAllUsedSpatialSubCategories(): Promise<void> {\n try {\n const results = await this._imodel.queryAllUsedSpatialSubCategories();\n if (undefined !== results) {\n this.processResults(results, new Set<string>(), false);\n }\n } catch {\n // In case of a truncated response, gracefully handle the error and exit.\n }\n\n }\n /** Given categoryIds, return which of these are not cached. */\n private getMissing(categoryIds: Id64Arg): Id64Set | undefined {\n let missing: Id64Set | undefined;\n for (const catId of Id64.iterable(categoryIds)) {\n if (undefined === this._byCategoryId.get(catId)) {\n if (undefined === missing)\n missing = new Set<string>();\n\n missing.add(catId);\n }\n }\n\n return missing;\n }\n\n public clear(): void {\n this._byCategoryId.clear();\n this._appearances.clear();\n }\n\n public onIModelConnectionClose(): void {\n this.clear();\n }\n\n private static createSubCategoryAppearance(json?: any) {\n let props: SubCategoryAppearance.Props | undefined;\n if (\"string\" === typeof json && 0 < json.length)\n props = JSON.parse(json);\n\n return new SubCategoryAppearance(props);\n }\n\n private processResults(result: SubCategoriesCache.Result, missing: Id64Set, override: boolean = true): void {\n for (const row of result) {\n this.add(row.parentId, row.id, SubCategoriesCache.createSubCategoryAppearance(row.appearance), override);\n }\n\n // Ensure that any category Ids which returned no results (e.g., non-existent category, invalid Id, etc) are still recorded so they are not repeatedly re-requested\n for (const id of missing)\n if (undefined === this._byCategoryId.get(id))\n this._byCategoryId.set(id, invalidCategoryIdEntry);\n }\n\n /** Exposed strictly for tests.\n * @internal\n */\n public add(categoryId: string, subCategoryId: string, appearance: SubCategoryAppearance, override: boolean) {\n let set = this._byCategoryId.get(categoryId);\n if (undefined === set)\n this._byCategoryId.set(categoryId, set = new Set<string>());\n\n set.add(subCategoryId);\n if (override || !this._appearances.has(subCategoryId))\n this._appearances.set(subCategoryId, appearance);\n }\n\n public async getCategoryInfo(inputCategoryIds: Id64String | Iterable<Id64String>): Promise<Map<Id64String, IModelConnection.Categories.CategoryInfo>> {\n // Eliminate duplicates...\n const categoryIds = new Set<string>(typeof inputCategoryIds === \"string\" ? [inputCategoryIds] : inputCategoryIds);\n const req = this.load(categoryIds);\n if (req)\n await req.promise;\n\n const map = new Map<Id64String, IModelConnection.Categories.CategoryInfo>();\n for (const categoryId of categoryIds) {\n const subCategoryIds = this._byCategoryId.get(categoryId);\n if (!subCategoryIds)\n continue;\n\n const subCategories = this.mapSubCategoryInfos(categoryId, subCategoryIds);\n map.set(categoryId, { id: categoryId, subCategories });\n }\n\n return map;\n }\n\n public async getSubCategoryInfo(categoryId: Id64String, inputSubCategoryIds: Id64String | Iterable<Id64String>): Promise<Map<Id64String, IModelConnection.Categories.SubCategoryInfo>> {\n // Eliminate duplicates...\n const subCategoryIds = new Set<string>(typeof inputSubCategoryIds === \"string\" ? [inputSubCategoryIds] : inputSubCategoryIds);\n const req = this.load(categoryId);\n if (req)\n await req.promise;\n\n return this.mapSubCategoryInfos(categoryId, subCategoryIds);\n }\n\n private mapSubCategoryInfos(categoryId: Id64String, subCategoryIds: Set<Id64String>): Map<Id64String, IModelConnection.Categories.SubCategoryInfo> {\n const map = new Map<Id64String, IModelConnection.Categories.SubCategoryInfo>();\n for (const id of subCategoryIds) {\n const appearance = this._appearances.get(id);\n if (appearance)\n map.set(id, { id, categoryId, appearance });\n }\n\n return map;\n }\n}\n\n/** This namespace and the types within it are exported strictly for use in tests.\n * @internal\n */\nexport namespace SubCategoriesCache {\n export type Result = SubCategoryResultRow[];\n\n export class Request {\n private readonly _imodel: IModelConnection;\n private readonly _categoryIds: CompressedId64Set[] = [];\n private readonly _result: Result = [];\n private _canceled = false;\n private _curCategoryIdsIndex = 0;\n\n public get wasCanceled() { return this._canceled || this._imodel.isClosed; }\n\n public constructor(categoryIds: Set<string>, imodel: IModelConnection, maxCategoriesPerQuery = 2500) {\n this._imodel = imodel;\n\n const catIds = [...categoryIds];\n OrderedId64Iterable.sortArray(catIds); // sort categories, so that given the same set of categoryIds we will always create the same batches.\n while (catIds.length !== 0) {\n const end = (catIds.length > maxCategoriesPerQuery) ? maxCategoriesPerQuery : catIds.length;\n const compressedIds = CompressedId64Set.compressArray(catIds.splice(0, end));\n this._categoryIds.push(compressedIds);\n }\n }\n\n public cancel() { this._canceled = true; }\n\n public async dispatch(): Promise<Result | undefined> {\n if (this.wasCanceled || this._curCategoryIdsIndex >= this._categoryIds.length) // handle case of empty category Id set...\n return undefined;\n\n try {\n const catIds = this._categoryIds[this._curCategoryIdsIndex];\n const result = await this._imodel.querySubCategories(catIds);\n this._result.push(...result);\n if (this.wasCanceled)\n return undefined;\n } catch {\n // ###TODO: detect cases in which retry is warranted\n // Note that currently, if we succeed in obtaining some pages of results and fail to retrieve another page, we will end up processing the\n // incomplete results. Since we're not retrying, that's the best we can do.\n }\n\n // Finished with current batch of categoryIds. Dispatch the next batch if one exists.\n if (++this._curCategoryIdsIndex < this._categoryIds.length) {\n if (this.wasCanceled)\n return undefined;\n else\n return this.dispatch();\n }\n\n // Even if we were canceled, we've retrieved all the rows. Might as well process them to prevent another request for some of the same rows from being enqueued.\n return this._result;\n }\n }\n\n export type QueueFunc = (anySubCategoriesLoaded: boolean) => void;\n\n export class QueueEntry {\n public readonly categoryIds: Id64Set;\n public readonly funcs: QueueFunc[];\n\n public constructor(categoryIds: Id64Set, func: QueueFunc) {\n this.categoryIds = categoryIds;\n this.funcs = [func];\n }\n }\n\n /** A \"queue\" of SubCategoriesRequests, which consists of between 0 and 2 entries. Each entry specifies the set of category IDs to be loaded and a list of functions to be executed\n * when loading is completed. This is used to enforce ordering of operations upon subcategories despite the need to asynchronously load them. It incidentally also provides an\n * opportunity to reduce the number of backend requests by batching consecutive requests.\n * Chiefly used by [[Viewport]].\n * @internal\n */\n export class Queue {\n /* NB: Members marked protected for use in tests only. */\n protected _current?: QueueEntry;\n protected _next?: QueueEntry;\n protected _request?: SubCategoriesRequest;\n protected _disposed = false;\n\n /** Push a request onto the queue. The requested categories will be loaded if necessary, and then\n * the supplied function will be invoked. Any previously-pushed requests are guaranteed to be processed before this one.\n */\n public push(cache: SubCategoriesCache, categoryIds: Id64Arg, func: QueueFunc): void {\n if (this._disposed)\n return;\n else if (undefined === this._current)\n this.pushCurrent(cache, categoryIds, func);\n else\n this.pushNext(categoryIds, func);\n }\n\n /** Cancel all requests and empty the queue. */\n public [Symbol.dispose](): void {\n if (undefined !== this._request) {\n assert(undefined !== this._current);\n this._request.cancel();\n this._request = undefined;\n }\n\n this._current = this._next = undefined;\n this._disposed = true;\n }\n\n public get isEmpty(): boolean {\n return undefined === this._current && undefined === this._next;\n }\n\n private pushCurrent(cache: SubCategoriesCache, categoryIds: Id64Arg, func: QueueFunc): void {\n assert(undefined === this._next);\n assert(undefined === this._current);\n assert(undefined === this._request);\n\n this._request = cache.load(categoryIds);\n if (undefined === this._request) {\n // All requested categories are already loaded.\n func(false);\n return;\n } else {\n // We need to load the requested categories before invoking the function.\n this.processCurrent(cache, new QueueEntry(Id64.toIdSet(categoryIds, true), func));\n }\n }\n\n private processCurrent(cache: SubCategoriesCache, entry: QueueEntry): void {\n assert(undefined !== this._request);\n assert(undefined === this._current);\n assert(undefined === this._next);\n\n this._current = entry;\n this._request.promise.then((completed: boolean) => { // eslint-disable-line @typescript-eslint/no-floating-promises\n if (this._disposed)\n return;\n\n // Invoke all the functions which were awaiting this set of IModelConnection.Categories.\n assert(undefined !== this._current);\n if (completed)\n for (const func of this._current.funcs)\n func(true);\n\n this._request = undefined;\n this._current = undefined;\n\n // If we have more requests, process them.\n const next = this._next;\n this._next = undefined;\n if (undefined !== next) {\n this._request = cache.load(next.categoryIds);\n if (undefined === this._request) {\n // All categories loaded.\n for (const func of next.funcs)\n func(true);\n } else {\n // We need to load the requested categories before invoking the pending functions.\n this.processCurrent(cache, next);\n }\n }\n });\n }\n\n private pushNext(categoryIds: Id64Arg, func: QueueFunc): void {\n assert(undefined !== this._current);\n assert(undefined !== this._request);\n\n if (undefined === this._next) {\n // We have a request currently in process and none pending.\n // We could potentially determine that this request doesn't require any categories that are not already loaded or being loaded by the current request.\n // But we will find that out (synchronously) when current request completes, unless more requests come in. Probably not worth it.\n this._next = new QueueEntry(Id64.toIdSet(categoryIds, true), func);\n } else {\n // We have a request currently in process, and one or more pending. Append this one to the pending.\n this._next.funcs.push(func);\n for (const categoryId of Id64.iterable(categoryIds))\n this._next.categoryIds.add(categoryId);\n }\n }\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itwin/core-frontend",
3
- "version": "5.4.0-dev.5",
3
+ "version": "5.4.0-dev.7",
4
4
  "description": "iTwin.js frontend components",
5
5
  "main": "lib/cjs/core-frontend.js",
6
6
  "module": "lib/esm/core-frontend.js",
@@ -23,14 +23,14 @@
23
23
  "url": "http://www.bentley.com"
24
24
  },
25
25
  "peerDependencies": {
26
- "@itwin/appui-abstract": "5.4.0-dev.5",
27
- "@itwin/core-orbitgt": "5.4.0-dev.5",
28
- "@itwin/core-quantity": "5.4.0-dev.5",
29
- "@itwin/core-bentley": "5.4.0-dev.5",
30
- "@itwin/core-common": "5.4.0-dev.5",
31
- "@itwin/ecschema-rpcinterface-common": "5.4.0-dev.5",
32
- "@itwin/core-geometry": "5.4.0-dev.5",
33
- "@itwin/ecschema-metadata": "5.4.0-dev.5"
26
+ "@itwin/core-bentley": "5.4.0-dev.7",
27
+ "@itwin/core-geometry": "5.4.0-dev.7",
28
+ "@itwin/core-orbitgt": "5.4.0-dev.7",
29
+ "@itwin/core-quantity": "5.4.0-dev.7",
30
+ "@itwin/ecschema-metadata": "5.4.0-dev.7",
31
+ "@itwin/appui-abstract": "5.4.0-dev.7",
32
+ "@itwin/ecschema-rpcinterface-common": "5.4.0-dev.7",
33
+ "@itwin/core-common": "5.4.0-dev.7"
34
34
  },
35
35
  "//devDependencies": [
36
36
  "NOTE: All peerDependencies should also be listed as devDependencies since peerDependencies are not considered by npm install",
@@ -57,15 +57,15 @@
57
57
  "vite-multiple-assets": "^1.3.1",
58
58
  "vite-plugin-static-copy": "2.2.0",
59
59
  "webpack": "^5.97.1",
60
- "@itwin/appui-abstract": "5.4.0-dev.5",
61
- "@itwin/core-orbitgt": "5.4.0-dev.5",
62
- "@itwin/core-bentley": "5.4.0-dev.5",
63
- "@itwin/core-common": "5.4.0-dev.5",
64
- "@itwin/core-geometry": "5.4.0-dev.5",
65
- "@itwin/core-quantity": "5.4.0-dev.5",
66
- "@itwin/ecschema-metadata": "5.4.0-dev.5",
67
- "@itwin/build-tools": "5.4.0-dev.5",
68
- "@itwin/ecschema-rpcinterface-common": "5.4.0-dev.5"
60
+ "@itwin/core-bentley": "5.4.0-dev.7",
61
+ "@itwin/core-common": "5.4.0-dev.7",
62
+ "@itwin/build-tools": "5.4.0-dev.7",
63
+ "@itwin/appui-abstract": "5.4.0-dev.7",
64
+ "@itwin/core-orbitgt": "5.4.0-dev.7",
65
+ "@itwin/core-quantity": "5.4.0-dev.7",
66
+ "@itwin/core-geometry": "5.4.0-dev.7",
67
+ "@itwin/ecschema-metadata": "5.4.0-dev.7",
68
+ "@itwin/ecschema-rpcinterface-common": "5.4.0-dev.7"
69
69
  },
70
70
  "//dependencies": [
71
71
  "NOTE: these dependencies should be only for things that DO NOT APPEAR IN THE API",
@@ -76,8 +76,8 @@
76
76
  "@loaders.gl/draco": "^4.3.4",
77
77
  "fuse.js": "^3.3.0",
78
78
  "wms-capabilities": "0.4.0",
79
- "@itwin/webgl-compatibility": "5.4.0-dev.5",
80
- "@itwin/core-i18n": "5.4.0-dev.5"
79
+ "@itwin/webgl-compatibility": "5.4.0-dev.7",
80
+ "@itwin/core-i18n": "5.4.0-dev.7"
81
81
  },
82
82
  "scripts": {
83
83
  "build": "npm run -s copy:public && npm run -s build:cjs && npm run -s build:esm && npm run -s webpackWorkers && npm run -s copy:workers && npm run -s copy:draco",