@itwin/presentation-core-interop 2.0.0-alpha.2 → 2.0.0-alpha.3

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 (83) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/lib/core-interop/Formatting.d.ts.map +1 -0
  3. package/lib/core-interop/Formatting.js.map +1 -0
  4. package/lib/core-interop/IModelKey.d.ts.map +1 -0
  5. package/lib/core-interop/IModelKey.js.map +1 -0
  6. package/lib/core-interop/Logging.d.ts.map +1 -0
  7. package/lib/core-interop/Logging.js.map +1 -0
  8. package/lib/core-interop/Metadata.d.ts.map +1 -0
  9. package/lib/core-interop/Metadata.js.map +1 -0
  10. package/lib/core-interop/MetadataInternal.d.ts.map +1 -0
  11. package/lib/{esm/core-interop → core-interop}/MetadataInternal.js +5 -3
  12. package/lib/core-interop/MetadataInternal.js.map +1 -0
  13. package/lib/core-interop/QueryExecutor.d.ts.map +1 -0
  14. package/lib/core-interop/QueryExecutor.js.map +1 -0
  15. package/lib/core-interop/Transactions.d.ts.map +1 -0
  16. package/lib/core-interop/Transactions.js.map +1 -0
  17. package/lib/presentation-core-interop.d.ts.map +1 -0
  18. package/lib/presentation-core-interop.js.map +1 -0
  19. package/package.json +19 -21
  20. package/lib/cjs/core-interop/Formatting.d.ts.map +0 -1
  21. package/lib/cjs/core-interop/Formatting.js +0 -136
  22. package/lib/cjs/core-interop/Formatting.js.map +0 -1
  23. package/lib/cjs/core-interop/IModelKey.d.ts.map +0 -1
  24. package/lib/cjs/core-interop/IModelKey.js +0 -36
  25. package/lib/cjs/core-interop/IModelKey.js.map +0 -1
  26. package/lib/cjs/core-interop/Logging.d.ts.map +0 -1
  27. package/lib/cjs/core-interop/Logging.js +0 -46
  28. package/lib/cjs/core-interop/Logging.js.map +0 -1
  29. package/lib/cjs/core-interop/Metadata.d.ts.map +0 -1
  30. package/lib/cjs/core-interop/Metadata.js +0 -62
  31. package/lib/cjs/core-interop/Metadata.js.map +0 -1
  32. package/lib/cjs/core-interop/MetadataInternal.d.ts.map +0 -1
  33. package/lib/cjs/core-interop/MetadataInternal.js +0 -427
  34. package/lib/cjs/core-interop/MetadataInternal.js.map +0 -1
  35. package/lib/cjs/core-interop/QueryExecutor.d.ts.map +0 -1
  36. package/lib/cjs/core-interop/QueryExecutor.js +0 -150
  37. package/lib/cjs/core-interop/QueryExecutor.js.map +0 -1
  38. package/lib/cjs/core-interop/Transactions.d.ts.map +0 -1
  39. package/lib/cjs/core-interop/Transactions.js +0 -60
  40. package/lib/cjs/core-interop/Transactions.js.map +0 -1
  41. package/lib/cjs/package.json +0 -1
  42. package/lib/cjs/presentation-core-interop.d.ts.map +0 -1
  43. package/lib/cjs/presentation-core-interop.js +0 -20
  44. package/lib/cjs/presentation-core-interop.js.map +0 -1
  45. package/lib/esm/core-interop/Formatting.d.ts +0 -45
  46. package/lib/esm/core-interop/Formatting.d.ts.map +0 -1
  47. package/lib/esm/core-interop/Formatting.js.map +0 -1
  48. package/lib/esm/core-interop/IModelKey.d.ts +0 -31
  49. package/lib/esm/core-interop/IModelKey.d.ts.map +0 -1
  50. package/lib/esm/core-interop/IModelKey.js.map +0 -1
  51. package/lib/esm/core-interop/Logging.d.ts +0 -33
  52. package/lib/esm/core-interop/Logging.d.ts.map +0 -1
  53. package/lib/esm/core-interop/Logging.js.map +0 -1
  54. package/lib/esm/core-interop/Metadata.d.ts +0 -30
  55. package/lib/esm/core-interop/Metadata.d.ts.map +0 -1
  56. package/lib/esm/core-interop/Metadata.js.map +0 -1
  57. package/lib/esm/core-interop/MetadataInternal.d.ts +0 -10
  58. package/lib/esm/core-interop/MetadataInternal.d.ts.map +0 -1
  59. package/lib/esm/core-interop/MetadataInternal.js.map +0 -1
  60. package/lib/esm/core-interop/QueryExecutor.d.ts +0 -34
  61. package/lib/esm/core-interop/QueryExecutor.d.ts.map +0 -1
  62. package/lib/esm/core-interop/QueryExecutor.js.map +0 -1
  63. package/lib/esm/core-interop/Transactions.d.ts +0 -71
  64. package/lib/esm/core-interop/Transactions.d.ts.map +0 -1
  65. package/lib/esm/core-interop/Transactions.js.map +0 -1
  66. package/lib/esm/presentation-core-interop.d.ts +0 -7
  67. package/lib/esm/presentation-core-interop.d.ts.map +0 -1
  68. package/lib/esm/presentation-core-interop.js.map +0 -1
  69. /package/lib/{cjs/core-interop → core-interop}/Formatting.d.ts +0 -0
  70. /package/lib/{esm/core-interop → core-interop}/Formatting.js +0 -0
  71. /package/lib/{cjs/core-interop → core-interop}/IModelKey.d.ts +0 -0
  72. /package/lib/{esm/core-interop → core-interop}/IModelKey.js +0 -0
  73. /package/lib/{cjs/core-interop → core-interop}/Logging.d.ts +0 -0
  74. /package/lib/{esm/core-interop → core-interop}/Logging.js +0 -0
  75. /package/lib/{cjs/core-interop → core-interop}/Metadata.d.ts +0 -0
  76. /package/lib/{esm/core-interop → core-interop}/Metadata.js +0 -0
  77. /package/lib/{cjs/core-interop → core-interop}/MetadataInternal.d.ts +0 -0
  78. /package/lib/{cjs/core-interop → core-interop}/QueryExecutor.d.ts +0 -0
  79. /package/lib/{esm/core-interop → core-interop}/QueryExecutor.js +0 -0
  80. /package/lib/{cjs/core-interop → core-interop}/Transactions.d.ts +0 -0
  81. /package/lib/{esm/core-interop → core-interop}/Transactions.js +0 -0
  82. /package/lib/{cjs/presentation-core-interop.d.ts → presentation-core-interop.d.ts} +0 -0
  83. /package/lib/{esm/presentation-core-interop.js → presentation-core-interop.js} +0 -0
@@ -1,34 +0,0 @@
1
- import { QueryBinder } from "@itwin/core-common";
2
- import type { QueryOptions, QueryRowProxy } from "@itwin/core-common";
3
- import type { ECSqlQueryExecutor } from "@itwin/presentation-shared";
4
- export declare const QUERY_CANCEL_DELAY_MS = 100;
5
- /**
6
- * Defines input for `createECSqlQueryExecutor`. Generally, this is an instance of either [IModelDb](https://www.itwinjs.org/reference/core-backend/imodels/imodeldb/)
7
- * or [IModelConnection](https://www.itwinjs.org/reference/core-frontend/imodelconnection/imodelconnection/).
8
- * @public
9
- */
10
- interface CoreECSqlReaderFactory {
11
- createQueryReader(ecsql: string, binder?: QueryBinder, options?: QueryOptions): AsyncIterableIterator<QueryRowProxy>;
12
- }
13
- /**
14
- * Creates an `ECSqlQueryExecutor` from either [IModelDb](https://www.itwinjs.org/reference/core-backend/imodels/imodeldb/) or
15
- * [IModelConnection](https://www.itwinjs.org/reference/core-frontend/imodelconnection/imodelconnection/).
16
- *
17
- * Usage example:
18
- *
19
- * ```ts
20
- * import { IModelDb } from "@itwin/core-backend";
21
- * import { createECSqlQueryExecutor } from "@itwin/presentation-core-interop";
22
- *
23
- * const imodel: IModelDb = getIModelDb();
24
- * const executor = createECSqlQueryExecutor(imodel);
25
- * for await (const row of executor.createQueryReader(MY_QUERY)) {
26
- * // TODO: do something with `row`
27
- * }
28
- * ```
29
- *
30
- * @public
31
- */
32
- export declare function createECSqlQueryExecutor(imodel: CoreECSqlReaderFactory): ECSqlQueryExecutor;
33
- export {};
34
- //# sourceMappingURL=QueryExecutor.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"QueryExecutor.d.ts","sourceRoot":"","sources":["../../../src/core-interop/QueryExecutor.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,WAAW,EAAuC,MAAM,oBAAoB,CAAC;AAItF,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACtE,OAAO,KAAK,EAGV,kBAAkB,EAGnB,MAAM,4BAA4B,CAAC;AAEpC,eAAO,MAAM,qBAAqB,MAAM,CAAC;AAEzC;;;;GAIG;AACH,UAAU,sBAAsB;IAC9B,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,qBAAqB,CAAC,aAAa,CAAC,CAAC;CACtH;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,sBAAsB,GAAG,kBAAk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AC,CAAC,CAAC,kBAAkB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IAC5E,OAAO,GAAG,UAAU,GAAG,KAAK,EAAE,CAAC;AACjC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { Guid, OrderedId64Iterable } from \"@itwin/core-bentley\";\nimport { QueryBinder, QueryOptionsBuilder, QueryRowFormat } from \"@itwin/core-common\";\nimport { Point2d, Point3d } from \"@itwin/core-geometry\";\nimport { trimWhitespace } from \"@itwin/presentation-shared\";\n\nimport type { QueryOptions, QueryRowProxy } from \"@itwin/core-common\";\nimport type {\n ECSqlBinding,\n ECSqlQueryDef,\n ECSqlQueryExecutor,\n ECSqlQueryReaderOptions,\n ECSqlQueryRow,\n} from \"@itwin/presentation-shared\";\n\nexport const QUERY_CANCEL_DELAY_MS = 100;\n\n/**\n * Defines input for `createECSqlQueryExecutor`. Generally, this is an instance of either [IModelDb](https://www.itwinjs.org/reference/core-backend/imodels/imodeldb/)\n * or [IModelConnection](https://www.itwinjs.org/reference/core-frontend/imodelconnection/imodelconnection/).\n * @public\n */\ninterface CoreECSqlReaderFactory {\n createQueryReader(ecsql: string, binder?: QueryBinder, options?: QueryOptions): AsyncIterableIterator<QueryRowProxy>;\n}\n\n/**\n * Creates an `ECSqlQueryExecutor` from either [IModelDb](https://www.itwinjs.org/reference/core-backend/imodels/imodeldb/) or\n * [IModelConnection](https://www.itwinjs.org/reference/core-frontend/imodelconnection/imodelconnection/).\n *\n * Usage example:\n *\n * ```ts\n * import { IModelDb } from \"@itwin/core-backend\";\n * import { createECSqlQueryExecutor } from \"@itwin/presentation-core-interop\";\n *\n * const imodel: IModelDb = getIModelDb();\n * const executor = createECSqlQueryExecutor(imodel);\n * for await (const row of executor.createQueryReader(MY_QUERY)) {\n * // TODO: do something with `row`\n * }\n * ```\n *\n * @public\n */\nexport function createECSqlQueryExecutor(imodel: CoreECSqlReaderFactory): ECSqlQueryExecutor {\n return {\n createQueryReader(query: ECSqlQueryDef, config?: ECSqlQueryReaderOptions) {\n const { ctes, ecsql, bindings } = query;\n const opts = new QueryOptionsBuilder();\n switch (config?.rowFormat) {\n case \"ECSqlPropertyNames\":\n opts.setRowFormat(QueryRowFormat.UseECSqlPropertyNames);\n break;\n case \"Indexes\":\n opts.setRowFormat(QueryRowFormat.UseECSqlPropertyIndexes);\n break;\n }\n const restartToken = config?.restartToken ?? Guid.createValue();\n opts.setRestartToken(restartToken);\n const onCancel = () => {\n try {\n const cancelReader = imodel.createQueryReader(\n \"SELECT 1\",\n undefined,\n new QueryOptionsBuilder().setRestartToken(restartToken).getOptions(),\n );\n void (async () => {\n try {\n for await (const _ of cancelReader) {\n /* drain */\n }\n } catch {\n /* expected */\n }\n })();\n } catch {\n /* ignore */\n }\n };\n return new ECSqlQueryReaderImpl(\n imodel.createQueryReader(\n trimWhitespace(addCTEs(ecsql, ctes)),\n bindings ? bind(bindings) : undefined,\n opts.getOptions(),\n ),\n config?.rowFormat === \"Indexes\" ? \"array\" : \"object\",\n onCancel,\n );\n },\n };\n}\n\nclass ECSqlQueryReaderImpl implements ReturnType<ECSqlQueryExecutor[\"createQueryReader\"]> {\n private _cancelTimer: ReturnType<typeof setTimeout> | undefined;\n\n public constructor(\n private _coreReader: AsyncIterableIterator<QueryRowProxy>,\n private _format: \"array\" | \"object\",\n private _onCancel: () => void,\n ) {}\n\n public [Symbol.asyncIterator](): AsyncIterableIterator<ECSqlQueryRow> {\n return this;\n }\n\n public async next(): Promise<IteratorResult<ECSqlQueryRow>> {\n const res = await this._coreReader.next();\n if (res.done) {\n if (this._cancelTimer) {\n clearTimeout(this._cancelTimer);\n this._cancelTimer = undefined;\n }\n return { done: true, value: undefined };\n }\n return { done: false, value: this._format === \"array\" ? res.value.toArray() : res.value.toRow() };\n }\n\n public async return(): Promise<IteratorResult<ECSqlQueryRow>> {\n if (this._coreReader.return) {\n await this._coreReader.return();\n } else {\n this._cancelTimer = setTimeout(() => this._onCancel(), QUERY_CANCEL_DELAY_MS);\n }\n return { done: true, value: undefined };\n }\n}\n\nfunction bind(bindings: ECSqlBinding[] | Record<string, ECSqlBinding>): QueryBinder {\n const binder = new QueryBinder();\n const entries: Array<[string | number, ECSqlBinding]> = Array.isArray(bindings)\n ? bindings.map((b, i) => [i + 1, b])\n : Object.entries(bindings);\n for (const [key, b] of entries) {\n if (b.value === undefined) {\n binder.bindNull(key);\n continue;\n }\n switch (b.type) {\n case \"boolean\":\n binder.bindBoolean(key, b.value);\n break;\n case \"double\":\n binder.bindDouble(key, b.value);\n break;\n case \"id\":\n binder.bindId(key, b.value);\n break;\n case \"idset\":\n binder.bindIdSet(key, OrderedId64Iterable.sortArray(b.value));\n break;\n case \"int\":\n binder.bindInt(key, b.value);\n break;\n case \"long\":\n binder.bindLong(key, b.value);\n break;\n case \"point2d\":\n binder.bindPoint2d(key, Point2d.fromJSON(b.value));\n break;\n case \"point3d\":\n binder.bindPoint3d(key, Point3d.fromJSON(b.value));\n break;\n case \"string\":\n binder.bindString(key, b.value);\n break;\n }\n }\n return binder;\n}\n\nfunction addCTEs(ecsql: string, ctes: string[] | undefined) {\n const ctesPrefix = ctes?.length ? `WITH RECURSIVE ${ctes.join(\", \")} ` : \"\";\n return `${ctesPrefix}${ecsql}`;\n}\n"]}
@@ -1,71 +0,0 @@
1
- import type { Event } from "@itwin/presentation-shared";
2
- /**
3
- * An interface for a transaction manager that has 3 types of events fired before and after a commit
4
- * and when changes are applied on a briefcase.
5
- *
6
- * Generally, this either means [TxnManager](https://www.itwinjs.org/reference/core-backend/imodels/txnmanager/), accessed
7
- * through [BriefcaseDb.txns](https://www.itwinjs.org/reference/core-backend/imodels/briefcasedb/#txns), or
8
- * [BriefcaseTxns](https://www.itwinjs.org/reference/core-frontend/imodelconnection/briefcasetxns/), accessed
9
- * through [BriefcaseConnection.txns](https://www.itwinjs.org/reference/core-frontend/imodelconnection/briefcaseconnection/#txns).
10
- * @public
11
- */
12
- interface ICoreTxnManager {
13
- /**
14
- * Event raised before a commit operation is performed. Initiated by a call to either
15
- * [IModelDb.saveChanges](https://www.itwinjs.org/reference/core-backend/imodels/imodeldb/savechanges/)
16
- * or [BriefcaseConnection.saveChanges](https://www.itwinjs.org/reference/core-frontend/imodelconnection/briefcaseconnection/savechanges/),
17
- * unless there are no changes to save.
18
- */
19
- onCommit: Event;
20
- /**
21
- * Event raised after a commit operation is performed. Initiated by a call to either
22
- * [IModelDb.saveChanges](https://www.itwinjs.org/reference/core-backend/imodels/imodeldb/savechanges/)
23
- * or [BriefcaseConnection.saveChanges](https://www.itwinjs.org/reference/core-frontend/imodelconnection/briefcaseconnection/savechanges/),
24
- * even if there were no changes to save.
25
- */
26
- onCommitted: Event;
27
- /**
28
- * Event raised after a changeset has been applied to the briefcase. Changesets may be applied as a result of
29
- * [BriefcaseDb.pullChanges](https://www.itwinjs.org/reference/core-backend/imodels/briefcasedb/) or
30
- * [BriefcaseConnection.pullChanges](https://www.itwinjs.org/reference/core-frontend/imodelconnection/briefcaseconnection/pullchanges/),
31
- * or by undo/redo operations.
32
- */
33
- onChangesApplied: Event;
34
- }
35
- /**
36
- * Registers listeners to `txns` events and calls provided `onChanged` callback when transaction manager
37
- * reports there are iModel data changes.
38
- *
39
- * Usage example:
40
- *
41
- * ```ts
42
- * import { BriefcaseDb } from "@itwin/core-backend";
43
- * import { registerTxnListeners } from "@itwin/presentation-core-interop";
44
- * import { HierarchyProvider } from "@itwin/presentation-hierarchies";
45
- *
46
- * // get iModel and hierarchy provider from arbitrary sources
47
- * const db: BriefcaseDb = getIModel();
48
- * const provider: HierarchyProvider = getHierarchyProvider();
49
- *
50
- * // register the listeners
51
- * const unregister = registerTxnListeners(db.txns, () => {
52
- * // notify provided about the changed data
53
- * provider.notifyDataSourceChanged();
54
- * // TODO: force the components using `provider` to reload
55
- * });
56
- *
57
- * // clean up on iModel close
58
- * db.onClosed.addOnce(() => unregister());
59
- * ```
60
- *
61
- * @param txns Either [TxnManager](https://www.itwinjs.org/reference/core-backend/imodels/txnmanager/), accessed
62
- * through [BriefcaseDb.txns](https://www.itwinjs.org/reference/core-backend/imodels/briefcasedb/#txns),
63
- * or [BriefcaseTxns](https://www.itwinjs.org/reference/core-frontend/imodelconnection/briefcasetxns/), accessed
64
- * through [BriefcaseConnection.txns](https://www.itwinjs.org/reference/core-frontend/imodelconnection/briefcaseconnection/#txns).
65
- * @param onChanged A function to call when transaction manager reports iModel data changes.
66
- * @returns A function that unregisters the transaction manager listeners.
67
- * @public
68
- */
69
- export declare function registerTxnListeners(txns: ICoreTxnManager, onChanged: () => void): () => void;
70
- export {};
71
- //# sourceMappingURL=Transactions.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Transactions.d.ts","sourceRoot":"","sources":["../../../src/core-interop/Transactions.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAExD;;;;;;;;;GASG;AACH,UAAU,eAAe;IACvB;;;;;OAKG;IACH,QAAQ,EAAE,KAAK,CAAC;IAChB;;;;;OAKG;IACH,WAAW,EAAE,KAAK,CAAC;IACnB;;;;;OAKG;IACH,gBAAgB,EAAE,KAAK,CAAC;CACzB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAiB7F"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"Transactions.js","sourceRoot":"","sources":["../../../src/core-interop/Transactions.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAsChG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAM,UAAU,oBAAoB,CAAC,IAAqB,EAAE,SAAqB;IAC/E,IAAI,UAAU,GAAG,KAAK,CAAC;IACvB,MAAM,YAAY,GAAG,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,GAAG,EAAE;QAClD,UAAU,GAAG,IAAI,CAAC;IACpB,CAAC,CAAC,CAAC;IACH,MAAM,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,GAAG,EAAE;QACpD,IAAI,UAAU,EAAE,CAAC;YACf,SAAS,EAAE,CAAC;QACd,CAAC;QACD,UAAU,GAAG,KAAK,CAAC;IACrB,CAAC,CAAC,CAAC;IACH,MAAM,cAAc,GAAG,IAAI,CAAC,gBAAgB,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;IACpE,OAAO,GAAG,EAAE;QACV,YAAY,EAAE,CAAC;QACf,WAAW,EAAE,CAAC;QACd,cAAc,EAAE,CAAC;IACnB,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport type { Event } from \"@itwin/presentation-shared\";\n\n/**\n * An interface for a transaction manager that has 3 types of events fired before and after a commit\n * and when changes are applied on a briefcase.\n *\n * Generally, this either means [TxnManager](https://www.itwinjs.org/reference/core-backend/imodels/txnmanager/), accessed\n * through [BriefcaseDb.txns](https://www.itwinjs.org/reference/core-backend/imodels/briefcasedb/#txns), or\n * [BriefcaseTxns](https://www.itwinjs.org/reference/core-frontend/imodelconnection/briefcasetxns/), accessed\n * through [BriefcaseConnection.txns](https://www.itwinjs.org/reference/core-frontend/imodelconnection/briefcaseconnection/#txns).\n * @public\n */\ninterface ICoreTxnManager {\n /**\n * Event raised before a commit operation is performed. Initiated by a call to either\n * [IModelDb.saveChanges](https://www.itwinjs.org/reference/core-backend/imodels/imodeldb/savechanges/)\n * or [BriefcaseConnection.saveChanges](https://www.itwinjs.org/reference/core-frontend/imodelconnection/briefcaseconnection/savechanges/),\n * unless there are no changes to save.\n */\n onCommit: Event;\n /**\n * Event raised after a commit operation is performed. Initiated by a call to either\n * [IModelDb.saveChanges](https://www.itwinjs.org/reference/core-backend/imodels/imodeldb/savechanges/)\n * or [BriefcaseConnection.saveChanges](https://www.itwinjs.org/reference/core-frontend/imodelconnection/briefcaseconnection/savechanges/),\n * even if there were no changes to save.\n */\n onCommitted: Event;\n /**\n * Event raised after a changeset has been applied to the briefcase. Changesets may be applied as a result of\n * [BriefcaseDb.pullChanges](https://www.itwinjs.org/reference/core-backend/imodels/briefcasedb/) or\n * [BriefcaseConnection.pullChanges](https://www.itwinjs.org/reference/core-frontend/imodelconnection/briefcaseconnection/pullchanges/),\n * or by undo/redo operations.\n */\n onChangesApplied: Event;\n}\n\n/**\n * Registers listeners to `txns` events and calls provided `onChanged` callback when transaction manager\n * reports there are iModel data changes.\n *\n * Usage example:\n *\n * ```ts\n * import { BriefcaseDb } from \"@itwin/core-backend\";\n * import { registerTxnListeners } from \"@itwin/presentation-core-interop\";\n * import { HierarchyProvider } from \"@itwin/presentation-hierarchies\";\n *\n * // get iModel and hierarchy provider from arbitrary sources\n * const db: BriefcaseDb = getIModel();\n * const provider: HierarchyProvider = getHierarchyProvider();\n *\n * // register the listeners\n * const unregister = registerTxnListeners(db.txns, () => {\n * // notify provided about the changed data\n * provider.notifyDataSourceChanged();\n * // TODO: force the components using `provider` to reload\n * });\n *\n * // clean up on iModel close\n * db.onClosed.addOnce(() => unregister());\n * ```\n *\n * @param txns Either [TxnManager](https://www.itwinjs.org/reference/core-backend/imodels/txnmanager/), accessed\n * through [BriefcaseDb.txns](https://www.itwinjs.org/reference/core-backend/imodels/briefcasedb/#txns),\n * or [BriefcaseTxns](https://www.itwinjs.org/reference/core-frontend/imodelconnection/briefcasetxns/), accessed\n * through [BriefcaseConnection.txns](https://www.itwinjs.org/reference/core-frontend/imodelconnection/briefcaseconnection/#txns).\n * @param onChanged A function to call when transaction manager reports iModel data changes.\n * @returns A function that unregisters the transaction manager listeners.\n * @public\n */\nexport function registerTxnListeners(txns: ICoreTxnManager, onChanged: () => void): () => void {\n let hasChanges = false;\n const beforeCommit = txns.onCommit.addListener(() => {\n hasChanges = true;\n });\n const afterCommit = txns.onCommitted.addListener(() => {\n if (hasChanges) {\n onChanged();\n }\n hasChanges = false;\n });\n const appliedChanges = txns.onChangesApplied.addListener(onChanged);\n return () => {\n beforeCommit();\n afterCommit();\n appliedChanges();\n };\n}\n"]}
@@ -1,7 +0,0 @@
1
- export { createValueFormatter } from "./core-interop/Formatting.js";
2
- export { createIModelKey } from "./core-interop/IModelKey.js";
3
- export { createLogger } from "./core-interop/Logging.js";
4
- export { createECSchemaProvider } from "./core-interop/Metadata.js";
5
- export { createECSqlQueryExecutor } from "./core-interop/QueryExecutor.js";
6
- export { registerTxnListeners } from "./core-interop/Transactions.js";
7
- //# sourceMappingURL=presentation-core-interop.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"presentation-core-interop.d.ts","sourceRoot":"","sources":["../../src/presentation-core-interop.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAC3E,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"presentation-core-interop.js","sourceRoot":"","sources":["../../src/presentation-core-interop.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAC3E,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nexport { createValueFormatter } from \"./core-interop/Formatting.js\";\nexport { createIModelKey } from \"./core-interop/IModelKey.js\";\nexport { createLogger } from \"./core-interop/Logging.js\";\nexport { createECSchemaProvider } from \"./core-interop/Metadata.js\";\nexport { createECSqlQueryExecutor } from \"./core-interop/QueryExecutor.js\";\nexport { registerTxnListeners } from \"./core-interop/Transactions.js\";\n"]}