Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates codebase from commonjs to es-modules syntax #33

Merged
merged 2 commits into from
May 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions example.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
var AutoLayout = require('bpmn-auto-layout');
import AutoLayout from 'bpmn-auto-layout';
import fs from 'fs/promises';

var diagramXML = `
<?xml version="1.0" encoding="UTF-8"?>
Expand Down Expand Up @@ -60,9 +61,6 @@ var diagramXML = `

var autoLayout = new AutoLayout();

var fs = require('fs').promises;


(async () => {

var layoutedDiagramXML = await autoLayout.layoutProcess(diagramXML);
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = require('./lib/AutoLayout');
export { default } from './lib/AutoLayout.js';
16 changes: 5 additions & 11 deletions lib/AutoLayout.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
var BpmnModdle = require('bpmn-moddle');
var Tree = require('./Tree');
var DiFactory = require('./DiFactory');
import BpmnModdle from 'bpmn-moddle';

var DiUtil = require('./DiUtil');

var is = DiUtil.is;
var getExpandedBounds = DiUtil.getExpandedBounds;
var getBendpoints = DiUtil.getBendpoints;
import Tree from './Tree.js';
import DiFactory from './DiFactory.js';
import { is,getExpandedBounds, getBendpoints } from './DiUtil.js';

var PADDING_NODE = 'padding_node';


function AutoLayout() {
export default function AutoLayout() {
this.moddle = new BpmnModdle();
this.DiFactory = new DiFactory(this.moddle);
this.nodeCount = -1;
}

module.exports = AutoLayout;

AutoLayout.prototype.layoutProcess = async function(xmlStr) {
var self = this;
var moddle = this.moddle;
Expand Down
17 changes: 3 additions & 14 deletions lib/DiFactory.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,12 @@
'use strict';

var map = require('min-dash').map;
var assign = require('min-dash').assign;
var pick = require('min-dash').pick;
import { map, assign, pick } from 'min-dash';
import { is, connectRectangles, getExpandedBounds } from './DiUtil.js';

var DiUtil = require('./DiUtil');

var is = DiUtil.is;
var connectRectangles = DiUtil.connectRectangles;
var getExpandedBounds = DiUtil.getExpandedBounds;


function DiFactory(moddle) {
export default function DiFactory(moddle) {
this._model = moddle;
}

module.exports = DiFactory;


DiFactory.prototype._isExpanded = function(element) {
return element && element.flowElements ? element.flowElements.length > 0 : false;
};
Expand Down
2 changes: 1 addition & 1 deletion lib/DiUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ function is(type, expected) {
return findType;
}

module.exports = {
export {
getExpandedBounds,
connectRectangles,
connectPoints,
Expand Down
4 changes: 1 addition & 3 deletions lib/Tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ TreeNode.prototype._getLastChild = function() {
return this._getChildAt(this._getChildrenCount() - 1);
};

function Tree() {
export default function Tree() {
this.config = {
iMaxDepth: 1000,
iLevelSeparation: 40,
Expand All @@ -101,8 +101,6 @@ function Tree() {
this.iLastSearch = 0;
}

module.exports = Tree;

// Layout algorithm
Tree._firstWalk = function(tree, node, level, prevSiblings = []) {

Expand Down
Loading