npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@itwin/presentation-core-interop

v1.1.2

Published

The package acts as a layer between iTwin.js Core and Presentation packages.

Downloads

10,136

Readme

@itwin/presentation-core-interop

Copyright © Bentley Systems, Incorporated. All rights reserved. See LICENSE.md for license terms and full copyright notice.

The @itwin/presentation-core-interop package acts as a layer between itwinjs-core packages and presentation packages:

  • @itwin/presentation-hierarchies
  • @itwin/unified-selection

Having this interop layer helps us evolve both sides without affecting one another in a major way.

API

createECSqlQueryExecutor

Maps an iModel in the form of itwinjs-core IModelDb or IModelConnection to an instance of ECSqlQueryExecutor, used in @itwin/presentation-hierarchies and @itwin/unified-selection packages.

Example:

import { IModelDb } from "@itwin/core-backend";
import { createECSqlQueryExecutor } from "@itwin/presentation-core-interop";

const imodel: IModelDb = getIModelDb();
const executor = createECSqlQueryExecutor(imodel);
for await (const row of executor.createQueryReader(MY_QUERY)) {
  // TODO: do something with `row`
}

createECSchemaProvider

Maps an instance of itwinjs-core SchemaContext class to an instance of ECSchemaProvider, used in @itwin/presentation-hierarchies and @itwin/unified-selection packages.

Example:

import { SchemaContext } from "@itwin/ecschema-metadata";
import { createECSchemaProvider } from "@itwin/presentation-core-interop";

const schemas = new SchemaContext();
const schemaProvider = createECSchemaProvider(schemas);
// the created schema provider may be used in `@itwin/presentation-hierarchies` or `@itwin/unified-selection` packages

createValueFormatter

Creates an instance of IPrimitiveValueFormatter that knows how to format primitive property values using their units' information. That information is retrieved from an iModel through itwinjs-core SchemaContext.

Example:

import { SchemaContext } from "@itwin/ecschema-metadata";
import { createValueFormatter } from "@itwin/presentation-core-interop";

const schemaContext = new SchemaContext();
const formatter = createValueFormatter({ schemaContext, unitSystem: "metric" });
const formattedValue = await formatter({ type: "Double", value: 1.234, koqName: "MySchema.LengthKindOfQuantity" });

registerTxnListeners

Registers a number of transaction listeners on either the backend TxnManager or the frontend BriefcaseTxns and calls the given onChange function whenever there's a change in an iModel holding the transaction manager.

Example:

import { BriefcaseDb } from "@itwin/core-backend";
import { registerTxnListeners } from "@itwin/presentation-core-interop";
import { HierarchyProvider } from "@itwin/presentation-hierarchies";

// get iModel and hierarchy provider from arbitrary sources
const db: BriefcaseDb = getIModel();
const provider: HierarchyProvider = getHierarchyProvider();

// register the listeners
const unregister = registerTxnListeners(db.txns, () => {
  // notify provided about the changed data
  provider.notifyDataSourceChanged();
  // TODO: force the components using `provider` to reload
});

// clean up on iModel close
db.onClosed.addOnce(() => unregister());

createLogger

Maps the itwinjs-core Logger class to an ILogger interface used by Presentation packages.

Example:

import { Logger as CoreLogger } from "@itwin/core-bentley";
import { createLogger as createPresentationLogger } from "@itwin/presentation-core-interop";
import { setLogger as setPresentationLogger } from "@itwin/presentation-hierarchies";

setPresentationLogger(createPresentationLogger(CoreLogger));