Skip to content

v4.8.0

Compare
Choose a tag to compare
@github-actions github-actions released this 08 Aug 16:16
· 393 commits to master since this release

deltaDoc: true
version: '4.8.0'

4.8.0 Change Notes

Table of contents:

Workspaces

The beta Workspace and Settings APIs have been updated to make them easier to use, including the addition of the WorkspaceEditor API for creating new WorkspaceDbs to hold workspace resources. Consult the learning article for a comprehensive overview with examples.

Electron 31 support

In addition to already supported Electron versions, iTwin.js now supports Electron 31.

Type-safe Worker APIs

The WorkerProxy APIs provide an easy way to leverage Workers in a type-safe way to move processing out of the JavaScript main thread into a background thread.

Creating graphics in Workers

Typically, you would use a GraphicBuilder to create graphics. GraphicBuilder produces a RenderGraphic containing WebGL resources like textures and vertex buffers, so it must execute on the main JavaScript thread. This is fine for simple decorations, but imagine you are streaming large data sets like GeoJSON or point clouds that must be processed into graphics - that would require far more processing which, if executed on the main thread, would utterly degrade the responsiveness of the application by blocking the event loop.

GraphicDescriptionBuilder has been introduced to address this problem. In conjunction with a WorkerProxy, you can move the heavy processing into a background thread to produce a GraphicDescription, leaving to the main thread the fast and straighforward task of converting that description into a RenderGraphic using RenderSystem.createGraphicFromDescription. See this article for an example.

Internal APIs

iTwin.js categorizes the stability of each API using release tags like @public, @beta, and @internal. @internal APIs are intended strictly for use inside of the itwinjs-core repository. They can be tricky to use correctly, and may be changed or removed at any time, so consumers of iTwin.js should not write code that depends on them. Unfortunately, up until now they have been exported from the iTwin.js core packages just like any other type of APIs, making it easy for anyone to accidentally or intentionally introduce a dependency on them. To ensure that we can adhere to our commitment to providing stable libraries, we have begun to transition to a new approach to handling these kinds of APIs.

The details are relevant primarily to contributors, but consumers should expect to find that @internal APIs they currently depend upon have been marked as deprecated. The deprecation messages include information about alternative public APIs to use instead, where appropriate. If you encounter a dependency on an @internal API which you struggle to remove, please let us know. Beginning in iTwin.js 5.0, you will no longer be able to access any @internal APIs.

ListenerType helper

We added a new helper type ListenerType to retrieve the type of the callback function for a given BeEvent. This is useful when implicit types cannot be used - for example, when you need to define a listener outside of a call to BeEvent.addListener.

ecschema-metadata CustomAttributeClass.containerType deprecated and replaced with appliesTo

The Xml and JSON representations of a custom attribute (and related TypeScript interfaces) all use a property named appliesTo of type CustomAttributeContainerType to indicate the kind(s) of schema entities to which the attribute can be applied. Confusingly, the @beta CustomAttributeClass class exposes this same information via a property named containerType. To address this discrepancy, containerType has been deprecated in favor of the new appliesTo property. The protected _containerType property was renamed to _appliesTo.

Improve the performance of the ECSchemaRpcLocater

Improve the performance of the ECSchemaRpcLocater by making all of the underlying ECSchemaRpcInterface methods GET by default so responses are cached by default. Previously each client had to set the methods to be GET or they would default to POST and were not cached.

Mathematical operation parsing

The quantity formatter supports parsing mathematical operations. The operation is solved, formatting every values present, according to the specified format. This makes it possible to process several different units at once.

// Operation containing many units (feet, inches, yards).
const mathematicalOperation = "5 ft + 12 in + 1 yd -1 ft 6 in";

// Asynchronous implementation
const quantityProps = await Parser.parseIntoQuantity(mathematicalOperation, format, unitsProvider);
quantityProps.magnitude // 7.5 (feet)

// Synchronous implementation
const parseResult = Parser.parseToQuantityValue(mathematicalOperation, format, feetConversionSpecs);
parseResult.value // 7.5 (feet)

Limitations

Only plus(`+`) and minus(`-`) signs are supported for now. Other operators will end up returning a parsing error or an invalid input result.

Usage

The parsing of mathematical operations is disabled by default. To enable it, you can override the default QuantityFormatter. Ex : ```Typescript // App specific const quantityType = QuantityType.LengthEngineering;

// Default props for the desired quantityType
const props = IModelApp.quantityFormatter.getFormatPropsByQuantityType(quantityType);

// Override the formatter and enable mathematical operations.
await IModelApp.quantityFormatter.setOverrideFormat(quantityType, { ...props, allowMathematicOperations: true });