@itwin/presentation-core-interop 1.4.0-alpha.4 → 1.4.0-alpha.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +33 -0
- package/README.md +69 -17
- package/lib/cjs/core-interop/Formatting.d.ts +7 -7
- package/lib/cjs/core-interop/Formatting.d.ts.map +1 -1
- package/lib/cjs/core-interop/Formatting.js +3 -3
- package/lib/cjs/core-interop/Formatting.js.map +1 -1
- package/lib/cjs/core-interop/Logging.d.ts +1 -1
- package/lib/cjs/core-interop/Logging.d.ts.map +1 -1
- package/lib/cjs/core-interop/Logging.js.map +1 -1
- package/lib/cjs/core-interop/Metadata.d.ts +6 -5
- package/lib/cjs/core-interop/Metadata.d.ts.map +1 -1
- package/lib/cjs/core-interop/Metadata.js +3 -3
- package/lib/cjs/core-interop/Metadata.js.map +1 -1
- package/lib/cjs/core-interop/MetadataInternal.d.ts +2 -2
- package/lib/cjs/core-interop/MetadataInternal.d.ts.map +1 -1
- package/lib/cjs/core-interop/MetadataInternal.js +4 -8
- package/lib/cjs/core-interop/MetadataInternal.js.map +1 -1
- package/lib/cjs/core-interop/QueryExecutor.d.ts +3 -2
- package/lib/cjs/core-interop/QueryExecutor.d.ts.map +1 -1
- package/lib/cjs/core-interop/QueryExecutor.js +1 -1
- package/lib/cjs/core-interop/QueryExecutor.js.map +1 -1
- package/lib/cjs/core-interop/Transactions.d.ts +1 -1
- package/lib/cjs/core-interop/Transactions.d.ts.map +1 -1
- package/lib/cjs/core-interop/Transactions.js.map +1 -1
- package/lib/esm/core-interop/Formatting.d.ts +7 -7
- package/lib/esm/core-interop/Formatting.d.ts.map +1 -1
- package/lib/esm/core-interop/Formatting.js +4 -4
- package/lib/esm/core-interop/Formatting.js.map +1 -1
- package/lib/esm/core-interop/Logging.d.ts +1 -1
- package/lib/esm/core-interop/Logging.d.ts.map +1 -1
- package/lib/esm/core-interop/Logging.js.map +1 -1
- package/lib/esm/core-interop/Metadata.d.ts +6 -5
- package/lib/esm/core-interop/Metadata.d.ts.map +1 -1
- package/lib/esm/core-interop/Metadata.js +3 -3
- package/lib/esm/core-interop/Metadata.js.map +1 -1
- package/lib/esm/core-interop/MetadataInternal.d.ts +2 -2
- package/lib/esm/core-interop/MetadataInternal.d.ts.map +1 -1
- package/lib/esm/core-interop/MetadataInternal.js +5 -9
- package/lib/esm/core-interop/MetadataInternal.js.map +1 -1
- package/lib/esm/core-interop/QueryExecutor.d.ts +3 -2
- package/lib/esm/core-interop/QueryExecutor.d.ts.map +1 -1
- package/lib/esm/core-interop/QueryExecutor.js +1 -1
- package/lib/esm/core-interop/QueryExecutor.js.map +1 -1
- package/lib/esm/core-interop/Transactions.d.ts +1 -1
- package/lib/esm/core-interop/Transactions.d.ts.map +1 -1
- package/lib/esm/core-interop/Transactions.js.map +1 -1
- package/package.json +12 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryExecutor.js","sourceRoot":"","sources":["../../../src/core-interop/QueryExecutor.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,
|
|
1
|
+
{"version":3,"file":"QueryExecutor.js","sourceRoot":"","sources":["../../../src/core-interop/QueryExecutor.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACtF,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAc5D;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,wBAAwB,CAAC,MAA8B;IACrE,OAAO;QACL,iBAAiB,CAAC,KAAoB,EAAE,MAAgC;YACtE,MAA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AC,CAAC,KAAK,CAAC,CAAC;gBAChC,MAAM;YACR,KAAK,SAAS;gBACZ,MAAM,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;gBACrD,MAAM;YACR,KAAK,SAAS;gBACZ,MAAM,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;gBACrD,MAAM;YACR,KAAK,QAAQ;gBACX,MAAM,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;gBAClC,MAAM;QACV,CAAC;IACH,CAAC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,OAAO,CAAC,KAAa,EAAE,IAA0B;IACxD,MAAM,UAAU,GAAG,IAAI,EAAE,MAAM,CAAC,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 { 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 { ECSqlReader, QueryOptions } from \"@itwin/core-common\";\nimport type { ECSqlBinding, ECSqlQueryDef, ECSqlQueryExecutor, ECSqlQueryReaderOptions, ECSqlQueryRow } from \"@itwin/presentation-shared\";\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): ECSqlReader;\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 if (config?.restartToken) {\n opts.setRestartToken(config.restartToken);\n }\n return new ECSqlQueryReaderImpl(\n imodel.createQueryReader(trimWhitespace(addCTEs(ecsql, ctes)), bind(bindings ?? []), opts.getOptions()),\n config?.rowFormat === \"Indexes\" ? \"array\" : \"object\",\n );\n },\n };\n}\n\nclass ECSqlQueryReaderImpl implements ReturnType<ECSqlQueryExecutor[\"createQueryReader\"]> {\n public constructor(\n private _coreReader: ECSqlReader,\n private _format: \"array\" | \"object\",\n ) {}\n public [Symbol.asyncIterator](): AsyncIterableIterator<ECSqlQueryRow> {\n return this;\n }\n public async next(): Promise<IteratorResult<ECSqlQueryRow>> {\n const res = await this._coreReader.next();\n if (res.done) {\n return { done: true, value: undefined };\n }\n return {\n done: false,\n value: this._format === \"array\" ? res.value.toArray() : res.value.toRow(),\n };\n }\n}\n\nfunction bind(bindings: ECSqlBinding[]): QueryBinder {\n const binder = new QueryBinder();\n bindings.forEach((b, i) => {\n if (b.value === undefined) {\n binder.bindNull(i + 1);\n return;\n }\n switch (b.type) {\n case \"boolean\":\n binder.bindBoolean(i + 1, b.value);\n break;\n case \"double\":\n binder.bindDouble(i + 1, b.value);\n break;\n case \"id\":\n binder.bindId(i + 1, b.value);\n break;\n case \"idset\":\n binder.bindIdSet(i + 1, OrderedId64Iterable.sortArray(b.value));\n break;\n case \"int\":\n binder.bindInt(i + 1, b.value);\n break;\n case \"long\":\n binder.bindLong(i + 1, b.value);\n break;\n case \"point2d\":\n binder.bindPoint2d(i + 1, Point2d.fromJSON(b.value));\n break;\n case \"point3d\":\n binder.bindPoint3d(i + 1, Point3d.fromJSON(b.value));\n break;\n case \"string\":\n binder.bindString(i + 1, 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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Transactions.d.ts","sourceRoot":"","sources":["../../../src/core-interop/Transactions.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;
|
|
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 +1 @@
|
|
|
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 { 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
|
+
{"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"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/presentation-core-interop",
|
|
3
|
-
"version": "1.4.0-alpha.
|
|
3
|
+
"version": "1.4.0-alpha.6",
|
|
4
4
|
"description": "The package acts as a layer between iTwin.js Core and Presentation packages.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"rxjs": "^7.8.2",
|
|
34
|
-
"@itwin/presentation-shared": "~2.0.0-alpha.
|
|
34
|
+
"@itwin/presentation-shared": "~2.0.0-alpha.7"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"@itwin/core-bentley": "^4.1.0 || ^5.0.0",
|
|
@@ -41,12 +41,12 @@
|
|
|
41
41
|
"@itwin/ecschema-metadata": "^4.1.0 || ^5.0.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@itwin/build-tools": "^5.
|
|
45
|
-
"@itwin/core-bentley": "
|
|
46
|
-
"@itwin/core-common": "
|
|
47
|
-
"@itwin/core-geometry": "
|
|
48
|
-
"@itwin/core-quantity": "
|
|
49
|
-
"@itwin/ecschema-metadata": "
|
|
44
|
+
"@itwin/build-tools": "^5.5.2",
|
|
45
|
+
"@itwin/core-bentley": "5.6.0-dev.17",
|
|
46
|
+
"@itwin/core-common": "5.6.0-dev.17",
|
|
47
|
+
"@itwin/core-geometry": "5.6.0-dev.17",
|
|
48
|
+
"@itwin/core-quantity": "5.6.0-dev.17",
|
|
49
|
+
"@itwin/ecschema-metadata": "5.6.0-dev.17",
|
|
50
50
|
"@itwin/eslint-plugin": "5.1.0",
|
|
51
51
|
"@types/chai": "^5.2.3",
|
|
52
52
|
"@types/chai-as-promised": "^8.0.2",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"chai": "^5.3.3",
|
|
58
58
|
"chai-as-promised": "^8.0.2",
|
|
59
59
|
"cpx2": "^7.0.2",
|
|
60
|
-
"eslint": "^9.39.
|
|
60
|
+
"eslint": "^9.39.2",
|
|
61
61
|
"mocha": "^11.7.5",
|
|
62
62
|
"rimraf": "^6.1.2",
|
|
63
63
|
"rxjs-for-await": "^1.0.0",
|
|
@@ -71,11 +71,13 @@
|
|
|
71
71
|
"build:esm": "tsc -p tsconfig.esm.json",
|
|
72
72
|
"clean": "rimraf lib",
|
|
73
73
|
"cover": "c8 npm -s test",
|
|
74
|
-
"lint": "eslint ./src/**/*.ts",
|
|
74
|
+
"lint": "eslint \"./src/**/*.ts\"",
|
|
75
75
|
"test:dev": "mocha --enable-source-maps --config ./.mocharc.json",
|
|
76
76
|
"test": "npm run test:dev",
|
|
77
77
|
"extract-api": "betools extract-api --entry=presentation-core-interop --apiReportFolder=./api --apiReportTempFolder=./api/temp --apiSummaryFolder=./api --includeUnexportedApis",
|
|
78
78
|
"check-internal": "node ../../scripts/checkInternal.js --apiSummary ./api/presentation-core-interop.api.md",
|
|
79
|
+
"update-extractions": "node ../../scripts/updateExtractions.js --targets=./README.md",
|
|
80
|
+
"check-extractions": "node ../../scripts/updateExtractions.js --targets=./README.md --check",
|
|
79
81
|
"validate-markdowns": "node ../../scripts/validateMarkdowns.js README.md"
|
|
80
82
|
}
|
|
81
83
|
}
|