@itwin/core-frontend 3.5.0-dev.25 → 3.5.0-dev.26

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.
Files changed (121) hide show
  1. package/lib/cjs/BriefcaseConnection.js +7 -7
  2. package/lib/cjs/BriefcaseConnection.js.map +1 -1
  3. package/lib/cjs/BriefcaseTxns.js +9 -9
  4. package/lib/cjs/BriefcaseTxns.js.map +1 -1
  5. package/lib/cjs/GraphicalEditingScope.js +2 -2
  6. package/lib/cjs/GraphicalEditingScope.js.map +1 -1
  7. package/lib/cjs/IpcApp.d.ts +8 -1
  8. package/lib/cjs/IpcApp.d.ts.map +1 -1
  9. package/lib/cjs/IpcApp.js +13 -0
  10. package/lib/cjs/IpcApp.js.map +1 -1
  11. package/lib/cjs/NativeApp.d.ts +5 -1
  12. package/lib/cjs/NativeApp.d.ts.map +1 -1
  13. package/lib/cjs/NativeApp.js +25 -20
  14. package/lib/cjs/NativeApp.js.map +1 -1
  15. package/lib/cjs/NativeAppLogger.js +1 -1
  16. package/lib/cjs/NativeAppLogger.js.map +1 -1
  17. package/lib/cjs/render/primitives/SurfaceParams.d.ts +0 -1
  18. package/lib/cjs/render/primitives/SurfaceParams.d.ts.map +1 -1
  19. package/lib/cjs/render/primitives/SurfaceParams.js.map +1 -1
  20. package/lib/cjs/render/primitives/VertexTable.d.ts.map +1 -1
  21. package/lib/cjs/render/primitives/VertexTable.js +0 -1
  22. package/lib/cjs/render/primitives/VertexTable.js.map +1 -1
  23. package/lib/cjs/render/primitives/VertexTableSplitter.d.ts.map +1 -1
  24. package/lib/cjs/render/primitives/VertexTableSplitter.js +0 -1
  25. package/lib/cjs/render/primitives/VertexTableSplitter.js.map +1 -1
  26. package/lib/cjs/render/primitives/mesh/MeshPrimitives.d.ts +0 -1
  27. package/lib/cjs/render/primitives/mesh/MeshPrimitives.d.ts.map +1 -1
  28. package/lib/cjs/render/primitives/mesh/MeshPrimitives.js +0 -1
  29. package/lib/cjs/render/primitives/mesh/MeshPrimitives.js.map +1 -1
  30. package/lib/cjs/render/webgl/MeshData.d.ts +0 -1
  31. package/lib/cjs/render/webgl/MeshData.d.ts.map +1 -1
  32. package/lib/cjs/render/webgl/MeshData.js +0 -1
  33. package/lib/cjs/render/webgl/MeshData.js.map +1 -1
  34. package/lib/cjs/render/webgl/MeshGeometry.d.ts +0 -1
  35. package/lib/cjs/render/webgl/MeshGeometry.d.ts.map +1 -1
  36. package/lib/cjs/render/webgl/MeshGeometry.js +0 -1
  37. package/lib/cjs/render/webgl/MeshGeometry.js.map +1 -1
  38. package/lib/cjs/render/webgl/RenderFlags.d.ts +2 -2
  39. package/lib/cjs/render/webgl/RenderFlags.d.ts.map +1 -1
  40. package/lib/cjs/render/webgl/RenderFlags.js.map +1 -1
  41. package/lib/cjs/render/webgl/SurfaceGeometry.d.ts +0 -1
  42. package/lib/cjs/render/webgl/SurfaceGeometry.d.ts.map +1 -1
  43. package/lib/cjs/render/webgl/SurfaceGeometry.js +2 -6
  44. package/lib/cjs/render/webgl/SurfaceGeometry.js.map +1 -1
  45. package/lib/cjs/render/webgl/glsl/Lighting.js +1 -1
  46. package/lib/cjs/render/webgl/glsl/Lighting.js.map +1 -1
  47. package/lib/cjs/render/webgl/glsl/Surface.js +1 -1
  48. package/lib/cjs/render/webgl/glsl/Surface.js.map +1 -1
  49. package/lib/cjs/tile/IModelTileRequestChannels.js +1 -1
  50. package/lib/cjs/tile/IModelTileRequestChannels.js.map +1 -1
  51. package/lib/cjs/tile/ImdlReader.d.ts.map +1 -1
  52. package/lib/cjs/tile/ImdlReader.js +0 -1
  53. package/lib/cjs/tile/ImdlReader.js.map +1 -1
  54. package/lib/cjs/tile/TileAdmin.js +1 -1
  55. package/lib/cjs/tile/TileAdmin.js.map +1 -1
  56. package/lib/cjs/tile/TileRequestChannels.js +1 -1
  57. package/lib/cjs/tile/TileRequestChannels.js.map +1 -1
  58. package/lib/cjs/tile/TileStorage.d.ts.map +1 -1
  59. package/lib/cjs/tile/TileStorage.js +12 -6
  60. package/lib/cjs/tile/TileStorage.js.map +1 -1
  61. package/lib/esm/BriefcaseConnection.js +7 -7
  62. package/lib/esm/BriefcaseConnection.js.map +1 -1
  63. package/lib/esm/BriefcaseTxns.js +9 -9
  64. package/lib/esm/BriefcaseTxns.js.map +1 -1
  65. package/lib/esm/GraphicalEditingScope.js +2 -2
  66. package/lib/esm/GraphicalEditingScope.js.map +1 -1
  67. package/lib/esm/IpcApp.d.ts +8 -1
  68. package/lib/esm/IpcApp.d.ts.map +1 -1
  69. package/lib/esm/IpcApp.js +13 -0
  70. package/lib/esm/IpcApp.js.map +1 -1
  71. package/lib/esm/NativeApp.d.ts +5 -1
  72. package/lib/esm/NativeApp.d.ts.map +1 -1
  73. package/lib/esm/NativeApp.js +25 -20
  74. package/lib/esm/NativeApp.js.map +1 -1
  75. package/lib/esm/NativeAppLogger.js +1 -1
  76. package/lib/esm/NativeAppLogger.js.map +1 -1
  77. package/lib/esm/render/primitives/SurfaceParams.d.ts +0 -1
  78. package/lib/esm/render/primitives/SurfaceParams.d.ts.map +1 -1
  79. package/lib/esm/render/primitives/SurfaceParams.js.map +1 -1
  80. package/lib/esm/render/primitives/VertexTable.d.ts.map +1 -1
  81. package/lib/esm/render/primitives/VertexTable.js +0 -1
  82. package/lib/esm/render/primitives/VertexTable.js.map +1 -1
  83. package/lib/esm/render/primitives/VertexTableSplitter.d.ts.map +1 -1
  84. package/lib/esm/render/primitives/VertexTableSplitter.js +0 -1
  85. package/lib/esm/render/primitives/VertexTableSplitter.js.map +1 -1
  86. package/lib/esm/render/primitives/mesh/MeshPrimitives.d.ts +0 -1
  87. package/lib/esm/render/primitives/mesh/MeshPrimitives.d.ts.map +1 -1
  88. package/lib/esm/render/primitives/mesh/MeshPrimitives.js +0 -1
  89. package/lib/esm/render/primitives/mesh/MeshPrimitives.js.map +1 -1
  90. package/lib/esm/render/webgl/MeshData.d.ts +0 -1
  91. package/lib/esm/render/webgl/MeshData.d.ts.map +1 -1
  92. package/lib/esm/render/webgl/MeshData.js +0 -1
  93. package/lib/esm/render/webgl/MeshData.js.map +1 -1
  94. package/lib/esm/render/webgl/MeshGeometry.d.ts +0 -1
  95. package/lib/esm/render/webgl/MeshGeometry.d.ts.map +1 -1
  96. package/lib/esm/render/webgl/MeshGeometry.js +0 -1
  97. package/lib/esm/render/webgl/MeshGeometry.js.map +1 -1
  98. package/lib/esm/render/webgl/RenderFlags.d.ts +2 -2
  99. package/lib/esm/render/webgl/RenderFlags.d.ts.map +1 -1
  100. package/lib/esm/render/webgl/RenderFlags.js.map +1 -1
  101. package/lib/esm/render/webgl/SurfaceGeometry.d.ts +0 -1
  102. package/lib/esm/render/webgl/SurfaceGeometry.d.ts.map +1 -1
  103. package/lib/esm/render/webgl/SurfaceGeometry.js +2 -6
  104. package/lib/esm/render/webgl/SurfaceGeometry.js.map +1 -1
  105. package/lib/esm/render/webgl/glsl/Lighting.js +1 -1
  106. package/lib/esm/render/webgl/glsl/Lighting.js.map +1 -1
  107. package/lib/esm/render/webgl/glsl/Surface.js +1 -1
  108. package/lib/esm/render/webgl/glsl/Surface.js.map +1 -1
  109. package/lib/esm/tile/IModelTileRequestChannels.js +1 -1
  110. package/lib/esm/tile/IModelTileRequestChannels.js.map +1 -1
  111. package/lib/esm/tile/ImdlReader.d.ts.map +1 -1
  112. package/lib/esm/tile/ImdlReader.js +0 -1
  113. package/lib/esm/tile/ImdlReader.js.map +1 -1
  114. package/lib/esm/tile/TileAdmin.js +1 -1
  115. package/lib/esm/tile/TileAdmin.js.map +1 -1
  116. package/lib/esm/tile/TileRequestChannels.js +1 -1
  117. package/lib/esm/tile/TileRequestChannels.js.map +1 -1
  118. package/lib/esm/tile/TileStorage.d.ts.map +1 -1
  119. package/lib/esm/tile/TileStorage.js +12 -6
  120. package/lib/esm/tile/TileStorage.js.map +1 -1
  121. package/package.json +20 -20
@@ -189,7 +189,7 @@ export class BriefcaseConnection extends IModelConnection {
189
189
  get iModelId() { return super.iModelId; } // GuidString | undefined for IModelConnection, but required for BriefcaseConnection
190
190
  /** Open a BriefcaseConnection to a [BriefcaseDb]($backend). */
191
191
  static async openFile(briefcaseProps) {
192
- const iModelProps = await IpcApp.callIpcHost("openBriefcase", briefcaseProps);
192
+ const iModelProps = await IpcApp.appFunctionIpc.openBriefcase(briefcaseProps);
193
193
  const connection = new this({ ...briefcaseProps, ...iModelProps }, briefcaseProps.readonly ? OpenMode.Readonly : OpenMode.ReadWrite);
194
194
  IModelConnection.onOpen.raiseEvent(connection);
195
195
  return connection;
@@ -198,7 +198,7 @@ export class BriefcaseConnection extends IModelConnection {
198
198
  * @note StandaloneDbs, by definition, may not push or pull changes. Attempting to do so will throw exceptions.
199
199
  */
200
200
  static async openStandalone(filePath, openMode = OpenMode.ReadWrite, opts) {
201
- const openResponse = await IpcApp.callIpcHost("openStandalone", filePath, openMode, opts);
201
+ const openResponse = await IpcApp.appFunctionIpc.openStandalone(filePath, openMode, opts);
202
202
  const connection = new this(openResponse, openMode);
203
203
  IModelConnection.onOpen.raiseEvent(connection);
204
204
  return connection;
@@ -216,7 +216,7 @@ export class BriefcaseConnection extends IModelConnection {
216
216
  this.beforeClose();
217
217
  this.txns.dispose();
218
218
  this._isClosed = true;
219
- await IpcApp.callIpcHost("closeIModel", this._fileKey);
219
+ await IpcApp.appFunctionIpc.closeIModel(this._fileKey);
220
220
  }
221
221
  requireTimeline() {
222
222
  if (this.iTwinId === Guid.empty)
@@ -230,7 +230,7 @@ export class BriefcaseConnection extends IModelConnection {
230
230
  * @param description Optional description of the changes.
231
231
  */
232
232
  async saveChanges(description) {
233
- await IpcApp.callIpcHost("saveChanges", this.key, description);
233
+ await IpcApp.appFunctionIpc.saveChanges(this.key, description);
234
234
  }
235
235
  /** Pull (and potentially merge if there are local changes) up to a specified changeset from iModelHub into this briefcase
236
236
  * @param toIndex The changeset index to pull changes to. If `undefined`, pull all changes.
@@ -238,7 +238,7 @@ export class BriefcaseConnection extends IModelConnection {
238
238
  */
239
239
  async pullChanges(toIndex) {
240
240
  this.requireTimeline();
241
- this.changeset = await IpcApp.callIpcHost("pullChanges", this.key, toIndex);
241
+ this.changeset = await IpcApp.appFunctionIpc.pullChanges(this.key, toIndex);
242
242
  }
243
243
  /** Create a changeset from local Txns and push to iModelHub. On success, clear Txn table.
244
244
  * @param description The description for the changeset
@@ -247,7 +247,7 @@ export class BriefcaseConnection extends IModelConnection {
247
247
  */
248
248
  async pushChanges(description) {
249
249
  this.requireTimeline();
250
- return IpcApp.callIpcHost("pushChanges", this.key, description);
250
+ return IpcApp.appFunctionIpc.pushChanges(this.key, description);
251
251
  }
252
252
  /** The current graphical editing scope, if one is in progress.
253
253
  * @see [[enterEditingScope]] to begin graphical editing.
@@ -260,7 +260,7 @@ export class BriefcaseConnection extends IModelConnection {
260
260
  * @see [[enterEditingScope]] to enable graphical editing.
261
261
  */
262
262
  async supportsGraphicalEditing() {
263
- return IpcApp.callIpcHost("isGraphicalEditingSupported", this.key);
263
+ return IpcApp.appFunctionIpc.isGraphicalEditingSupported(this.key);
264
264
  }
265
265
  /** Begin a new graphical editing scope.
266
266
  * @throws Error if an editing scope already exists or one could not be created.
@@ -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,EAEuC,WAAW,GACxD,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,OAA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AC;IAC9E,CAAC;IAED,2FAA2F;IACpF,KAAK,CAAC,cAAc;QACzB,OAAO,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC;IACpC,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,WAAW,CAAC,WAAoB;QAC3C,MAAM,MAAM,CAAC,WAAW,CAAC,aAAa,EAAE,IAAI,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;IACjE,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,WAAW,CAAC,OAAwB;QAC/C,IAAI,CAAC,eAAe,EAAE,CAAC;QACvB,IAAI,CAAC,SAAS,GAAG,MAAM,MAAM,CAAC,WAAW,CAAC,aAAa,EAAE,IAAI,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAC9E,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,WAAW,CAAC,WAAmB;QAC1C,IAAI,CAAC,eAAe,EAAE,CAAC;QACvB,OAAO,MAAM,CAAC,WAAW,CAAC,aAAa,EAAE,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,WAAW,CAAC,6BAA6B,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;IACrE,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,iBAAiB;QAC5B,OAAO,IAAI,CAAC,cAAc,CAAC,iBAAiB,EAAE,CAAC;IACjD,CAAC;CAMF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module IModelConnection\r\n */\r\n\r\nimport { assert, BeEvent, CompressedId64Set, Guid, GuidString, Id64String, IModelStatus, OpenMode } from \"@itwin/core-bentley\";\r\nimport {\r\n ChangesetIndex,\r\n ChangesetIndexAndId, IModelConnectionProps, IModelError, OpenBriefcaseProps, StandaloneOpenOptions,\r\n} from \"@itwin/core-common\";\r\nimport { BriefcaseTxns } from \"./BriefcaseTxns\";\r\nimport { GraphicalEditingScope } from \"./GraphicalEditingScope\";\r\nimport { IModelApp } from \"./IModelApp\";\r\nimport { IModelConnection } from \"./IModelConnection\";\r\nimport { IpcApp } from \"./IpcApp\";\r\nimport { disposeTileTreesForGeometricModels } from \"./tile/internal\";\r\nimport { Viewport } from \"./Viewport\";\r\n\r\n/** Keeps track of changes to models, buffering them until synchronization points.\r\n * While a GraphicalEditingScope is open, the changes are buffered until the scope exits, at which point they are processed.\r\n * Otherwise, the buffered changes are processed after undo/redo, commit, or pull+merge changes.\r\n */\r\nclass ModelChangeMonitor {\r\n private _editingScope?: GraphicalEditingScope;\r\n private readonly _briefcase: BriefcaseConnection;\r\n private readonly _deletedModels = new Set<string>();\r\n private readonly _modelIdToGuid = new Map<string, string>();\r\n private readonly _removals: VoidFunction[] = [];\r\n\r\n public constructor(briefcase: BriefcaseConnection) {\r\n this._briefcase = briefcase;\r\n\r\n // Buffer updated geometry guids.\r\n this._removals.push(briefcase.txns.onModelGeometryChanged.addListener((changes) => {\r\n for (const change of changes) {\r\n this._deletedModels.delete(change.id);\r\n this._modelIdToGuid.set(change.id, change.guid);\r\n }\r\n }));\r\n\r\n // Buffer deletions of models.\r\n this._removals.push(briefcase.txns.onModelsChanged.addListener((changes) => {\r\n if (changes.deleted) {\r\n for (const id of CompressedId64Set.iterable(changes.deleted)) {\r\n this._modelIdToGuid.delete(id);\r\n this._deletedModels.add(id);\r\n }\r\n }\r\n }));\r\n\r\n // Outside of an editing scope, we want to update viewport contents after commit, undo/redo, or merging changes.\r\n const maybeProcess = async () => {\r\n if (this.editingScope)\r\n return;\r\n\r\n const modelIds = Array.from(this._modelIdToGuid.keys());\r\n if (modelIds.length > 0)\r\n await IModelApp.tileAdmin.purgeTileTrees(this._briefcase, modelIds);\r\n\r\n this.processBuffered();\r\n };\r\n\r\n this._removals.push(briefcase.txns.onCommitted.addListener(maybeProcess));\r\n this._removals.push(briefcase.txns.onAfterUndoRedo.addListener(maybeProcess));\r\n this._removals.push(briefcase.txns.onChangesPulled.addListener(maybeProcess));\r\n }\r\n\r\n public async close(): Promise<void> {\r\n for (const removal of this._removals)\r\n removal();\r\n\r\n this._removals.length = 0;\r\n\r\n if (this._editingScope) {\r\n await this._editingScope.exit();\r\n this._editingScope = undefined;\r\n }\r\n }\r\n\r\n public get editingScope(): GraphicalEditingScope | undefined {\r\n return this._editingScope;\r\n }\r\n\r\n public async enterEditingScope(): Promise<GraphicalEditingScope> {\r\n if (this._editingScope)\r\n throw new Error(\"Cannot create an editing scope for an iModel that already has one\");\r\n\r\n this._editingScope = await GraphicalEditingScope.enter(this._briefcase);\r\n\r\n const removeGeomListener = this._editingScope.onGeometryChanges.addListener((changes) => {\r\n const modelIds = [];\r\n for (const change of changes)\r\n modelIds.push(change.id);\r\n\r\n this.invalidateScenes(modelIds);\r\n });\r\n\r\n this._editingScope.onExited.addOnce((scope) => {\r\n assert(scope === this._editingScope);\r\n this._editingScope = undefined;\r\n removeGeomListener();\r\n this.processBuffered();\r\n });\r\n\r\n return this._editingScope;\r\n }\r\n\r\n private processBuffered(): void {\r\n const models = this._briefcase.models;\r\n for (const [id, guid] of this._modelIdToGuid) {\r\n const model = models.getLoaded(id)?.asGeometricModel;\r\n if (model)\r\n model.geometryGuid = guid;\r\n }\r\n\r\n const modelIds = new Set<string>(this._modelIdToGuid.keys());\r\n for (const deleted of this._deletedModels) {\r\n modelIds.add(deleted);\r\n models.unload(deleted);\r\n }\r\n\r\n this.invalidateScenes(modelIds);\r\n disposeTileTreesForGeometricModels(modelIds, this._briefcase);\r\n\r\n this._briefcase.onBufferedModelChanges.raiseEvent(modelIds);\r\n\r\n this._modelIdToGuid.clear();\r\n this._deletedModels.clear();\r\n }\r\n\r\n private invalidateScenes(changedModels: Iterable<Id64String>): void {\r\n for (const user of IModelApp.tileAdmin.tileUsers) {\r\n if (user instanceof Viewport && user.iModel === this._briefcase) {\r\n for (const modelId of changedModels) {\r\n if (user.view.viewsModel(modelId)) {\r\n user.invalidateScene();\r\n user.setFeatureOverrideProviderChanged();\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n }\r\n}\r\n\r\n/** Settings that can be used to control the behavior of [[Tool]]s that modify a [[BriefcaseConnection]].\r\n * For example, tools that want to create new elements can consult the briefcase's editor tool settings to\r\n * determine into which model and category to insert the elements.\r\n * Specialized tools are free to ignore these settings.\r\n * @see [[BriefcaseConnection.editorToolSettings]] to query or modify the current settings for a briefcase.\r\n * @see [CreateElementTool]($editor-frontend) for an example of a tool that uses these settings.\r\n * @alpha\r\n */\r\nexport class BriefcaseEditorToolSettings {\r\n private _category?: Id64String;\r\n private _model?: Id64String;\r\n\r\n /** An event raised just after the default [[category]] is changed. */\r\n public readonly onCategoryChanged = new BeEvent<(previousCategory: Id64String | undefined) => void>();\r\n\r\n /** An event raised just after the default [[model]] is changed. */\r\n public readonly onModelChanged = new BeEvent<(previousModel: Id64String | undefined) => void>();\r\n\r\n /** The [Category]($backend) into which new elements should be inserted by default.\r\n * Specialized tools are free to ignore this setting and instead use their own logic to select an appropriate category.\r\n * @see [[onCategoryChanged]] to be notified when this property is modified.\r\n * @see [CreateElementTool.targetCategory]($editor-frontend) for an example of a tool that uses this setting.\r\n */\r\n public get category(): Id64String | undefined {\r\n return this._category;\r\n }\r\n public set category(category: Id64String | undefined) {\r\n const previousCategory = this.category;\r\n if (category !== this.category) {\r\n this._category = category;\r\n this.onCategoryChanged.raiseEvent(previousCategory);\r\n }\r\n }\r\n\r\n /** The [Model]($backend) into which new elements should be inserted by default.\r\n * Specialized tools are free to ignore this setting and instead use their own logic to select an appropriate model.\r\n * @see [[onModelChanged]] to be notified when this property is modified.\r\n * @see [CreateElementTool.targetModel]($editor-frontend) for an example of a tool that uses this setting.\r\n */\r\n public get model(): Id64String | undefined {\r\n return this._model;\r\n }\r\n public set model(model: Id64String | undefined) {\r\n const previousModel = this.model;\r\n if (model !== this.model) {\r\n this._model = model;\r\n this.onModelChanged.raiseEvent(previousModel);\r\n }\r\n }\r\n}\r\n\r\n/** A connection to an editable briefcase on the backend. This class uses [Ipc]($docs/learning/IpcInterface.md) to communicate\r\n * to the backend and may only be used by [[IpcApp]]s.\r\n * @public\r\n */\r\nexport class BriefcaseConnection extends IModelConnection {\r\n protected _isClosed?: boolean;\r\n private readonly _modelsMonitor: ModelChangeMonitor;\r\n /** Default settings that can be used to control the behavior of [[Tool]]s that modify this briefcase.\r\n * @alpha\r\n */\r\n public readonly editorToolSettings = new BriefcaseEditorToolSettings();\r\n\r\n /** Manages local changes to the briefcase via [Txns]($docs/learning/InteractiveEditing.md). */\r\n public readonly txns: BriefcaseTxns;\r\n\r\n /** @internal */\r\n public override isBriefcaseConnection(): this is BriefcaseConnection { return true; }\r\n\r\n /** The Guid that identifies the iTwin that owns this iModel. */\r\n public override get iTwinId(): GuidString { return super.iTwinId!; } // GuidString | undefined for IModelConnection, but required for BriefcaseConnection\r\n\r\n /** The Guid that identifies this iModel. */\r\n public override get iModelId(): GuidString { return super.iModelId!; } // GuidString | undefined for IModelConnection, but required for BriefcaseConnection\r\n\r\n protected constructor(props: IModelConnectionProps, openMode: OpenMode) {\r\n super(props);\r\n this._openMode = openMode;\r\n this.txns = new BriefcaseTxns(this);\r\n this._modelsMonitor = new ModelChangeMonitor(this);\r\n }\r\n\r\n /** Open a BriefcaseConnection to a [BriefcaseDb]($backend). */\r\n public static async openFile(briefcaseProps: OpenBriefcaseProps): Promise<BriefcaseConnection> {\r\n const iModelProps = await IpcApp.callIpcHost(\"openBriefcase\", briefcaseProps);\r\n const connection = new this({ ...briefcaseProps, ...iModelProps }, briefcaseProps.readonly ? OpenMode.Readonly : OpenMode.ReadWrite);\r\n IModelConnection.onOpen.raiseEvent(connection);\r\n return connection;\r\n }\r\n\r\n /** Open a BriefcaseConnection to a [StandaloneDb]($backend)\r\n * @note StandaloneDbs, by definition, may not push or pull changes. Attempting to do so will throw exceptions.\r\n */\r\n public static async openStandalone(filePath: string, openMode: OpenMode = OpenMode.ReadWrite, opts?: StandaloneOpenOptions): Promise<BriefcaseConnection> {\r\n const openResponse = await IpcApp.callIpcHost(\"openStandalone\", filePath, openMode, opts);\r\n const connection = new this(openResponse, openMode);\r\n IModelConnection.onOpen.raiseEvent(connection);\r\n return connection;\r\n }\r\n\r\n /** Returns `true` if [[close]] has already been called. */\r\n public get isClosed(): boolean { return this._isClosed === true; }\r\n\r\n /**\r\n * Close this BriefcaseConnection.\r\n * @note make sure to call [[saveChanges]] before calling this method. Unsaved local changes are abandoned.\r\n */\r\n public async close(): Promise<void> {\r\n if (this.isClosed)\r\n return;\r\n\r\n await this._modelsMonitor.close();\r\n\r\n this.beforeClose();\r\n this.txns.dispose();\r\n\r\n this._isClosed = true;\r\n await IpcApp.callIpcHost(\"closeIModel\", this._fileKey);\r\n }\r\n\r\n private requireTimeline() {\r\n if (this.iTwinId === Guid.empty)\r\n throw new IModelError(IModelStatus.WrongIModel, \"iModel has no timeline\");\r\n }\r\n\r\n /** Query if there are any pending Txns in this briefcase that are waiting to be pushed. */\r\n public async hasPendingTxns(): Promise<boolean> { // eslint-disable-line @itwin/prefer-get\r\n return this.txns.hasPendingTxns();\r\n }\r\n\r\n /** Commit pending changes to this briefcase.\r\n * @param description Optional description of the changes.\r\n */\r\n public async saveChanges(description?: string): Promise<void> {\r\n await IpcApp.callIpcHost(\"saveChanges\", this.key, description);\r\n }\r\n\r\n /** Pull (and potentially merge if there are local changes) up to a specified changeset from iModelHub into this briefcase\r\n * @param toIndex The changeset index to pull changes to. If `undefined`, pull all changes.\r\n * @see [[BriefcaseTxns.onChangesPulled]] for the event dispatched after changes are pulled.\r\n */\r\n public async pullChanges(toIndex?: ChangesetIndex): Promise<void> {\r\n this.requireTimeline();\r\n this.changeset = await IpcApp.callIpcHost(\"pullChanges\", this.key, toIndex);\r\n }\r\n\r\n /** Create a changeset from local Txns and push to iModelHub. On success, clear Txn table.\r\n * @param description The description for the changeset\r\n * @returns the changesetId of the pushed changes\r\n * @see [[BriefcaseTxns.onChangesPushed]] for the event dispatched after changes are pushed.\r\n */\r\n public async pushChanges(description: string): Promise<ChangesetIndexAndId> {\r\n this.requireTimeline();\r\n return IpcApp.callIpcHost(\"pushChanges\", this.key, description);\r\n }\r\n\r\n /** The current graphical editing scope, if one is in progress.\r\n * @see [[enterEditingScope]] to begin graphical editing.\r\n */\r\n public get editingScope(): GraphicalEditingScope | undefined {\r\n return this._modelsMonitor.editingScope;\r\n }\r\n\r\n /** Return whether graphical editing is supported for this briefcase. It is not supported if the briefcase is read-only, or the briefcase contains a version of\r\n * the BisCore ECSchema older than v0.1.11.\r\n * @see [[enterEditingScope]] to enable graphical editing.\r\n */\r\n public async supportsGraphicalEditing(): Promise<boolean> {\r\n return IpcApp.callIpcHost(\"isGraphicalEditingSupported\", this.key);\r\n }\r\n\r\n /** Begin a new graphical editing scope.\r\n * @throws Error if an editing scope already exists or one could not be created.\r\n * @see [[GraphicalEditingScope.exit]] to exit the scope.\r\n * @see [[supportsGraphicalEditing]] to determine whether this method should be expected to succeed.\r\n * @see [[editingScope]] to obtain the current editing scope, if one is in progress.\r\n */\r\n public async enterEditingScope(): Promise<GraphicalEditingScope> {\r\n return this._modelsMonitor.enterEditingScope();\r\n }\r\n\r\n /** Strictly for tests - dispatched from ModelChangeMonitor.processBuffered.\r\n * @internal\r\n */\r\n public readonly onBufferedModelChanges = new BeEvent<(changedModelIds: Set<string>) => void>();\r\n}\r\n"]}
1
+ {"version":3,"file":"BriefcaseConnection.js","sourceRoot":"","sources":["../../src/BriefcaseConnection.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,EAAE,IAAI,EAA0B,YAAY,E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C,iBAAiB;QAC5B,OAAO,IAAI,CAAC,cAAc,CAAC,iBAAiB,EAAE,CAAC;IACjD,CAAC;CAMF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module IModelConnection\r\n */\r\n\r\nimport { assert, BeEvent, CompressedId64Set, Guid, GuidString, Id64String, IModelStatus, OpenMode } from \"@itwin/core-bentley\";\r\nimport {\r\n ChangesetIndex,\r\n ChangesetIndexAndId, IModelConnectionProps, IModelError, OpenBriefcaseProps, StandaloneOpenOptions,\r\n} from \"@itwin/core-common\";\r\nimport { BriefcaseTxns } from \"./BriefcaseTxns\";\r\nimport { GraphicalEditingScope } from \"./GraphicalEditingScope\";\r\nimport { IModelApp } from \"./IModelApp\";\r\nimport { IModelConnection } from \"./IModelConnection\";\r\nimport { IpcApp } from \"./IpcApp\";\r\nimport { disposeTileTreesForGeometricModels } from \"./tile/internal\";\r\nimport { Viewport } from \"./Viewport\";\r\n\r\n/** Keeps track of changes to models, buffering them until synchronization points.\r\n * While a GraphicalEditingScope is open, the changes are buffered until the scope exits, at which point they are processed.\r\n * Otherwise, the buffered changes are processed after undo/redo, commit, or pull+merge changes.\r\n */\r\nclass ModelChangeMonitor {\r\n private _editingScope?: GraphicalEditingScope;\r\n private readonly _briefcase: BriefcaseConnection;\r\n private readonly _deletedModels = new Set<string>();\r\n private readonly _modelIdToGuid = new Map<string, string>();\r\n private readonly _removals: VoidFunction[] = [];\r\n\r\n public constructor(briefcase: BriefcaseConnection) {\r\n this._briefcase = briefcase;\r\n\r\n // Buffer updated geometry guids.\r\n this._removals.push(briefcase.txns.onModelGeometryChanged.addListener((changes) => {\r\n for (const change of changes) {\r\n this._deletedModels.delete(change.id);\r\n this._modelIdToGuid.set(change.id, change.guid);\r\n }\r\n }));\r\n\r\n // Buffer deletions of models.\r\n this._removals.push(briefcase.txns.onModelsChanged.addListener((changes) => {\r\n if (changes.deleted) {\r\n for (const id of CompressedId64Set.iterable(changes.deleted)) {\r\n this._modelIdToGuid.delete(id);\r\n this._deletedModels.add(id);\r\n }\r\n }\r\n }));\r\n\r\n // Outside of an editing scope, we want to update viewport contents after commit, undo/redo, or merging changes.\r\n const maybeProcess = async () => {\r\n if (this.editingScope)\r\n return;\r\n\r\n const modelIds = Array.from(this._modelIdToGuid.keys());\r\n if (modelIds.length > 0)\r\n await IModelApp.tileAdmin.purgeTileTrees(this._briefcase, modelIds);\r\n\r\n this.processBuffered();\r\n };\r\n\r\n this._removals.push(briefcase.txns.onCommitted.addListener(maybeProcess));\r\n this._removals.push(briefcase.txns.onAfterUndoRedo.addListener(maybeProcess));\r\n this._removals.push(briefcase.txns.onChangesPulled.addListener(maybeProcess));\r\n }\r\n\r\n public async close(): Promise<void> {\r\n for (const removal of this._removals)\r\n removal();\r\n\r\n this._removals.length = 0;\r\n\r\n if (this._editingScope) {\r\n await this._editingScope.exit();\r\n this._editingScope = undefined;\r\n }\r\n }\r\n\r\n public get editingScope(): GraphicalEditingScope | undefined {\r\n return this._editingScope;\r\n }\r\n\r\n public async enterEditingScope(): Promise<GraphicalEditingScope> {\r\n if (this._editingScope)\r\n throw new Error(\"Cannot create an editing scope for an iModel that already has one\");\r\n\r\n this._editingScope = await GraphicalEditingScope.enter(this._briefcase);\r\n\r\n const removeGeomListener = this._editingScope.onGeometryChanges.addListener((changes) => {\r\n const modelIds = [];\r\n for (const change of changes)\r\n modelIds.push(change.id);\r\n\r\n this.invalidateScenes(modelIds);\r\n });\r\n\r\n this._editingScope.onExited.addOnce((scope) => {\r\n assert(scope === this._editingScope);\r\n this._editingScope = undefined;\r\n removeGeomListener();\r\n this.processBuffered();\r\n });\r\n\r\n return this._editingScope;\r\n }\r\n\r\n private processBuffered(): void {\r\n const models = this._briefcase.models;\r\n for (const [id, guid] of this._modelIdToGuid) {\r\n const model = models.getLoaded(id)?.asGeometricModel;\r\n if (model)\r\n model.geometryGuid = guid;\r\n }\r\n\r\n const modelIds = new Set<string>(this._modelIdToGuid.keys());\r\n for (const deleted of this._deletedModels) {\r\n modelIds.add(deleted);\r\n models.unload(deleted);\r\n }\r\n\r\n this.invalidateScenes(modelIds);\r\n disposeTileTreesForGeometricModels(modelIds, this._briefcase);\r\n\r\n this._briefcase.onBufferedModelChanges.raiseEvent(modelIds);\r\n\r\n this._modelIdToGuid.clear();\r\n this._deletedModels.clear();\r\n }\r\n\r\n private invalidateScenes(changedModels: Iterable<Id64String>): void {\r\n for (const user of IModelApp.tileAdmin.tileUsers) {\r\n if (user instanceof Viewport && user.iModel === this._briefcase) {\r\n for (const modelId of changedModels) {\r\n if (user.view.viewsModel(modelId)) {\r\n user.invalidateScene();\r\n user.setFeatureOverrideProviderChanged();\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n }\r\n}\r\n\r\n/** Settings that can be used to control the behavior of [[Tool]]s that modify a [[BriefcaseConnection]].\r\n * For example, tools that want to create new elements can consult the briefcase's editor tool settings to\r\n * determine into which model and category to insert the elements.\r\n * Specialized tools are free to ignore these settings.\r\n * @see [[BriefcaseConnection.editorToolSettings]] to query or modify the current settings for a briefcase.\r\n * @see [CreateElementTool]($editor-frontend) for an example of a tool that uses these settings.\r\n * @alpha\r\n */\r\nexport class BriefcaseEditorToolSettings {\r\n private _category?: Id64String;\r\n private _model?: Id64String;\r\n\r\n /** An event raised just after the default [[category]] is changed. */\r\n public readonly onCategoryChanged = new BeEvent<(previousCategory: Id64String | undefined) => void>();\r\n\r\n /** An event raised just after the default [[model]] is changed. */\r\n public readonly onModelChanged = new BeEvent<(previousModel: Id64String | undefined) => void>();\r\n\r\n /** The [Category]($backend) into which new elements should be inserted by default.\r\n * Specialized tools are free to ignore this setting and instead use their own logic to select an appropriate category.\r\n * @see [[onCategoryChanged]] to be notified when this property is modified.\r\n * @see [CreateElementTool.targetCategory]($editor-frontend) for an example of a tool that uses this setting.\r\n */\r\n public get category(): Id64String | undefined {\r\n return this._category;\r\n }\r\n public set category(category: Id64String | undefined) {\r\n const previousCategory = this.category;\r\n if (category !== this.category) {\r\n this._category = category;\r\n this.onCategoryChanged.raiseEvent(previousCategory);\r\n }\r\n }\r\n\r\n /** The [Model]($backend) into which new elements should be inserted by default.\r\n * Specialized tools are free to ignore this setting and instead use their own logic to select an appropriate model.\r\n * @see [[onModelChanged]] to be notified when this property is modified.\r\n * @see [CreateElementTool.targetModel]($editor-frontend) for an example of a tool that uses this setting.\r\n */\r\n public get model(): Id64String | undefined {\r\n return this._model;\r\n }\r\n public set model(model: Id64String | undefined) {\r\n const previousModel = this.model;\r\n if (model !== this.model) {\r\n this._model = model;\r\n this.onModelChanged.raiseEvent(previousModel);\r\n }\r\n }\r\n}\r\n\r\n/** A connection to an editable briefcase on the backend. This class uses [Ipc]($docs/learning/IpcInterface.md) to communicate\r\n * to the backend and may only be used by [[IpcApp]]s.\r\n * @public\r\n */\r\nexport class BriefcaseConnection extends IModelConnection {\r\n protected _isClosed?: boolean;\r\n private readonly _modelsMonitor: ModelChangeMonitor;\r\n /** Default settings that can be used to control the behavior of [[Tool]]s that modify this briefcase.\r\n * @alpha\r\n */\r\n public readonly editorToolSettings = new BriefcaseEditorToolSettings();\r\n\r\n /** Manages local changes to the briefcase via [Txns]($docs/learning/InteractiveEditing.md). */\r\n public readonly txns: BriefcaseTxns;\r\n\r\n /** @internal */\r\n public override isBriefcaseConnection(): this is BriefcaseConnection { return true; }\r\n\r\n /** The Guid that identifies the iTwin that owns this iModel. */\r\n public override get iTwinId(): GuidString { return super.iTwinId!; } // GuidString | undefined for IModelConnection, but required for BriefcaseConnection\r\n\r\n /** The Guid that identifies this iModel. */\r\n public override get iModelId(): GuidString { return super.iModelId!; } // GuidString | undefined for IModelConnection, but required for BriefcaseConnection\r\n\r\n protected constructor(props: IModelConnectionProps, openMode: OpenMode) {\r\n super(props);\r\n this._openMode = openMode;\r\n this.txns = new BriefcaseTxns(this);\r\n this._modelsMonitor = new ModelChangeMonitor(this);\r\n }\r\n\r\n /** Open a BriefcaseConnection to a [BriefcaseDb]($backend). */\r\n public static async openFile(briefcaseProps: OpenBriefcaseProps): Promise<BriefcaseConnection> {\r\n const iModelProps = await IpcApp.appFunctionIpc.openBriefcase(briefcaseProps);\r\n const connection = new this({ ...briefcaseProps, ...iModelProps }, briefcaseProps.readonly ? OpenMode.Readonly : OpenMode.ReadWrite);\r\n IModelConnection.onOpen.raiseEvent(connection);\r\n return connection;\r\n }\r\n\r\n /** Open a BriefcaseConnection to a [StandaloneDb]($backend)\r\n * @note StandaloneDbs, by definition, may not push or pull changes. Attempting to do so will throw exceptions.\r\n */\r\n public static async openStandalone(filePath: string, openMode: OpenMode = OpenMode.ReadWrite, opts?: StandaloneOpenOptions): Promise<BriefcaseConnection> {\r\n const openResponse = await IpcApp.appFunctionIpc.openStandalone(filePath, openMode, opts);\r\n const connection = new this(openResponse, openMode);\r\n IModelConnection.onOpen.raiseEvent(connection);\r\n return connection;\r\n }\r\n\r\n /** Returns `true` if [[close]] has already been called. */\r\n public get isClosed(): boolean { return this._isClosed === true; }\r\n\r\n /**\r\n * Close this BriefcaseConnection.\r\n * @note make sure to call [[saveChanges]] before calling this method. Unsaved local changes are abandoned.\r\n */\r\n public async close(): Promise<void> {\r\n if (this.isClosed)\r\n return;\r\n\r\n await this._modelsMonitor.close();\r\n\r\n this.beforeClose();\r\n this.txns.dispose();\r\n\r\n this._isClosed = true;\r\n await IpcApp.appFunctionIpc.closeIModel(this._fileKey);\r\n }\r\n\r\n private requireTimeline() {\r\n if (this.iTwinId === Guid.empty)\r\n throw new IModelError(IModelStatus.WrongIModel, \"iModel has no timeline\");\r\n }\r\n\r\n /** Query if there are any pending Txns in this briefcase that are waiting to be pushed. */\r\n public async hasPendingTxns(): Promise<boolean> { // eslint-disable-line @itwin/prefer-get\r\n return this.txns.hasPendingTxns();\r\n }\r\n\r\n /** Commit pending changes to this briefcase.\r\n * @param description Optional description of the changes.\r\n */\r\n public async saveChanges(description?: string): Promise<void> {\r\n await IpcApp.appFunctionIpc.saveChanges(this.key, description);\r\n }\r\n\r\n /** Pull (and potentially merge if there are local changes) up to a specified changeset from iModelHub into this briefcase\r\n * @param toIndex The changeset index to pull changes to. If `undefined`, pull all changes.\r\n * @see [[BriefcaseTxns.onChangesPulled]] for the event dispatched after changes are pulled.\r\n */\r\n public async pullChanges(toIndex?: ChangesetIndex): Promise<void> {\r\n this.requireTimeline();\r\n this.changeset = await IpcApp.appFunctionIpc.pullChanges(this.key, toIndex);\r\n }\r\n\r\n /** Create a changeset from local Txns and push to iModelHub. On success, clear Txn table.\r\n * @param description The description for the changeset\r\n * @returns the changesetId of the pushed changes\r\n * @see [[BriefcaseTxns.onChangesPushed]] for the event dispatched after changes are pushed.\r\n */\r\n public async pushChanges(description: string): Promise<ChangesetIndexAndId> {\r\n this.requireTimeline();\r\n return IpcApp.appFunctionIpc.pushChanges(this.key, description);\r\n }\r\n\r\n /** The current graphical editing scope, if one is in progress.\r\n * @see [[enterEditingScope]] to begin graphical editing.\r\n */\r\n public get editingScope(): GraphicalEditingScope | undefined {\r\n return this._modelsMonitor.editingScope;\r\n }\r\n\r\n /** Return whether graphical editing is supported for this briefcase. It is not supported if the briefcase is read-only, or the briefcase contains a version of\r\n * the BisCore ECSchema older than v0.1.11.\r\n * @see [[enterEditingScope]] to enable graphical editing.\r\n */\r\n public async supportsGraphicalEditing(): Promise<boolean> {\r\n return IpcApp.appFunctionIpc.isGraphicalEditingSupported(this.key);\r\n }\r\n\r\n /** Begin a new graphical editing scope.\r\n * @throws Error if an editing scope already exists or one could not be created.\r\n * @see [[GraphicalEditingScope.exit]] to exit the scope.\r\n * @see [[supportsGraphicalEditing]] to determine whether this method should be expected to succeed.\r\n * @see [[editingScope]] to obtain the current editing scope, if one is in progress.\r\n */\r\n public async enterEditingScope(): Promise<GraphicalEditingScope> {\r\n return this._modelsMonitor.enterEditingScope();\r\n }\r\n\r\n /** Strictly for tests - dispatched from ModelChangeMonitor.processBuffered.\r\n * @internal\r\n */\r\n public readonly onBufferedModelChanges = new BeEvent<(changedModelIds: Set<string>) => void>();\r\n}\r\n"]}
@@ -102,31 +102,31 @@ export class BriefcaseTxns extends BriefcaseNotificationHandler {
102
102
  }
103
103
  /** Query if the briefcase has any pending Txns waiting to be pushed. */
104
104
  async hasPendingTxns() {
105
- return IpcApp.callIpcHost("hasPendingTxns", this._iModel.key);
105
+ return IpcApp.appFunctionIpc.hasPendingTxns(this._iModel.key);
106
106
  }
107
107
  /** Determine if any reversible (undoable) changes exist.
108
108
  * @see [[reverseSingleTxn]] or [[reverseAll]] to undo changes.
109
109
  */
110
110
  async isUndoPossible() {
111
- return IpcApp.callIpcHost("isUndoPossible", this._iModel.key);
111
+ return IpcApp.appFunctionIpc.isUndoPossible(this._iModel.key);
112
112
  }
113
113
  /** Determine if any reinstatable (redoable) changes exist.
114
114
  * @see [[reinstateTxn]] to redo changes.
115
115
  */
116
116
  async isRedoPossible() {
117
- return IpcApp.callIpcHost("isRedoPossible", this._iModel.key);
117
+ return IpcApp.appFunctionIpc.isRedoPossible(this._iModel.key);
118
118
  }
119
119
  /** Get the description of the operation that would be reversed by calling [[reverseTxns]]`(1)`.
120
120
  * This is useful for showing the operation that would be undone, for example in a menu.
121
121
  */
122
122
  async getUndoString() {
123
- return IpcApp.callIpcHost("getUndoString", this._iModel.key);
123
+ return IpcApp.appFunctionIpc.getUndoString(this._iModel.key);
124
124
  }
125
125
  /** Get a description of the operation that would be reinstated by calling [[reinstateTxn]].
126
126
  * This is useful for showing the operation that would be redone, in a pull-down menu for example.
127
127
  */
128
128
  async getRedoString() {
129
- return IpcApp.callIpcHost("getRedoString", this._iModel.key);
129
+ return IpcApp.appFunctionIpc.getRedoString(this._iModel.key);
130
130
  }
131
131
  /** Reverse (undo) the most recent operation.
132
132
  * @see [[reinstateTxn]] to redo operations.
@@ -145,7 +145,7 @@ export class BriefcaseTxns extends BriefcaseNotificationHandler {
145
145
  * @note If numOperations is too large only the number of reversible operations are reversed.
146
146
  */
147
147
  async reverseTxns(numOperations) {
148
- return IpcApp.callIpcHost("reverseTxns", this._iModel.key, numOperations);
148
+ return IpcApp.appFunctionIpc.reverseTxns(this._iModel.key, numOperations);
149
149
  }
150
150
  /** Reverse (undo) all changes back to the beginning of the session.
151
151
  * @see [[reinstateTxn]] to redo changes.
@@ -153,7 +153,7 @@ export class BriefcaseTxns extends BriefcaseNotificationHandler {
153
153
  * @see [[isUndoPossible]] to determine if any reversible operations exist.
154
154
  */
155
155
  async reverseAll() {
156
- return IpcApp.callIpcHost("reverseAllTxn", this._iModel.key);
156
+ return IpcApp.appFunctionIpc.reverseAllTxn(this._iModel.key);
157
157
  }
158
158
  /** Reinstate (redo) the most recently reversed transaction. Since at any time multiple transactions can be reversed, it
159
159
  * may take multiple calls to this method to reinstate all reversed operations.
@@ -163,7 +163,7 @@ export class BriefcaseTxns extends BriefcaseNotificationHandler {
163
163
  * @see [[reverseSingleTxn]] or [[reverseAll]] to undo changes.
164
164
  */
165
165
  async reinstateTxn() {
166
- return IpcApp.callIpcHost("reinstateTxn", this._iModel.key);
166
+ return IpcApp.appFunctionIpc.reinstateTxn(this._iModel.key);
167
167
  }
168
168
  /** Restart the current TxnManager session. This causes all Txns in the current session to no longer be undoable (as if the file was closed
169
169
  * and reopened.)
@@ -172,7 +172,7 @@ export class BriefcaseTxns extends BriefcaseNotificationHandler {
172
172
  * Probably a good idea to alert the user it happened.
173
173
  */
174
174
  async restartTxnSession() {
175
- await IpcApp.callIpcHost("restartTxnSession", this._iModel.key);
175
+ await IpcApp.appFunctionIpc.restartTxnSession(this._iModel.key);
176
176
  }
177
177
  /** @internal */
178
178
  notifyElementsChanged(changed) {
@@ -1 +1 @@
1
- {"version":3,"file":"BriefcaseTxns.js","sourceRoot":"","sources":["../../src/BriefcaseTxns.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,qBAA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C;IAED,gBAAgB;IACT,yBAAyB,CAAC,MAAgB;QAC/C,IAAI,CAAC,OAAO,CAAC,YAAY,GAAG,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACvD,CAAC;IAED,gBAAgB;IACT,yBAAyB,CAAC,IAAmC;QAClE,IAAI,CAAC,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACxE,CAAC;IAED,gBAAgB;IACT,uCAAuC,CAAC,GAAmC;QAChF,IAAI,CAAC,OAAO,CAAC,0BAA0B,GAAG,GAAG,CAAC,CAAC,CAAC,IAAI,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACrF,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module IModelConnection\r\n */\r\n\r\nimport { BeEvent } from \"@itwin/core-bentley\";\r\nimport { Point3d, Range3d, Range3dProps, XYZProps } from \"@itwin/core-geometry\";\r\nimport {\r\n ChangedEntities, ChangesetIndexAndId, EcefLocation, EcefLocationProps, GeographicCRS, GeographicCRSProps, IModelStatus, IpcAppChannel, ModelIdAndGeometryGuid,\r\n RemoveFunction, RootSubjectProps, TxnNotifications,\r\n} from \"@itwin/core-common\";\r\nimport { BriefcaseConnection } from \"./BriefcaseConnection\";\r\nimport { IpcApp, NotificationHandler } from \"./IpcApp\";\r\n\r\n/**\r\n * Base class for notification handlers for events from the backend that are specific to a [[BriefcaseConnection]].\r\n * @see [[BriefcaseTxns]].\r\n * @public\r\n */\r\nexport abstract class BriefcaseNotificationHandler extends NotificationHandler {\r\n constructor(private _key: string) { super(); }\r\n public abstract get briefcaseChannelName(): string;\r\n public get channelName() { return `${this.briefcaseChannelName}:${this._key}`; }\r\n}\r\n\r\n/** Manages local changes to a [[BriefcaseConnection]] via [Txns]($docs/learning/InteractiveEditing.md).\r\n * @see [[BriefcaseConnection.txns]].\r\n * @see [TxnManager]($backend) for the backend counterpart.\r\n * @public\r\n */\r\nexport class BriefcaseTxns extends BriefcaseNotificationHandler implements TxnNotifications {\r\n private readonly _iModel: BriefcaseConnection;\r\n private _cleanup?: RemoveFunction;\r\n\r\n /** @internal */\r\n public get briefcaseChannelName() {\r\n return IpcAppChannel.Txns;\r\n }\r\n\r\n /** Event raised after Txn validation or changeset application to indicate the set of changed elements.\r\n * @note If there are many changed elements in a single Txn, the notifications are sent in batches so this event *may be called multiple times* per Txn.\r\n */\r\n public readonly onElementsChanged = new BeEvent<(changes: Readonly<ChangedEntities>) => void>();\r\n\r\n /** Event raised after Txn validation or changeset application to indicate the set of changed models.\r\n * @note If there are many changed models in a single Txn, the notifications are sent in batches so this event *may be called multiple times* per Txn.\r\n */\r\n public readonly onModelsChanged = new BeEvent<(changes: Readonly<ChangedEntities>) => void>();\r\n\r\n /** Event raised after the geometry within one or more [[GeometricModelState]]s is modified by applying a changeset or validation of a transaction.\r\n * A model's geometry can change as a result of:\r\n * - Insertion or deletion of a geometric element within the model; or\r\n * - Modification of an existing element's geometric properties; or\r\n * - An explicit request to flag it as changed via [IModelDb.Models.updateModel]($backend).\r\n */\r\n public readonly onModelGeometryChanged = new BeEvent<(changes: ReadonlyArray<ModelIdAndGeometryGuid>) => void>();\r\n\r\n /** Event raised before a commit operation is performed. Initiated by a call to [[BriefcaseConnection.saveChanges]], unless there are no changes to save.\r\n * @see [[onCommitted]] for the event raised after the operation.\r\n */\r\n public readonly onCommit = new BeEvent<() => void>();\r\n\r\n /** Event raised after a commit operation is performed. Initiated by a call to [[BriefcaseConnection.saveChanges]], even if there were no changes to save.\r\n * The event supplies the following information:\r\n * - `hasPendingTxns`: true if the briefcase has local changes not yet pushed to the server.\r\n * - `time`: the time at which changes were saved on the backend (obtained via `Date.now()`).\r\n * @see [[onCommit]] for the event raised before the operation.\r\n */\r\n public readonly onCommitted = new BeEvent<(hasPendingTxns: boolean, time: number) => void>();\r\n\r\n /** Event raised after a changeset has been applied to the briefcase.\r\n * Changesets may be applied as a result of [[BriefcaseConnection.pullChanges]], or by undo/redo operations.\r\n */\r\n public readonly onChangesApplied = new BeEvent<() => void>();\r\n\r\n /** Event raised before an undo/redo operation is performed.\r\n * @see [[onAfterUndoRedo]] for the event raised after the operation.\r\n */\r\n public readonly onBeforeUndoRedo = new BeEvent<(isUndo: boolean) => void>();\r\n\r\n /** Event raised after an undo/redo operation is performed.\r\n * @see [[onBeforeUndoRedo]] for the event raised before to the operation.\r\n */\r\n public readonly onAfterUndoRedo = new BeEvent<(isUndo: boolean) => void>();\r\n\r\n /** Event raised after changes are pulled and merged into the briefcase.\r\n * @see [[BriefcaseConnection.pullAndMergeChanges]].\r\n */\r\n public readonly onChangesPulled = new BeEvent<(parentChangeset: ChangesetIndexAndId) => void>();\r\n\r\n /** Event raised after the briefcase's local changes are pushed.\r\n * @see [[BriefcaseConnection.pushChanges]].\r\n */\r\n public readonly onChangesPushed = new BeEvent<(parentChangeset: ChangesetIndexAndId) => void>();\r\n\r\n /** @internal */\r\n public constructor(iModel: BriefcaseConnection) {\r\n super(iModel.key);\r\n this._iModel = iModel;\r\n this._cleanup = this.registerImpl();\r\n }\r\n\r\n /** @internal */\r\n public dispose(): void {\r\n if (this._cleanup) {\r\n this._cleanup();\r\n this._cleanup = undefined;\r\n\r\n this.onElementsChanged.clear();\r\n this.onModelsChanged.clear();\r\n this.onModelGeometryChanged.clear();\r\n this.onCommit.clear();\r\n this.onCommitted.clear();\r\n this.onChangesApplied.clear();\r\n this.onBeforeUndoRedo.clear();\r\n this.onAfterUndoRedo.clear();\r\n this.onChangesPulled.clear();\r\n this.onChangesPushed.clear();\r\n }\r\n }\r\n\r\n /** Query if the briefcase has any pending Txns waiting to be pushed. */\r\n public async hasPendingTxns(): Promise<boolean> { // eslint-disable-line @itwin/prefer-get\r\n return IpcApp.callIpcHost(\"hasPendingTxns\", this._iModel.key);\r\n }\r\n\r\n /** Determine if any reversible (undoable) changes exist.\r\n * @see [[reverseSingleTxn]] or [[reverseAll]] to undo changes.\r\n */\r\n public async isUndoPossible(): Promise<boolean> { // eslint-disable-line @itwin/prefer-get\r\n return IpcApp.callIpcHost(\"isUndoPossible\", this._iModel.key);\r\n }\r\n\r\n /** Determine if any reinstatable (redoable) changes exist.\r\n * @see [[reinstateTxn]] to redo changes.\r\n */\r\n public async isRedoPossible(): Promise<boolean> { // eslint-disable-line @itwin/prefer-get\r\n return IpcApp.callIpcHost(\"isRedoPossible\", this._iModel.key);\r\n }\r\n\r\n /** Get the description of the operation that would be reversed by calling [[reverseTxns]]`(1)`.\r\n * This is useful for showing the operation that would be undone, for example in a menu.\r\n */\r\n public async getUndoString(): Promise<string> {\r\n return IpcApp.callIpcHost(\"getUndoString\", this._iModel.key);\r\n }\r\n\r\n /** Get a description of the operation that would be reinstated by calling [[reinstateTxn]].\r\n * This is useful for showing the operation that would be redone, in a pull-down menu for example.\r\n */\r\n public async getRedoString(): Promise<string> {\r\n return IpcApp.callIpcHost(\"getRedoString\", this._iModel.key);\r\n }\r\n\r\n /** Reverse (undo) the most recent operation.\r\n * @see [[reinstateTxn]] to redo operations.\r\n * @see [[reverseAll]] to undo all operations.\r\n * @see [[isUndoPossible]] to determine if any reversible operations exist.\r\n */\r\n public async reverseSingleTxn(): Promise<IModelStatus> {\r\n return this.reverseTxns(1);\r\n }\r\n\r\n /** Reverse (undo) the most recent operation(s) to the briefcase in the current session.\r\n * @param numOperations the number of operations to reverse. If this is greater than 1, the entire set of operations will\r\n * be reinstated together when/if [[reinstateTxn]] is called.\r\n * @note If there are any outstanding uncommitted changes, they are reversed.\r\n * @note The term \"operation\" is used rather than Txn, since multiple Txns can be grouped together via [TxnManager.beginMultiTxnOperation]($backend). So,\r\n * even if numOperations is 1, multiple Txns may be reversed if they were grouped together when they were made.\r\n * @note If numOperations is too large only the number of reversible operations are reversed.\r\n */\r\n public async reverseTxns(numOperations: number): Promise<IModelStatus> {\r\n return IpcApp.callIpcHost(\"reverseTxns\", this._iModel.key, numOperations);\r\n }\r\n\r\n /** Reverse (undo) all changes back to the beginning of the session.\r\n * @see [[reinstateTxn]] to redo changes.\r\n * @see [[reverseSingleTxn]] to undo only the most recent operation.\r\n * @see [[isUndoPossible]] to determine if any reversible operations exist.\r\n */\r\n public async reverseAll(): Promise<IModelStatus> {\r\n return IpcApp.callIpcHost(\"reverseAllTxn\", this._iModel.key);\r\n }\r\n\r\n /** Reinstate (redo) the most recently reversed transaction. Since at any time multiple transactions can be reversed, it\r\n * may take multiple calls to this method to reinstate all reversed operations.\r\n * @returns Success if a reversed transaction was reinstated, error status otherwise.\r\n * @note If there are any outstanding uncommitted changes, they are canceled before the Txn is reinstated.\r\n * @see [[isRedoPossible]] to determine if any reinstatable operations exist.\r\n * @see [[reverseSingleTxn]] or [[reverseAll]] to undo changes.\r\n */\r\n public async reinstateTxn(): Promise<IModelStatus> {\r\n return IpcApp.callIpcHost(\"reinstateTxn\", this._iModel.key);\r\n }\r\n\r\n /** Restart the current TxnManager session. This causes all Txns in the current session to no longer be undoable (as if the file was closed\r\n * and reopened.)\r\n * @note This can be quite disconcerting to the user expecting to be able to undo previously made changes. It should only be used\r\n * under extreme circumstances where damage to the file or session could happen if the currently committed are reversed. Use sparingly and with care.\r\n * Probably a good idea to alert the user it happened.\r\n */\r\n public async restartTxnSession(): Promise<void> {\r\n await IpcApp.callIpcHost(\"restartTxnSession\", this._iModel.key);\r\n }\r\n\r\n /** @internal */\r\n public notifyElementsChanged(changed: ChangedEntities): void {\r\n this.onElementsChanged.raiseEvent(changed);\r\n }\r\n\r\n /** @internal */\r\n public notifyModelsChanged(changed: ChangedEntities): void {\r\n this.onModelsChanged.raiseEvent(changed);\r\n }\r\n\r\n /** @internal */\r\n public notifyGeometryGuidsChanged(changes: ModelIdAndGeometryGuid[]): void {\r\n this.onModelGeometryChanged.raiseEvent(changes);\r\n }\r\n\r\n /** @internal */\r\n public notifyCommit() {\r\n this.onCommit.raiseEvent();\r\n }\r\n\r\n /** @internal */\r\n public notifyCommitted(hasPendingTxns: boolean, time: number) {\r\n this.onCommitted.raiseEvent(hasPendingTxns, time);\r\n }\r\n\r\n /** @internal */\r\n public notifyChangesApplied() {\r\n this.onChangesApplied.raiseEvent();\r\n }\r\n\r\n /** @internal */\r\n public notifyBeforeUndoRedo(isUndo: boolean) {\r\n this.onBeforeUndoRedo.raiseEvent(isUndo);\r\n }\r\n\r\n /** @internal */\r\n public notifyAfterUndoRedo(isUndo: boolean) {\r\n this.onAfterUndoRedo.raiseEvent(isUndo);\r\n }\r\n\r\n /** @internal */\r\n public notifyPulledChanges(parentChangeset: ChangesetIndexAndId) {\r\n this.onChangesPulled.raiseEvent(parentChangeset);\r\n }\r\n\r\n /** @internal */\r\n public notifyPushedChanges(parentChangeset: ChangesetIndexAndId) {\r\n this.onChangesPushed.raiseEvent(parentChangeset);\r\n }\r\n\r\n /** @internal */\r\n public notifyIModelNameChanged(name: string) {\r\n this._iModel.name = name;\r\n }\r\n\r\n /** @internal */\r\n public notifyRootSubjectChanged(subject: RootSubjectProps) {\r\n this._iModel.rootSubject = subject;\r\n }\r\n\r\n /** @internal */\r\n public notifyProjectExtentsChanged(range: Range3dProps) {\r\n this._iModel.projectExtents = Range3d.fromJSON(range);\r\n }\r\n\r\n /** @internal */\r\n public notifyGlobalOriginChanged(origin: XYZProps) {\r\n this._iModel.globalOrigin = Point3d.fromJSON(origin);\r\n }\r\n\r\n /** @internal */\r\n public notifyEcefLocationChanged(ecef: EcefLocationProps | undefined) {\r\n this._iModel.ecefLocation = ecef ? new EcefLocation(ecef) : undefined;\r\n }\r\n\r\n /** @internal */\r\n public notifyGeographicCoordinateSystemChanged(gcs: GeographicCRSProps | undefined) {\r\n this._iModel.geographicCoordinateSystem = gcs ? new GeographicCRS(gcs) : undefined;\r\n }\r\n}\r\n"]}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;IACrC,CAAC;IAED,gBAAgB;IACT,2BAA2B,CAAC,KAAmB;QACpD,IAAI,CAAC,OAAO,CAAC,cAAc,GAAG,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACxD,CAAC;IAED,gBAAgB;IACT,yBAAyB,CAAC,MAAgB;QAC/C,IAAI,CAAC,OAAO,CAAC,YAAY,GAAG,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACvD,CAAC;IAED,gBAAgB;IACT,yBAAyB,CAAC,IAAmC;QAClE,IAAI,CAAC,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACxE,CAAC;IAED,gBAAgB;IACT,uCAAuC,CAAC,GAAmC;QAChF,IAAI,CAAC,OAAO,CAAC,0BAA0B,GAAG,GAAG,CAAC,CAAC,CAAC,IAAI,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACrF,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module IModelConnection\r\n */\r\n\r\nimport { BeEvent } from \"@itwin/core-bentley\";\r\nimport { Point3d, Range3d, Range3dProps, XYZProps } from \"@itwin/core-geometry\";\r\nimport {\r\n ChangedEntities, ChangesetIndexAndId, EcefLocation, EcefLocationProps, GeographicCRS, GeographicCRSProps, IModelStatus, IpcAppChannel, ModelIdAndGeometryGuid,\r\n RemoveFunction, RootSubjectProps, TxnNotifications,\r\n} from \"@itwin/core-common\";\r\nimport { BriefcaseConnection } from \"./BriefcaseConnection\";\r\nimport { IpcApp, NotificationHandler } from \"./IpcApp\";\r\n\r\n/**\r\n * Base class for notification handlers for events from the backend that are specific to a [[BriefcaseConnection]].\r\n * @see [[BriefcaseTxns]].\r\n * @public\r\n */\r\nexport abstract class BriefcaseNotificationHandler extends NotificationHandler {\r\n constructor(private _key: string) { super(); }\r\n public abstract get briefcaseChannelName(): string;\r\n public get channelName() { return `${this.briefcaseChannelName}:${this._key}`; }\r\n}\r\n\r\n/** Manages local changes to a [[BriefcaseConnection]] via [Txns]($docs/learning/InteractiveEditing.md).\r\n * @see [[BriefcaseConnection.txns]].\r\n * @see [TxnManager]($backend) for the backend counterpart.\r\n * @public\r\n */\r\nexport class BriefcaseTxns extends BriefcaseNotificationHandler implements TxnNotifications {\r\n private readonly _iModel: BriefcaseConnection;\r\n private _cleanup?: RemoveFunction;\r\n\r\n /** @internal */\r\n public get briefcaseChannelName() {\r\n return IpcAppChannel.Txns;\r\n }\r\n\r\n /** Event raised after Txn validation or changeset application to indicate the set of changed elements.\r\n * @note If there are many changed elements in a single Txn, the notifications are sent in batches so this event *may be called multiple times* per Txn.\r\n */\r\n public readonly onElementsChanged = new BeEvent<(changes: Readonly<ChangedEntities>) => void>();\r\n\r\n /** Event raised after Txn validation or changeset application to indicate the set of changed models.\r\n * @note If there are many changed models in a single Txn, the notifications are sent in batches so this event *may be called multiple times* per Txn.\r\n */\r\n public readonly onModelsChanged = new BeEvent<(changes: Readonly<ChangedEntities>) => void>();\r\n\r\n /** Event raised after the geometry within one or more [[GeometricModelState]]s is modified by applying a changeset or validation of a transaction.\r\n * A model's geometry can change as a result of:\r\n * - Insertion or deletion of a geometric element within the model; or\r\n * - Modification of an existing element's geometric properties; or\r\n * - An explicit request to flag it as changed via [IModelDb.Models.updateModel]($backend).\r\n */\r\n public readonly onModelGeometryChanged = new BeEvent<(changes: ReadonlyArray<ModelIdAndGeometryGuid>) => void>();\r\n\r\n /** Event raised before a commit operation is performed. Initiated by a call to [[BriefcaseConnection.saveChanges]], unless there are no changes to save.\r\n * @see [[onCommitted]] for the event raised after the operation.\r\n */\r\n public readonly onCommit = new BeEvent<() => void>();\r\n\r\n /** Event raised after a commit operation is performed. Initiated by a call to [[BriefcaseConnection.saveChanges]], even if there were no changes to save.\r\n * The event supplies the following information:\r\n * - `hasPendingTxns`: true if the briefcase has local changes not yet pushed to the server.\r\n * - `time`: the time at which changes were saved on the backend (obtained via `Date.now()`).\r\n * @see [[onCommit]] for the event raised before the operation.\r\n */\r\n public readonly onCommitted = new BeEvent<(hasPendingTxns: boolean, time: number) => void>();\r\n\r\n /** Event raised after a changeset has been applied to the briefcase.\r\n * Changesets may be applied as a result of [[BriefcaseConnection.pullChanges]], or by undo/redo operations.\r\n */\r\n public readonly onChangesApplied = new BeEvent<() => void>();\r\n\r\n /** Event raised before an undo/redo operation is performed.\r\n * @see [[onAfterUndoRedo]] for the event raised after the operation.\r\n */\r\n public readonly onBeforeUndoRedo = new BeEvent<(isUndo: boolean) => void>();\r\n\r\n /** Event raised after an undo/redo operation is performed.\r\n * @see [[onBeforeUndoRedo]] for the event raised before to the operation.\r\n */\r\n public readonly onAfterUndoRedo = new BeEvent<(isUndo: boolean) => void>();\r\n\r\n /** Event raised after changes are pulled and merged into the briefcase.\r\n * @see [[BriefcaseConnection.pullAndMergeChanges]].\r\n */\r\n public readonly onChangesPulled = new BeEvent<(parentChangeset: ChangesetIndexAndId) => void>();\r\n\r\n /** Event raised after the briefcase's local changes are pushed.\r\n * @see [[BriefcaseConnection.pushChanges]].\r\n */\r\n public readonly onChangesPushed = new BeEvent<(parentChangeset: ChangesetIndexAndId) => void>();\r\n\r\n /** @internal */\r\n public constructor(iModel: BriefcaseConnection) {\r\n super(iModel.key);\r\n this._iModel = iModel;\r\n this._cleanup = this.registerImpl();\r\n }\r\n\r\n /** @internal */\r\n public dispose(): void {\r\n if (this._cleanup) {\r\n this._cleanup();\r\n this._cleanup = undefined;\r\n\r\n this.onElementsChanged.clear();\r\n this.onModelsChanged.clear();\r\n this.onModelGeometryChanged.clear();\r\n this.onCommit.clear();\r\n this.onCommitted.clear();\r\n this.onChangesApplied.clear();\r\n this.onBeforeUndoRedo.clear();\r\n this.onAfterUndoRedo.clear();\r\n this.onChangesPulled.clear();\r\n this.onChangesPushed.clear();\r\n }\r\n }\r\n\r\n /** Query if the briefcase has any pending Txns waiting to be pushed. */\r\n public async hasPendingTxns(): Promise<boolean> { // eslint-disable-line @itwin/prefer-get\r\n return IpcApp.appFunctionIpc.hasPendingTxns(this._iModel.key);\r\n }\r\n\r\n /** Determine if any reversible (undoable) changes exist.\r\n * @see [[reverseSingleTxn]] or [[reverseAll]] to undo changes.\r\n */\r\n public async isUndoPossible(): Promise<boolean> { // eslint-disable-line @itwin/prefer-get\r\n return IpcApp.appFunctionIpc.isUndoPossible(this._iModel.key);\r\n }\r\n\r\n /** Determine if any reinstatable (redoable) changes exist.\r\n * @see [[reinstateTxn]] to redo changes.\r\n */\r\n public async isRedoPossible(): Promise<boolean> { // eslint-disable-line @itwin/prefer-get\r\n return IpcApp.appFunctionIpc.isRedoPossible(this._iModel.key);\r\n }\r\n\r\n /** Get the description of the operation that would be reversed by calling [[reverseTxns]]`(1)`.\r\n * This is useful for showing the operation that would be undone, for example in a menu.\r\n */\r\n public async getUndoString(): Promise<string> {\r\n return IpcApp.appFunctionIpc.getUndoString(this._iModel.key);\r\n }\r\n\r\n /** Get a description of the operation that would be reinstated by calling [[reinstateTxn]].\r\n * This is useful for showing the operation that would be redone, in a pull-down menu for example.\r\n */\r\n public async getRedoString(): Promise<string> {\r\n return IpcApp.appFunctionIpc.getRedoString(this._iModel.key);\r\n }\r\n\r\n /** Reverse (undo) the most recent operation.\r\n * @see [[reinstateTxn]] to redo operations.\r\n * @see [[reverseAll]] to undo all operations.\r\n * @see [[isUndoPossible]] to determine if any reversible operations exist.\r\n */\r\n public async reverseSingleTxn(): Promise<IModelStatus> {\r\n return this.reverseTxns(1);\r\n }\r\n\r\n /** Reverse (undo) the most recent operation(s) to the briefcase in the current session.\r\n * @param numOperations the number of operations to reverse. If this is greater than 1, the entire set of operations will\r\n * be reinstated together when/if [[reinstateTxn]] is called.\r\n * @note If there are any outstanding uncommitted changes, they are reversed.\r\n * @note The term \"operation\" is used rather than Txn, since multiple Txns can be grouped together via [TxnManager.beginMultiTxnOperation]($backend). So,\r\n * even if numOperations is 1, multiple Txns may be reversed if they were grouped together when they were made.\r\n * @note If numOperations is too large only the number of reversible operations are reversed.\r\n */\r\n public async reverseTxns(numOperations: number): Promise<IModelStatus> {\r\n return IpcApp.appFunctionIpc.reverseTxns(this._iModel.key, numOperations);\r\n }\r\n\r\n /** Reverse (undo) all changes back to the beginning of the session.\r\n * @see [[reinstateTxn]] to redo changes.\r\n * @see [[reverseSingleTxn]] to undo only the most recent operation.\r\n * @see [[isUndoPossible]] to determine if any reversible operations exist.\r\n */\r\n public async reverseAll(): Promise<IModelStatus> {\r\n return IpcApp.appFunctionIpc.reverseAllTxn(this._iModel.key);\r\n }\r\n\r\n /** Reinstate (redo) the most recently reversed transaction. Since at any time multiple transactions can be reversed, it\r\n * may take multiple calls to this method to reinstate all reversed operations.\r\n * @returns Success if a reversed transaction was reinstated, error status otherwise.\r\n * @note If there are any outstanding uncommitted changes, they are canceled before the Txn is reinstated.\r\n * @see [[isRedoPossible]] to determine if any reinstatable operations exist.\r\n * @see [[reverseSingleTxn]] or [[reverseAll]] to undo changes.\r\n */\r\n public async reinstateTxn(): Promise<IModelStatus> {\r\n return IpcApp.appFunctionIpc.reinstateTxn(this._iModel.key);\r\n }\r\n\r\n /** Restart the current TxnManager session. This causes all Txns in the current session to no longer be undoable (as if the file was closed\r\n * and reopened.)\r\n * @note This can be quite disconcerting to the user expecting to be able to undo previously made changes. It should only be used\r\n * under extreme circumstances where damage to the file or session could happen if the currently committed are reversed. Use sparingly and with care.\r\n * Probably a good idea to alert the user it happened.\r\n */\r\n public async restartTxnSession(): Promise<void> {\r\n await IpcApp.appFunctionIpc.restartTxnSession(this._iModel.key);\r\n }\r\n\r\n /** @internal */\r\n public notifyElementsChanged(changed: ChangedEntities): void {\r\n this.onElementsChanged.raiseEvent(changed);\r\n }\r\n\r\n /** @internal */\r\n public notifyModelsChanged(changed: ChangedEntities): void {\r\n this.onModelsChanged.raiseEvent(changed);\r\n }\r\n\r\n /** @internal */\r\n public notifyGeometryGuidsChanged(changes: ModelIdAndGeometryGuid[]): void {\r\n this.onModelGeometryChanged.raiseEvent(changes);\r\n }\r\n\r\n /** @internal */\r\n public notifyCommit() {\r\n this.onCommit.raiseEvent();\r\n }\r\n\r\n /** @internal */\r\n public notifyCommitted(hasPendingTxns: boolean, time: number) {\r\n this.onCommitted.raiseEvent(hasPendingTxns, time);\r\n }\r\n\r\n /** @internal */\r\n public notifyChangesApplied() {\r\n this.onChangesApplied.raiseEvent();\r\n }\r\n\r\n /** @internal */\r\n public notifyBeforeUndoRedo(isUndo: boolean) {\r\n this.onBeforeUndoRedo.raiseEvent(isUndo);\r\n }\r\n\r\n /** @internal */\r\n public notifyAfterUndoRedo(isUndo: boolean) {\r\n this.onAfterUndoRedo.raiseEvent(isUndo);\r\n }\r\n\r\n /** @internal */\r\n public notifyPulledChanges(parentChangeset: ChangesetIndexAndId) {\r\n this.onChangesPulled.raiseEvent(parentChangeset);\r\n }\r\n\r\n /** @internal */\r\n public notifyPushedChanges(parentChangeset: ChangesetIndexAndId) {\r\n this.onChangesPushed.raiseEvent(parentChangeset);\r\n }\r\n\r\n /** @internal */\r\n public notifyIModelNameChanged(name: string) {\r\n this._iModel.name = name;\r\n }\r\n\r\n /** @internal */\r\n public notifyRootSubjectChanged(subject: RootSubjectProps) {\r\n this._iModel.rootSubject = subject;\r\n }\r\n\r\n /** @internal */\r\n public notifyProjectExtentsChanged(range: Range3dProps) {\r\n this._iModel.projectExtents = Range3d.fromJSON(range);\r\n }\r\n\r\n /** @internal */\r\n public notifyGlobalOriginChanged(origin: XYZProps) {\r\n this._iModel.globalOrigin = Point3d.fromJSON(origin);\r\n }\r\n\r\n /** @internal */\r\n public notifyEcefLocationChanged(ecef: EcefLocationProps | undefined) {\r\n this._iModel.ecefLocation = ecef ? new EcefLocation(ecef) : undefined;\r\n }\r\n\r\n /** @internal */\r\n public notifyGeographicCoordinateSystemChanged(gcs: GeographicCRSProps | undefined) {\r\n this._iModel.geographicCoordinateSystem = gcs ? new GeographicCRS(gcs) : undefined;\r\n }\r\n}\r\n"]}
@@ -73,7 +73,7 @@ export class GraphicalEditingScope extends BriefcaseNotificationHandler {
73
73
  // Register the scope synchronously, in case enter() is called again for same iModel while awaiting asynchronous initialization.
74
74
  const scope = new GraphicalEditingScope(imodel);
75
75
  try {
76
- const scopeStarted = await IpcApp.callIpcHost("toggleGraphicalEditingScope", imodel.key, true);
76
+ const scopeStarted = await IpcApp.appFunctionIpc.toggleGraphicalEditingScope(imodel.key, true);
77
77
  assert(scopeStarted); // If it didn't, the backend threw an error.
78
78
  }
79
79
  catch (e) {
@@ -95,7 +95,7 @@ export class GraphicalEditingScope extends BriefcaseNotificationHandler {
95
95
  this.onExiting.raiseEvent(this);
96
96
  }
97
97
  finally {
98
- const scopeExited = await IpcApp.callIpcHost("toggleGraphicalEditingScope", this.iModel.key, false);
98
+ const scopeExited = await IpcApp.appFunctionIpc.toggleGraphicalEditingScope(this.iModel.key, false);
99
99
  assert(!scopeExited);
100
100
  try {
101
101
  this.onExited.raiseEvent(this);
@@ -1 +1 @@
1
- {"version":3,"file":"GraphicalEditingScope.js","sourceRoot":"","sources":["../../src/GraphicalEditingScope.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,eAAe,EAA0B,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEtI,OAAO,EAC6C,aAAa,EAAE,oBAAoB,GACtF,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,4BAA4B,EAAE,MAAM,iBAAiB,CAAC;AAE/D,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,MAAM,YAAa,SAAQ,WAAkC;IAI3D,YAAmB,YAAwB,EAAE,KAAc;QACzD,KAAK,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AAY,GAAG,YAAY,CAAC,YAAY,CAAC;oBAC9C,YAAY,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;iBACtC;gBAED,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;gBAC3B,IAAI,QAAQ,CAAC,MAAM,KAAK,aAAa,CAAC,IAAI,EAAE;oBAC1C,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;oBAClD,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,aAAa,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;iBACxD;aACF;SACF;QAED,IAAI,CAAC,iBAAiB,CAAC,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACnD,CAAC;;AAxID;;GAEG;AACoB,6BAAO,GAAG,IAAI,OAAO,EAA0C,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module IModelConnection\r\n */\r\n\r\nimport { assert, BeEvent, compareStrings, DbOpcode, DuplicatePolicy, GuidString, Id64String, SortedArray } from \"@itwin/core-bentley\";\r\nimport { Range3d } from \"@itwin/core-geometry\";\r\nimport {\r\n EditingScopeNotifications, ElementGeometryChange, IpcAppChannel, ModelGeometryChanges, ModelGeometryChangesProps, RemoveFunction,\r\n} from \"@itwin/core-common\";\r\nimport { BriefcaseNotificationHandler } from \"./BriefcaseTxns\";\r\nimport { BriefcaseConnection } from \"./BriefcaseConnection\";\r\nimport { IpcApp } from \"./IpcApp\";\r\n\r\nclass ModelChanges extends SortedArray<ElementGeometryChange> {\r\n public geometryGuid: GuidString;\r\n public readonly range: Range3d;\r\n\r\n public constructor(geometryGuid: GuidString, range: Range3d) {\r\n super((lhs, rhs) => compareStrings(lhs.id, rhs.id), DuplicatePolicy.Replace);\r\n this.geometryGuid = geometryGuid;\r\n this.range = range;\r\n }\r\n}\r\n\r\n/** Represents a period of time within an [interactive editing]($docs/learning/InteractiveEditing.md) session during which the\r\n * geometry of elements being displayed in one or more [[Viewport]]s is being modified. Outside of such a scope, whenever the\r\n * geometry within a [GeometricModel]($backend) changes new [[Tile]]s must be generated to reflect those changes in a viewport.\r\n * Regenerating entire tiles each time individual elements change can be time-consuming, which may introduce an unacceptable delay\r\n * between making a modification and seeing its result on the screen.\r\n *\r\n * Within the context of a graphical editing scope, no new tiles are generated. Instead, the geometry for any deleted or modified elements\r\n * is hidden in the tile graphics, and additional temporary graphics are displayed for any newly-inserted or modified elements. Only when the\r\n * scope exits are new tiles produced.\r\n *\r\n * The application decides when to enter and exit a graphical editing scope. A single interactive editing session may involve any number of\r\n * editing scopes. Typically, applications will enter a new editing scope (after first exiting a previous scope, if one exists):\r\n * - When switching from a non-graphical workflow to one that involves editing geometry; or\r\n * - When changing which geometric model is being edited; or\r\n * - After performing an operation that creates or modifies a \"large\" number (perhaps hundreds?) of elements.\r\n *\r\n * An application should typically exit any graphical editing scope before:\r\n * - Pulling changesets; or\r\n * - Switching from a graphical editing workflow to some non-graphical workflow.\r\n *\r\n * Graphical editing scopes are only supported for [[BriefcaseConnection]]s opened in read-write mode that contain version 1.0.11 or newer of the BisCore schema.\r\n * @see [[BriefcaseConnection.enterEditingScope]] to create a scope for a briefcase.\r\n * @see [[BriefcaseConnection.editingScope]] to obtain a briefcase's current scope.\r\n * @see [[exit]] to terminate a scope.\r\n * @public\r\n */\r\nexport class GraphicalEditingScope extends BriefcaseNotificationHandler implements EditingScopeNotifications {\r\n public get briefcaseChannelName() { return IpcAppChannel.EditingScope; }\r\n\r\n /** Maps model Id to accumulated changes to geometric elements within the associated model. */\r\n private readonly _geometryChanges = new Map<Id64String, ModelChanges>();\r\n private _disposed = false;\r\n private _cleanup?: RemoveFunction;\r\n\r\n /** The connection to the iModel being edited. */\r\n public readonly iModel: BriefcaseConnection;\r\n\r\n /** Event raised when a new scope is created for any [[BriefcaseConnection]].\r\n * @see [[onExiting]] and [[onExited]] for complementary events.\r\n */\r\n public static readonly onEnter = new BeEvent<(scope: GraphicalEditingScope) => void>();\r\n\r\n /** Event raised when this scope is about to exit.\r\n * @see [[onEnter]] for the complementary event.\r\n * @see [[onExited]] for an event raised after the scope exits.\r\n */\r\n public readonly onExiting = new BeEvent<(scope: GraphicalEditingScope) => void>();\r\n\r\n /** Event raised when this scope has exited.\r\n * @see [[onEnter]] for the complementary event.\r\n * @see [[onExiting]] for an event raised just before the scope is exited.\r\n */\r\n public readonly onExited = new BeEvent<(scope: GraphicalEditingScope) => void>();\r\n\r\n /** Event raised after geometric changes are written to the iModel. */\r\n public readonly onGeometryChanges = new BeEvent<(changes: Iterable<ModelGeometryChanges>, scope: GraphicalEditingScope) => void>();\r\n\r\n /** Don't call this directly - use BriefcaseConnection.enterEditingScope.\r\n * @internal\r\n */\r\n public static async enter(imodel: BriefcaseConnection): Promise<GraphicalEditingScope> {\r\n if (imodel.editingScope)\r\n throw new Error(\"Cannot create an editing scope for an iModel that already has one\");\r\n\r\n // Register the scope synchronously, in case enter() is called again for same iModel while awaiting asynchronous initialization.\r\n const scope = new GraphicalEditingScope(imodel);\r\n try {\r\n const scopeStarted = await IpcApp.callIpcHost(\"toggleGraphicalEditingScope\", imodel.key, true);\r\n assert(scopeStarted); // If it didn't, the backend threw an error.\r\n } catch (e) {\r\n scope.dispose();\r\n throw e;\r\n }\r\n\r\n this.onEnter.raiseEvent(scope);\r\n\r\n return scope;\r\n }\r\n\r\n /** Exits this editing scope. The associated [[BriefcaseConnection]]'s `editingScope` will be reset to `undefined`.\r\n * @throws Error if the scope could not be exited, e.g., if it has already been exited.\r\n * @see [[BriefcaseConnection.enterEditingScope]] to enter an editing scope.\r\n */\r\n public async exit(): Promise<void> {\r\n if (this._disposed || this.iModel.editingScope !== this)\r\n throw new Error(\"Cannot exit editing scope after it is disconnected from the iModel\");\r\n\r\n this._disposed = true;\r\n try {\r\n this.onExiting.raiseEvent(this);\r\n } finally {\r\n const scopeExited = await IpcApp.callIpcHost(\"toggleGraphicalEditingScope\", this.iModel.key, false);\r\n assert(!scopeExited);\r\n try {\r\n this.onExited.raiseEvent(this);\r\n } finally {\r\n this.dispose();\r\n }\r\n }\r\n }\r\n\r\n /** Obtain all geometric changes to elements within the specified model accumulated within this scope. */\r\n public getGeometryChangesForModel(modelId: Id64String): Iterable<ElementGeometryChange> | undefined {\r\n return this._geometryChanges.get(modelId);\r\n }\r\n\r\n /** Obtain all geometric changes to models accumulated within this scope. */\r\n public getGeometryChanges(): Iterable<ModelGeometryChanges> {\r\n return { [Symbol.iterator]: () => this.geometryChangeIterator() };\r\n }\r\n\r\n /** @internal */\r\n public get isDisposed() {\r\n return this._disposed;\r\n }\r\n\r\n private * geometryChangeIterator(): Iterator<ModelGeometryChanges> {\r\n for (const [key, value] of this._geometryChanges) {\r\n yield {\r\n id: key,\r\n geometryGuid: value.geometryGuid,\r\n range: value.range,\r\n elements: value,\r\n };\r\n }\r\n }\r\n\r\n private constructor(iModel: BriefcaseConnection) {\r\n super(iModel.key);\r\n this.iModel = iModel;\r\n this._cleanup = this.registerImpl();\r\n }\r\n\r\n private dispose(): void {\r\n this._disposed = true;\r\n\r\n this.onExiting.clear();\r\n this.onGeometryChanges.clear();\r\n this.onExited.clear();\r\n\r\n this._geometryChanges.clear();\r\n\r\n if (this._cleanup) {\r\n this._cleanup();\r\n this._cleanup = undefined;\r\n }\r\n }\r\n\r\n /** @internal */\r\n public notifyGeometryChanged(props: ModelGeometryChangesProps[]) {\r\n const changes = ModelGeometryChanges.iterable(props);\r\n const modelIds: Id64String[] = [];\r\n for (const modelChanges of changes) {\r\n // ###TODO do we care about the model range?\r\n let list = this._geometryChanges.get(modelChanges.id);\r\n modelIds.push(modelChanges.id);\r\n for (const elementChange of modelChanges.elements) {\r\n if (!list) {\r\n this._geometryChanges.set(modelChanges.id, list = new ModelChanges(modelChanges.geometryGuid, modelChanges.range));\r\n } else {\r\n list.geometryGuid = modelChanges.geometryGuid;\r\n modelChanges.range.clone(list.range);\r\n }\r\n\r\n list.insert(elementChange);\r\n if (DbOpcode.Delete === elementChange.type) {\r\n this.iModel.selectionSet.remove(elementChange.id);\r\n this.iModel.hilited.setHilite(elementChange.id, false);\r\n }\r\n }\r\n }\r\n\r\n this.onGeometryChanges.raiseEvent(changes, this);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"GraphicalEditingScope.js","sourceRoot":"","sources":["../../src/GraphicalEditingScope.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,eAAe,EAA0B,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEtI,OAAO,EAC6C,aAAa,EAAE,oBAAoB,GACtF,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,4BAA4B,EAAE,MAAM,iBAAiB,CAAC;AAE/D,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,MAAM,YAAa,SAAQ,WAAkC;IAI3D,YAAmB,YAAwB,EAAE,KAAc;QACzD,KAAK,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE,EAAE,GAAG,CAAC,EAAE,CAAC,EAAE,eAAe,CAAC,OAAO,CAAC,CAAC;QAC7E,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;CACF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,OAAO,qBAAsB,SAAQ,4BAA4B;IAqGrE,YAAoB,MAA2B;QAC7C,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAnGpB,8FAA8F;QAC7E,qBAAgB,GAAG,IAAI,GAAG,EA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,CAAC,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACnD,CAAC;;AAxID;;GAEG;AACoB,6BAAO,GAAG,IAAI,OAAO,EAA0C,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module IModelConnection\r\n */\r\n\r\nimport { assert, BeEvent, compareStrings, DbOpcode, DuplicatePolicy, GuidString, Id64String, SortedArray } from \"@itwin/core-bentley\";\r\nimport { Range3d } from \"@itwin/core-geometry\";\r\nimport {\r\n EditingScopeNotifications, ElementGeometryChange, IpcAppChannel, ModelGeometryChanges, ModelGeometryChangesProps, RemoveFunction,\r\n} from \"@itwin/core-common\";\r\nimport { BriefcaseNotificationHandler } from \"./BriefcaseTxns\";\r\nimport { BriefcaseConnection } from \"./BriefcaseConnection\";\r\nimport { IpcApp } from \"./IpcApp\";\r\n\r\nclass ModelChanges extends SortedArray<ElementGeometryChange> {\r\n public geometryGuid: GuidString;\r\n public readonly range: Range3d;\r\n\r\n public constructor(geometryGuid: GuidString, range: Range3d) {\r\n super((lhs, rhs) => compareStrings(lhs.id, rhs.id), DuplicatePolicy.Replace);\r\n this.geometryGuid = geometryGuid;\r\n this.range = range;\r\n }\r\n}\r\n\r\n/** Represents a period of time within an [interactive editing]($docs/learning/InteractiveEditing.md) session during which the\r\n * geometry of elements being displayed in one or more [[Viewport]]s is being modified. Outside of such a scope, whenever the\r\n * geometry within a [GeometricModel]($backend) changes new [[Tile]]s must be generated to reflect those changes in a viewport.\r\n * Regenerating entire tiles each time individual elements change can be time-consuming, which may introduce an unacceptable delay\r\n * between making a modification and seeing its result on the screen.\r\n *\r\n * Within the context of a graphical editing scope, no new tiles are generated. Instead, the geometry for any deleted or modified elements\r\n * is hidden in the tile graphics, and additional temporary graphics are displayed for any newly-inserted or modified elements. Only when the\r\n * scope exits are new tiles produced.\r\n *\r\n * The application decides when to enter and exit a graphical editing scope. A single interactive editing session may involve any number of\r\n * editing scopes. Typically, applications will enter a new editing scope (after first exiting a previous scope, if one exists):\r\n * - When switching from a non-graphical workflow to one that involves editing geometry; or\r\n * - When changing which geometric model is being edited; or\r\n * - After performing an operation that creates or modifies a \"large\" number (perhaps hundreds?) of elements.\r\n *\r\n * An application should typically exit any graphical editing scope before:\r\n * - Pulling changesets; or\r\n * - Switching from a graphical editing workflow to some non-graphical workflow.\r\n *\r\n * Graphical editing scopes are only supported for [[BriefcaseConnection]]s opened in read-write mode that contain version 1.0.11 or newer of the BisCore schema.\r\n * @see [[BriefcaseConnection.enterEditingScope]] to create a scope for a briefcase.\r\n * @see [[BriefcaseConnection.editingScope]] to obtain a briefcase's current scope.\r\n * @see [[exit]] to terminate a scope.\r\n * @public\r\n */\r\nexport class GraphicalEditingScope extends BriefcaseNotificationHandler implements EditingScopeNotifications {\r\n public get briefcaseChannelName() { return IpcAppChannel.EditingScope; }\r\n\r\n /** Maps model Id to accumulated changes to geometric elements within the associated model. */\r\n private readonly _geometryChanges = new Map<Id64String, ModelChanges>();\r\n private _disposed = false;\r\n private _cleanup?: RemoveFunction;\r\n\r\n /** The connection to the iModel being edited. */\r\n public readonly iModel: BriefcaseConnection;\r\n\r\n /** Event raised when a new scope is created for any [[BriefcaseConnection]].\r\n * @see [[onExiting]] and [[onExited]] for complementary events.\r\n */\r\n public static readonly onEnter = new BeEvent<(scope: GraphicalEditingScope) => void>();\r\n\r\n /** Event raised when this scope is about to exit.\r\n * @see [[onEnter]] for the complementary event.\r\n * @see [[onExited]] for an event raised after the scope exits.\r\n */\r\n public readonly onExiting = new BeEvent<(scope: GraphicalEditingScope) => void>();\r\n\r\n /** Event raised when this scope has exited.\r\n * @see [[onEnter]] for the complementary event.\r\n * @see [[onExiting]] for an event raised just before the scope is exited.\r\n */\r\n public readonly onExited = new BeEvent<(scope: GraphicalEditingScope) => void>();\r\n\r\n /** Event raised after geometric changes are written to the iModel. */\r\n public readonly onGeometryChanges = new BeEvent<(changes: Iterable<ModelGeometryChanges>, scope: GraphicalEditingScope) => void>();\r\n\r\n /** Don't call this directly - use BriefcaseConnection.enterEditingScope.\r\n * @internal\r\n */\r\n public static async enter(imodel: BriefcaseConnection): Promise<GraphicalEditingScope> {\r\n if (imodel.editingScope)\r\n throw new Error(\"Cannot create an editing scope for an iModel that already has one\");\r\n\r\n // Register the scope synchronously, in case enter() is called again for same iModel while awaiting asynchronous initialization.\r\n const scope = new GraphicalEditingScope(imodel);\r\n try {\r\n const scopeStarted = await IpcApp.appFunctionIpc.toggleGraphicalEditingScope(imodel.key, true);\r\n assert(scopeStarted); // If it didn't, the backend threw an error.\r\n } catch (e) {\r\n scope.dispose();\r\n throw e;\r\n }\r\n\r\n this.onEnter.raiseEvent(scope);\r\n\r\n return scope;\r\n }\r\n\r\n /** Exits this editing scope. The associated [[BriefcaseConnection]]'s `editingScope` will be reset to `undefined`.\r\n * @throws Error if the scope could not be exited, e.g., if it has already been exited.\r\n * @see [[BriefcaseConnection.enterEditingScope]] to enter an editing scope.\r\n */\r\n public async exit(): Promise<void> {\r\n if (this._disposed || this.iModel.editingScope !== this)\r\n throw new Error(\"Cannot exit editing scope after it is disconnected from the iModel\");\r\n\r\n this._disposed = true;\r\n try {\r\n this.onExiting.raiseEvent(this);\r\n } finally {\r\n const scopeExited = await IpcApp.appFunctionIpc.toggleGraphicalEditingScope(this.iModel.key, false);\r\n assert(!scopeExited);\r\n try {\r\n this.onExited.raiseEvent(this);\r\n } finally {\r\n this.dispose();\r\n }\r\n }\r\n }\r\n\r\n /** Obtain all geometric changes to elements within the specified model accumulated within this scope. */\r\n public getGeometryChangesForModel(modelId: Id64String): Iterable<ElementGeometryChange> | undefined {\r\n return this._geometryChanges.get(modelId);\r\n }\r\n\r\n /** Obtain all geometric changes to models accumulated within this scope. */\r\n public getGeometryChanges(): Iterable<ModelGeometryChanges> {\r\n return { [Symbol.iterator]: () => this.geometryChangeIterator() };\r\n }\r\n\r\n /** @internal */\r\n public get isDisposed() {\r\n return this._disposed;\r\n }\r\n\r\n private * geometryChangeIterator(): Iterator<ModelGeometryChanges> {\r\n for (const [key, value] of this._geometryChanges) {\r\n yield {\r\n id: key,\r\n geometryGuid: value.geometryGuid,\r\n range: value.range,\r\n elements: value,\r\n };\r\n }\r\n }\r\n\r\n private constructor(iModel: BriefcaseConnection) {\r\n super(iModel.key);\r\n this.iModel = iModel;\r\n this._cleanup = this.registerImpl();\r\n }\r\n\r\n private dispose(): void {\r\n this._disposed = true;\r\n\r\n this.onExiting.clear();\r\n this.onGeometryChanges.clear();\r\n this.onExited.clear();\r\n\r\n this._geometryChanges.clear();\r\n\r\n if (this._cleanup) {\r\n this._cleanup();\r\n this._cleanup = undefined;\r\n }\r\n }\r\n\r\n /** @internal */\r\n public notifyGeometryChanged(props: ModelGeometryChangesProps[]) {\r\n const changes = ModelGeometryChanges.iterable(props);\r\n const modelIds: Id64String[] = [];\r\n for (const modelChanges of changes) {\r\n // ###TODO do we care about the model range?\r\n let list = this._geometryChanges.get(modelChanges.id);\r\n modelIds.push(modelChanges.id);\r\n for (const elementChange of modelChanges.elements) {\r\n if (!list) {\r\n this._geometryChanges.set(modelChanges.id, list = new ModelChanges(modelChanges.geometryGuid, modelChanges.range));\r\n } else {\r\n list.geometryGuid = modelChanges.geometryGuid;\r\n modelChanges.range.clone(list.range);\r\n }\r\n\r\n list.insert(elementChange);\r\n if (DbOpcode.Delete === elementChange.type) {\r\n this.iModel.selectionSet.remove(elementChange.id);\r\n this.iModel.hilited.setHilite(elementChange.id, false);\r\n }\r\n }\r\n }\r\n\r\n this.onGeometryChanges.raiseEvent(changes, this);\r\n }\r\n}\r\n"]}
@@ -1,7 +1,7 @@
1
1
  /** @packageDocumentation
2
2
  * @module NativeApp
3
3
  */
4
- import { AsyncMethodsOf, PromiseReturnType } from "@itwin/core-bentley";
4
+ import { AsyncMethodsOf, PickAsyncMethods, PromiseReturnType } from "@itwin/core-bentley";
5
5
  import { IpcAppFunctions, IpcListener, IpcSocketFrontend, RemoveFunction } from "@itwin/core-common";
6
6
  import { IModelAppOptions } from "./IModelApp";
7
7
  /**
@@ -67,7 +67,14 @@ export declare class IpcApp {
67
67
  * @internal
68
68
  */
69
69
  static callIpcChannel(channelName: string, methodName: string, ...args: any[]): Promise<any>;
70
+ /** Create a type safe Proxy object to make IPC calls to a registered backend interface.
71
+ * @param channelName the channel registered by the backend handler.
72
+ */
73
+ static makeIpcProxy<K>(channelName: string): PickAsyncMethods<K>;
74
+ /** @deprecated use [[appFunctionIpc]] */
70
75
  static callIpcHost<T extends AsyncMethodsOf<IpcAppFunctions>>(methodName: T, ...args: Parameters<IpcAppFunctions[T]>): Promise<PromiseReturnType<IpcAppFunctions[T]>>;
76
+ /** A Proxy to call one of the [IpcAppFunctions]($common) functions via IPC. */
77
+ static appFunctionIpc: PickAsyncMethods<IpcAppFunctions>;
71
78
  /** start an IpcApp.
72
79
  * @note this should not be called directly. It is called by NativeApp.startup */
73
80
  static startup(ipc: IpcSocketFrontend, opts?: IpcAppOptions): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"IpcApp.d.ts","sourceRoot":"","sources":["../../src/IpcApp.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,EACmD,eAAe,EAAwC,WAAW,EAAE,iBAAiB,EAC/H,cAAc,EAC7B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAa,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE1D;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,SAAS,CAAC,EAAE,gBAAgB,CAAC;CAC9B;AAED;;;GAGG;AACH,qBAAa,MAAM;IACjB,OAAO,CAAC,MAAM,CAAC,IAAI,CAAgC;IACnD,qEAAqE;IAErE,OAAO,CAAC,MAAM,KAAK,GAAG,GAA4C;IAElE,iIA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,EAAE,iBAAiB,EAAE,IAAI,CAAC,EAAE,aAAa;IAMxE,gBAAgB;WACI,QAAQ;CAI7B;AAED;;;;;;;;;;;;;GAaG;AACH,8BAAsB,mBAAmB;IACvC,wFAAwF;IACxF,aAAoB,WAAW,IAAI,MAAM,CAAC;IAEnC,YAAY,IAAI,cAAc;IAUrC;;;;;OAKG;WACW,QAAQ,IAAI,cAAc;CAGzC"}
package/lib/esm/IpcApp.js CHANGED
@@ -78,6 +78,17 @@ export class IpcApp {
78
78
  }
79
79
  return retVal.result;
80
80
  }
81
+ /** Create a type safe Proxy object to make IPC calls to a registered backend interface.
82
+ * @param channelName the channel registered by the backend handler.
83
+ */
84
+ static makeIpcProxy(channelName) {
85
+ return new Proxy({}, {
86
+ get(_target, methodName) {
87
+ return async (...args) => IpcApp.callIpcChannel(channelName, methodName, ...args);
88
+ },
89
+ });
90
+ }
91
+ /** @deprecated use [[appFunctionIpc]] */
81
92
  static async callIpcHost(methodName, ...args) {
82
93
  return this.callIpcChannel(IpcAppChannel.Functions, methodName, ...args);
83
94
  }
@@ -94,6 +105,8 @@ export class IpcApp {
94
105
  await IModelApp.shutdown();
95
106
  }
96
107
  }
108
+ /** A Proxy to call one of the [IpcAppFunctions]($common) functions via IPC. */
109
+ IpcApp.appFunctionIpc = IpcApp.makeIpcProxy(IpcAppChannel.Functions);
97
110
  /**
98
111
  * Base class for all implementations of an Ipc notification response interface. This class is implemented on your frontend to supply
99
112
  * methods to receive notifications from your backend.
@@ -1 +1 @@
1
- {"version":3,"file":"IpcApp.js","sourceRoot":"","sources":["../../src/IpcApp.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAGH,OAAO,EACL,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,EACtD,YAAY,GACb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,SAAS,EAAoB,MAAM,aAAa,CAAC;AAU1D;;;GAGG;AACH,MAAM,OAAO,MAAM;IAEjB,qEAA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,8DAA8D,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;YAErL,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,CAAC;QAC3B,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,QAAQ;QACpB,OAAQ,IAAK,IAAY,EAA0B,CAAC,YAAY,EAAE,CAAC,CAAC,uFAAuF;IAC7J,CAAC;CACF;AAED,wCAAwC;AACxC,MAAM,mBAAoB,SAAQ,mBAAmB;IACnD,IAAW,WAAW,KAAK,OAAO,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC;IACrD,SAAS,KAAK,CAAC;CACvB","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module NativeApp\r\n */\r\n\r\nimport { AsyncMethodsOf, PromiseReturnType } from \"@itwin/core-bentley\";\r\nimport {\r\n BackendError, IModelError, IModelStatus, IpcAppChannel, IpcAppFunctions, IpcAppNotifications, IpcInvokeReturn, IpcListener, IpcSocketFrontend,\r\n iTwinChannel, RemoveFunction,\r\n} from \"@itwin/core-common\";\r\nimport { IModelApp, IModelAppOptions } from \"./IModelApp\";\r\n\r\n/**\r\n * Options for [[IpcApp.startup]]\r\n * @public\r\n */\r\nexport interface IpcAppOptions {\r\n iModelApp?: IModelAppOptions;\r\n}\r\n\r\n/**\r\n * The frontend of apps with a dedicated backend that can use [Ipc]($docs/learning/IpcInterface.md).\r\n * @public\r\n */\r\nexport class IpcApp {\r\n private static _ipc: IpcSocketFrontend | undefined;\r\n /** Get the implementation of the [[IpcSocketFrontend]] interface. */\r\n\r\n private static get ipc(): IpcSocketFrontend { return this._ipc!; }\r\n\r\n /** Determine whether Ipc is available for this frontend. This will only be true if [[startup]] has been called on this class. */\r\n public static get isValid(): boolean { return undefined !== this._ipc; }\r\n\r\n /**\r\n * Establish a message handler function for the supplied channel over Ipc. The handler will be called when messages are sent for\r\n * the channel via [[BackendIpc.send]].\r\n * @param channel the name of the channel\r\n * @param handler the message handler\r\n * @returns A function to remove the handler\r\n * @note Ipc is only supported if [[isValid]] is true.\r\n */\r\n public static addListener(channel: string, handler: IpcListener): RemoveFunction {\r\n return this.ipc.addListener(iTwinChannel(channel), handler);\r\n }\r\n\r\n /**\r\n * Remove a previously registered listener\r\n * @param channel The name of the channel for the listener previously registered with [[addListener]]\r\n * @param listener The function passed to [[addListener]]\r\n */\r\n public static removeListener(channel: string, listener: IpcListener) {\r\n this.ipc.removeListener(iTwinChannel(channel), listener);\r\n }\r\n\r\n /**\r\n * Send a message to the backend via `channel` and expect a result asynchronously. The handler must be established on the backend via [[BackendIpc.handle]]\r\n * @param channel The name of the channel for the method.\r\n * @see Electron [ipcRenderer.invoke](https://www.electronjs.org/docs/api/ipc-renderer) documentation for details.\r\n * Note that this interface may be implemented via Electron for desktop apps, or via\r\n * [WebSockets](https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API) for mobile or web-based\r\n * Ipc connections. In either case, the Electron documentation provides the specifications for how it works.\r\n * @note `args` are serialized with the [Structured Clone Algorithm](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm), so only\r\n * primitive types and `ArrayBuffers` are allowed.\r\n */\r\n public static async invoke(channel: string, ...args: any[]): Promise<any> {\r\n return this.ipc.invoke(iTwinChannel(channel), ...args);\r\n }\r\n\r\n /**\r\n * Send a message over the socket.\r\n * @param channel The name of the channel for the message.\r\n * @param data The optional data of the message.\r\n * @note `data` is serialized with the [Structured Clone Algorithm](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm), so only\r\n * primitive types and `ArrayBuffers` are allowed.\r\n */\r\n public static send(channel: string, ...data: any[]) {\r\n return this.ipc.send(iTwinChannel(channel), ...data);\r\n }\r\n\r\n /**\r\n * Call a method on the backend through an Ipc channel.\r\n * @param channelName the channel registered by the backend handler.\r\n * @param methodName the name of a method implemented by the backend handler.\r\n * @param args arguments to `methodName`\r\n * @return a Promise with the return value from `methodName`\r\n * @note If the backend implementation throws an exception, this method will throw a [[BackendError]] exception\r\n * with the `errorNumber` and `message` from the backend.\r\n * @note Ipc is only supported if [[isValid]] is true.\r\n * @internal\r\n */\r\n public static async callIpcChannel(channelName: string, methodName: string, ...args: any[]): Promise<any> {\r\n const retVal = (await this.invoke(channelName, methodName, ...args)) as IpcInvokeReturn;\r\n if (undefined !== retVal.error) {\r\n const err = new BackendError(retVal.error.errorNumber, retVal.error.name, retVal.error.message);\r\n err.stack = retVal.error.stack;\r\n throw err;\r\n }\r\n return retVal.result;\r\n }\r\n\r\n public static async callIpcHost<T extends AsyncMethodsOf<IpcAppFunctions>>(methodName: T, ...args: Parameters<IpcAppFunctions[T]>) {\r\n return this.callIpcChannel(IpcAppChannel.Functions, methodName, ...args) as PromiseReturnType<IpcAppFunctions[T]>;\r\n }\r\n\r\n /** start an IpcApp.\r\n * @note this should not be called directly. It is called by NativeApp.startup */\r\n public static async startup(ipc: IpcSocketFrontend, opts?: IpcAppOptions) {\r\n this._ipc = ipc;\r\n IpcAppNotifyHandler.register(); // receives notifications from backend\r\n await IModelApp.startup(opts?.iModelApp);\r\n }\r\n\r\n /** @internal */\r\n public static async shutdown() {\r\n this._ipc = undefined;\r\n await IModelApp.shutdown();\r\n }\r\n}\r\n\r\n/**\r\n * Base class for all implementations of an Ipc notification response interface. This class is implemented on your frontend to supply\r\n * methods to receive notifications from your backend.\r\n *\r\n * Create a subclass to implement your Ipc response interface. Your class should be declared like this:\r\n * ```ts\r\n * class MyNotificationHandler extends NotificationHandler implements MyNotifications\r\n * ```\r\n * to ensure all method names and signatures are correct. Your methods cannot have a return value.\r\n *\r\n * Then, call `MyNotificationHandler.register` at startup to connect your class to your channel.\r\n * @public\r\n * @extensions\r\n */\r\nexport abstract class NotificationHandler {\r\n /** All subclasses must implement this method to specify their response channel name. */\r\n public abstract get channelName(): string;\r\n\r\n public registerImpl(): RemoveFunction {\r\n return IpcApp.addListener(this.channelName, (_evt: Event, funcName: string, ...args: any[]) => {\r\n const func = (this as any)[funcName];\r\n if (typeof func !== \"function\")\r\n throw new IModelError(IModelStatus.FunctionNotFound, `Method \"${this.constructor.name}.${funcName}\" not found on NotificationHandler registered for channel: ${this.channelName}`);\r\n\r\n func.call(this, ...args);\r\n });\r\n }\r\n\r\n /**\r\n * Register this class as the handler for notifications on its channel. This static method creates a new instance\r\n * that becomes the notification handler and is `this` when its methods are called.\r\n * @returns A function that can be called to remove the handler.\r\n * @note this method should only be called once per channel. If it is called multiple times, multiple handlers are established.\r\n */\r\n public static register(): RemoveFunction {\r\n return (new (this as any)() as NotificationHandler).registerImpl(); // create an instance of subclass. \"as any\" is necessary because base class is abstract\r\n }\r\n}\r\n\r\n/** IpcApp notifications from backend */\r\nclass IpcAppNotifyHandler extends NotificationHandler implements IpcAppNotifications {\r\n public get channelName() { return IpcAppChannel.AppNotify; }\r\n public notifyApp() { }\r\n}\r\n"]}
1
+ {"version":3,"file":"IpcApp.js","sourceRoot":"","sources":["../../src/IpcApp.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAGH,OAAO,EACL,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,EACtD,YAAY,GACb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,SAAS,EAAoB,MAAM,aAAa,CAAC;AAU1D;;;GAGG;AACH,MAAM,OAAO,MAAM;IAEjB,qEAAqE;IAE7D,MAAM,KAAK,GAAG,KAAwB,OAAO,IAAI,CAAC,IAAK,CAAC,CAAC,CAAC;IAElE,iIAAiI;IAC1H,MAAM,KAAK,OAAO,KAAc,OAAO,SAAS,KAAK,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAExE;;;;;;;OAOG;IACI,MAAM,CAAC,WAAW,CAAC,OAAe,EAAE,OAAoB;QAC7D,OAAO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AAC;YACrC,IAAI,OAAO,IAAI,KAAK,UAAU;gBAC5B,MAAM,IAAI,WAAW,CAAC,YAAY,CAAC,gBAAgB,EAAE,WAAW,IAAI,CAAC,WAAW,CAAC,IAAI,IAAI,QAAQ,8DAA8D,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;YAErL,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,CAAC;QAC3B,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,QAAQ;QACpB,OAAQ,IAAK,IAAY,EAA0B,CAAC,YAAY,EAAE,CAAC,CAAC,uFAAuF;IAC7J,CAAC;CACF;AAED,wCAAwC;AACxC,MAAM,mBAAoB,SAAQ,mBAAmB;IACnD,IAAW,WAAW,KAAK,OAAO,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC;IACrD,SAAS,KAAK,CAAC;CACvB","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module NativeApp\r\n */\r\n\r\nimport { AsyncMethodsOf, PickAsyncMethods, PromiseReturnType } from \"@itwin/core-bentley\";\r\nimport {\r\n BackendError, IModelError, IModelStatus, IpcAppChannel, IpcAppFunctions, IpcAppNotifications, IpcInvokeReturn, IpcListener, IpcSocketFrontend,\r\n iTwinChannel, RemoveFunction,\r\n} from \"@itwin/core-common\";\r\nimport { IModelApp, IModelAppOptions } from \"./IModelApp\";\r\n\r\n/**\r\n * Options for [[IpcApp.startup]]\r\n * @public\r\n */\r\nexport interface IpcAppOptions {\r\n iModelApp?: IModelAppOptions;\r\n}\r\n\r\n/**\r\n * The frontend of apps with a dedicated backend that can use [Ipc]($docs/learning/IpcInterface.md).\r\n * @public\r\n */\r\nexport class IpcApp {\r\n private static _ipc: IpcSocketFrontend | undefined;\r\n /** Get the implementation of the [[IpcSocketFrontend]] interface. */\r\n\r\n private static get ipc(): IpcSocketFrontend { return this._ipc!; }\r\n\r\n /** Determine whether Ipc is available for this frontend. This will only be true if [[startup]] has been called on this class. */\r\n public static get isValid(): boolean { return undefined !== this._ipc; }\r\n\r\n /**\r\n * Establish a message handler function for the supplied channel over Ipc. The handler will be called when messages are sent for\r\n * the channel via [[BackendIpc.send]].\r\n * @param channel the name of the channel\r\n * @param handler the message handler\r\n * @returns A function to remove the handler\r\n * @note Ipc is only supported if [[isValid]] is true.\r\n */\r\n public static addListener(channel: string, handler: IpcListener): RemoveFunction {\r\n return this.ipc.addListener(iTwinChannel(channel), handler);\r\n }\r\n\r\n /**\r\n * Remove a previously registered listener\r\n * @param channel The name of the channel for the listener previously registered with [[addListener]]\r\n * @param listener The function passed to [[addListener]]\r\n */\r\n public static removeListener(channel: string, listener: IpcListener) {\r\n this.ipc.removeListener(iTwinChannel(channel), listener);\r\n }\r\n\r\n /**\r\n * Send a message to the backend via `channel` and expect a result asynchronously. The handler must be established on the backend via [[BackendIpc.handle]]\r\n * @param channel The name of the channel for the method.\r\n * @see Electron [ipcRenderer.invoke](https://www.electronjs.org/docs/api/ipc-renderer) documentation for details.\r\n * Note that this interface may be implemented via Electron for desktop apps, or via\r\n * [WebSockets](https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API) for mobile or web-based\r\n * Ipc connections. In either case, the Electron documentation provides the specifications for how it works.\r\n * @note `args` are serialized with the [Structured Clone Algorithm](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm), so only\r\n * primitive types and `ArrayBuffers` are allowed.\r\n */\r\n public static async invoke(channel: string, ...args: any[]): Promise<any> {\r\n return this.ipc.invoke(iTwinChannel(channel), ...args);\r\n }\r\n\r\n /**\r\n * Send a message over the socket.\r\n * @param channel The name of the channel for the message.\r\n * @param data The optional data of the message.\r\n * @note `data` is serialized with the [Structured Clone Algorithm](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm), so only\r\n * primitive types and `ArrayBuffers` are allowed.\r\n */\r\n public static send(channel: string, ...data: any[]) {\r\n return this.ipc.send(iTwinChannel(channel), ...data);\r\n }\r\n\r\n /**\r\n * Call a method on the backend through an Ipc channel.\r\n * @param channelName the channel registered by the backend handler.\r\n * @param methodName the name of a method implemented by the backend handler.\r\n * @param args arguments to `methodName`\r\n * @return a Promise with the return value from `methodName`\r\n * @note If the backend implementation throws an exception, this method will throw a [[BackendError]] exception\r\n * with the `errorNumber` and `message` from the backend.\r\n * @note Ipc is only supported if [[isValid]] is true.\r\n * @internal\r\n */\r\n public static async callIpcChannel(channelName: string, methodName: string, ...args: any[]): Promise<any> {\r\n const retVal = (await this.invoke(channelName, methodName, ...args)) as IpcInvokeReturn;\r\n if (undefined !== retVal.error) {\r\n const err = new BackendError(retVal.error.errorNumber, retVal.error.name, retVal.error.message);\r\n err.stack = retVal.error.stack;\r\n throw err;\r\n }\r\n return retVal.result;\r\n }\r\n\r\n /** Create a type safe Proxy object to make IPC calls to a registered backend interface.\r\n * @param channelName the channel registered by the backend handler.\r\n */\r\n public static makeIpcProxy<K>(channelName: string): PickAsyncMethods<K> {\r\n return new Proxy({} as PickAsyncMethods<K>, {\r\n get(_target, methodName: string) {\r\n return async (...args: any[]) =>\r\n IpcApp.callIpcChannel(channelName, methodName, ...args);\r\n },\r\n });\r\n }\r\n\r\n /** @deprecated use [[appFunctionIpc]] */\r\n public static async callIpcHost<T extends AsyncMethodsOf<IpcAppFunctions>>(methodName: T, ...args: Parameters<IpcAppFunctions[T]>) {\r\n return this.callIpcChannel(IpcAppChannel.Functions, methodName, ...args) as PromiseReturnType<IpcAppFunctions[T]>;\r\n }\r\n\r\n /** A Proxy to call one of the [IpcAppFunctions]($common) functions via IPC. */\r\n public static appFunctionIpc = IpcApp.makeIpcProxy<IpcAppFunctions>(IpcAppChannel.Functions);\r\n\r\n /** start an IpcApp.\r\n * @note this should not be called directly. It is called by NativeApp.startup */\r\n public static async startup(ipc: IpcSocketFrontend, opts?: IpcAppOptions) {\r\n this._ipc = ipc;\r\n IpcAppNotifyHandler.register(); // receives notifications from backend\r\n await IModelApp.startup(opts?.iModelApp);\r\n }\r\n\r\n /** @internal */\r\n public static async shutdown() {\r\n this._ipc = undefined;\r\n await IModelApp.shutdown();\r\n }\r\n}\r\n\r\n/**\r\n * Base class for all implementations of an Ipc notification response interface. This class is implemented on your frontend to supply\r\n * methods to receive notifications from your backend.\r\n *\r\n * Create a subclass to implement your Ipc response interface. Your class should be declared like this:\r\n * ```ts\r\n * class MyNotificationHandler extends NotificationHandler implements MyNotifications\r\n * ```\r\n * to ensure all method names and signatures are correct. Your methods cannot have a return value.\r\n *\r\n * Then, call `MyNotificationHandler.register` at startup to connect your class to your channel.\r\n * @public\r\n * @extensions\r\n */\r\nexport abstract class NotificationHandler {\r\n /** All subclasses must implement this method to specify their response channel name. */\r\n public abstract get channelName(): string;\r\n\r\n public registerImpl(): RemoveFunction {\r\n return IpcApp.addListener(this.channelName, (_evt: Event, funcName: string, ...args: any[]) => {\r\n const func = (this as any)[funcName];\r\n if (typeof func !== \"function\")\r\n throw new IModelError(IModelStatus.FunctionNotFound, `Method \"${this.constructor.name}.${funcName}\" not found on NotificationHandler registered for channel: ${this.channelName}`);\r\n\r\n func.call(this, ...args);\r\n });\r\n }\r\n\r\n /**\r\n * Register this class as the handler for notifications on its channel. This static method creates a new instance\r\n * that becomes the notification handler and is `this` when its methods are called.\r\n * @returns A function that can be called to remove the handler.\r\n * @note this method should only be called once per channel. If it is called multiple times, multiple handlers are established.\r\n */\r\n public static register(): RemoveFunction {\r\n return (new (this as any)() as NotificationHandler).registerImpl(); // create an instance of subclass. \"as any\" is necessary because base class is abstract\r\n }\r\n}\r\n\r\n/** IpcApp notifications from backend */\r\nclass IpcAppNotifyHandler extends NotificationHandler implements IpcAppNotifications {\r\n public get channelName() { return IpcAppChannel.AppNotify; }\r\n public notifyApp() { }\r\n}\r\n"]}
@@ -39,7 +39,11 @@ export interface NativeAppOpts extends IpcAppOptions {
39
39
  * @public
40
40
  */
41
41
  export declare class NativeApp {
42
+ private static _removeAppNotify?;
43
+ /** @deprecated use nativeAppIpc */
42
44
  static callNativeHost<T extends AsyncMethodsOf<NativeAppFunctions>>(methodName: T, ...args: Parameters<NativeAppFunctions[T]>): Promise<PromiseReturnType<NativeAppFunctions[T]>>;
45
+ /** A Proxy to call one of the [NativeAppFunctions]($common) functions via IPC. */
46
+ static nativeAppIpc: import("@itwin/core-bentley").PickAsyncMethods<NativeAppFunctions>;
43
47
  private static _storages;
44
48
  private static _onOnline;
45
49
  private static _onOffline;
@@ -68,7 +72,7 @@ export declare class NativeApp {
68
72
  * @param fileName the briefcase fileName
69
73
  */
70
74
  static deleteBriefcase(fileName: string): Promise<void>;
71
- /** Get a list of all briefcase files held in the local briefcase cache directory */
75
+ /** Get a list of all briefcase files held in the local briefcase cache directory */
72
76
  static getCachedBriefcases(iModelId?: GuidString): Promise<LocalBriefcaseProps[]>;
73
77
  /**
74
78
  * Open a [[Storage]]. Creates a new Storage with that name if it does not already exist.
@@ -1 +1 @@
1
- {"version":3,"file":"NativeApp.d.ts","sourceRoot":"","sources":["../../src/NativeApp.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,UAAU,EAAU,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACrG,OAAO,EACL,mBAAmB,EAAE,cAAc,EAAE,aAAa,EAAE,0BAA0B,EAAE,iBAAiB,EAAE,mBAAmB,EACpG,kBAAkB,EACV,YAAY,EAAE,QAAQ,EACjD,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,gBAAgB,EAAwB,MAAM,mBAAmB,CAAC;AAE3E,OAAO,EAAU,aAAa,EAAuB,MAAM,UAAU,CAAC;AAGtE;;;GAGG;AACH,oBAAY,mBAAmB,GAC7B;IAAE,QAAQ,CAAC,EAAE,QAAQ,CAAC;IAAC,WAAW,CA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