> cd tools/umd-to-es-modules
> npm install
> npm run transform ../../demos
Migrating to 2.2 from 2.1
The /tools/ directory in the yFiles for HTML package contains helpers that convert
your source code between various ways to import the yFiles library,
e.g., from UMD to ES module imports. We recommend running the umd-to-es-modules
tool after the automatic source code conversion tool for best results:
Location: tools/umd-to-es-modules
Based on jscodeshift
This script converts UMD imports of the yFiles library into the corresponding ES module imports.
To convert your source code, open a terminal and run:
Instead of the demos folder, you can of course transform any other folder you like, e.g. only a single demo folder.
Note that the resulting files may not be runnable in this state yet, as the transformation
might introduce syntax errors due to the removed require() calls.
Examples
Before:
require(['yfiles/view-component'], yfiles => {
const graphComponent = new yfiles.view.GraphComponent('graphComponent')
})
After:
import { GraphComponent } from "yfiles";
const graphComponent = new GraphComponent('graphComponent')
See the change log for a list of all incompatible changes.
License File Changes
Starting with 2.2, the license file is a simple JSON file instead of a UMD module. The format of the license data is still the same though. The demos also load the license from a new location: /lib/license.json instead of /demos/resources/license.js.
If you want to run the 2.2 demos with your 2.1 license, you can follow these steps:
-
Open your 2.1 license.js file which should look like this:
(function(r){(function(f){if("function"==typeof define&&define.amd){define(['yfiles/lang'],function(lang){f(lang.yfiles);});}else{f(r.yfiles||(r.yfiles={}));}}(/*@yjs:keep*/ function(yfiles) { yfiles.license = { "company": "MyCompany", // ...[your license data here] } })); }("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this)); -
Copy the actual license data (the value assigned to yfiles.license).
-
Paste the data into a new file and save it to
[path to your {product} package]/lib/license.json.
Renamed API Members
| Type | Member name in 2.1 | Member name in 2.2 |
|---|---|---|
IEnumerable |
selectMany |
flatMap |
TreeLayoutData |
leftRightPlacersLeftNodes |
leftRightNodePlacerLeftNodes |
TreeLayoutData |
delegatingNodePlacersPrimaryNodes |
delegatingNodePlacerPrimaryNodes |
HierarchicLayoutData |
alternativeEdgePath |
alternativeEdgePaths |
FixNodeLayoutData |
fixedNode |
fixedNodes |
Renamed Types
| Type name in 2.1 | Type name in 2.2 |
|---|---|
BfsDirection |
TraversalDirection |
Renamed API Members in ECMAScript Modules
These changes affect only the ES modules variant of the yFiles for HTML library, not the UMD variant.
| Name in 2.1 | Name in 2.2 |
|---|---|
YMap |
HashMap |
Classes and enums in the layout part got the complete name of the corresponding layout style as a prefix to make the name both unique and clear.
| Name in 2.1 | Name in 2.2 |
|---|---|
BusDescriptor |
BusRouterBusDescriptor |
DefaultSeriesParallelPortAssignment |
DefaultSeriesParallelLayoutPortAssignment |
DefaultTreePortAssignment |
DefaultTreeLayoutPortAssignment |
HierarchicEdgeLayoutDescriptor |
HierarchicLayoutEdgeLayoutDescriptor |
HierarchicEdgeRoutingStyle |
HierarchicLayoutEdgeRoutingStyle |
HierarchicLayeringStrategy |
HierarchicLayoutLayeringStrategy |
HierarchicNodeLayoutDescriptor |
HierarchicLayoutNodeLayoutDescriptor |
HierarchicPortAssignmentMode |
HierarchicLayoutPortAssignmentMode |
HierarchicRoutingStyle |
HierarchicLayoutRoutingStyle |
IHierarchicNodePlacer |
IHierarchicLayoutNodePlacer |
ISeriesParallelPortAssignment |
ISeriesParallelLayoutPortAssignment |
ITreeNodePlacer |
ITreeLayoutNodePlacer |
ITreePortAssignment |
ITreeLayoutPortAssignment |
OrganicScope |
OrganicLayoutScope |
OrthogonalEdgeLayoutDescriptor |
OrthogonalLayoutEdgeLayoutDescriptor |
PartialEdgeRoutingStrategy |
PartialLayoutEdgeRoutingStrategy |
RadialEdgeRoutingStrategy |
RadialLayoutEdgeRoutingStrategy |
RadialLayeringStrategy |
RadialLayoutLayeringStrategy |
RouterEdgeLayoutDescriptor |
EdgeRouterEdgeLayoutDescriptor |
Scope |
EdgeRouterScope |
SeriesParallelEdgeLayoutDescriptor |
SeriesParallelLayoutEdgeLayoutDescriptor |
SeriesParallelPortAssignmentMode |
SeriesParallelLayoutPortAssignmentMode |
SeriesParallelRoutingStyle |
SeriesParallelLayoutRoutingStyle |
TabularNodeLayoutDescriptor |
TabularLayoutNodeLayoutDescriptor |
TreeEdgeRoutingStyle |
ClassicTreeLayoutEdgeRoutingStyle |
TreePortAssignmentMode |
TreeLayoutPortAssignmentMode |
TreeRoutingStyle |
TreeLayoutEdgeRoutingStyle |
Removed API Members
clone()methods of all geometry classes:Size,Point,Insets, andRect.-
Since the classes are immutable, these methods can be dropped without replacement.
- Class
SingleItemCollection -
This class was removed and replaced by the more general
ItemCollection. YList.subList-
This method was neither implemented nor used by the library.
SnapLinetemplate keys andSnapLine.resourceKeyproperty-
All
SnapLinetemplate keys except forSNAP_LINE_STROKE_KEYwere removed since the templates are hardcoded anyway. RadialLayoutData.sourceGroupsandRadialLayoutData.targetGroupsproperties-
The properties have been removed since edge grouping is not supported by the
RadialLayout. DynamicObstacleDecomposition.getExistingCellsmethod-
This method is considered private and should not be part of the public API.
SegmentInfoBase.edgeandEdgeCellInfo.edgeproperties-
Removed due to general automatic layout improvements and refactorings.
OrganicEdgeRouter.checkNodeSizeprotected method-
Removed due to general automatic layout improvements and refactorings.
PathSearchResult.getEdgeInfo(Path)method-
Removed due to general automatic layout improvements and refactorings.
Other API Changes
-
The
GraphOverviewComponent.svgRenderingproperty is superseded by the newrenderModeproperty that allows to choose between three render modes, namelySVG,WEB_GLandCANVAS. -
The
LayoutExecutor.improvePortAssignmentandLayoutGraphAdapter.improvePortAssignmentproperties are replaced by the newportAdjustmentPolicyproperty which allows for a more fine-grained control over the port locations. -
The
IGraph.getPortLabelsmethod is by theportLabelsproperty to be more inline with the overall API. -
The
getAccumulatedInsetsandgetDecoratormethods onITableare replaced by the propertiesaccumulatedInsetsanddecoratorto be more inline with the overall API.