diff --git a/packages/core/package.json b/packages/core/package.json index 4c5e03c53b..79d22a54a3 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -36,7 +36,7 @@ "scripts": { "start": "father build --watch", "build": "npm run clean && father build && npm run build:umd", - "build:umd": "webpack --config webpack.config.js --mode production --profile --json > stats.json", + "build:umd": "webpack --config webpack.config.js --mode production --profile", "build:dev": "webpack --config webpack.dev.config.js --mode development", "ci": "npm run build && npm run coverage", "clean": "rimraf es esm lib dist", diff --git a/packages/core/src/graph/controller/item.ts b/packages/core/src/graph/controller/item.ts index f08567f564..261a687ba7 100644 --- a/packages/core/src/graph/controller/item.ts +++ b/packages/core/src/graph/controller/item.ts @@ -445,8 +445,10 @@ export default class ItemController { // 已经存在要设置的 state,或不存在 state 的样式为 undefined if ( - (item.hasState(stateName) === value && value) // 当该状态已经存在且现在需要设置为 true 时,不需要继续。当该状态不存在,且设置为 false 时,需要继续 - || (isString(value) && item.hasState(stateName))) { // 当该状态 value 是字符串,且已经存在该状态,不需要继续 + (item.hasState(stateName) === value && value) || // 当该状态已经存在且现在需要设置为 true 时,不需要继续。当该状态不存在,且设置为 false 时,需要继续 + (isString(value) && item.hasState(stateName)) + ) { + // 当该状态 value 是字符串,且已经存在该状态,不需要继续 return; } diff --git a/packages/core/src/graph/controller/mode.ts b/packages/core/src/graph/controller/mode.ts index a8c71fc067..3c29d8bd09 100644 --- a/packages/core/src/graph/controller/mode.ts +++ b/packages/core/src/graph/controller/mode.ts @@ -65,7 +65,7 @@ export default class ModeController { const behaves: IBehavior[] = []; let behave: IBehavior; each(behaviors || [], (behavior) => { - const BehaviorInstance = Behavior.getBehavior(behavior.type); + const BehaviorInstance = Behavior.getBehavior(behavior.type || behavior); if (!BehaviorInstance) { return; } diff --git a/packages/core/src/graph/graph.ts b/packages/core/src/graph/graph.ts index 733b5f5dbb..48044aec97 100644 --- a/packages/core/src/graph/graph.ts +++ b/packages/core/src/graph/graph.ts @@ -585,7 +585,7 @@ export default abstract class AbstractGraph extends EventEmitter implements IAbs * @param {object} padding 四周围边距 */ public fitView(padding?: Padding): void { - console.log('fiut veiuw') + console.log('fiut veiuw'); if (padding) { this.set('fitViewPadding', padding); } @@ -1212,7 +1212,7 @@ export default abstract class AbstractGraph extends EventEmitter implements IAbs */ public render(): void { const self = this; - console.log('render', self.get('fitView')) + console.log('render', self.get('fitView')); this.set('comboSorted', false); const data: GraphData = this.get('data'); @@ -2751,9 +2751,9 @@ export default abstract class AbstractGraph extends EventEmitter implements IAbs const stackData = data ? clone(data) : { - before: {}, - after: clone(this.save()), - }; + before: {}, + after: clone(this.save()), + }; if (stackType === 'redo') { this.redoStack.push({ diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index 453f1cefe6..45e0c6c3e9 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -30,7 +30,7 @@ export { registerEdge, registerBehavior, AbstractLayout, - AbstractEvent + AbstractEvent, }; export * from './types'; diff --git a/packages/core/src/item/item.ts b/packages/core/src/item/item.ts index c843ac3e43..78782df3d0 100644 --- a/packages/core/src/item/item.ts +++ b/packages/core/src/item/item.ts @@ -350,17 +350,17 @@ export default class ItemBase implements IItemBase { /** * 渲染前的逻辑,提供给子类复写 */ - protected beforeDraw() { } + protected beforeDraw() {} /** * 渲染后的逻辑,提供给子类复写 */ - protected afterDraw() { } + protected afterDraw() {} /** * 更新后做一些工作 */ - protected afterUpdate() { } + protected afterUpdate() {} /** * draw shape diff --git a/packages/core/src/shape/shape.ts b/packages/core/src/shape/shape.ts index bcb4183994..9926ba424d 100644 --- a/packages/core/src/shape/shape.ts +++ b/packages/core/src/shape/shape.ts @@ -126,17 +126,17 @@ const ShapeFramework = { /** * 绘制 */ - drawShape(/* cfg, group */) { }, + drawShape(/* cfg, group */) {}, /** * 绘制完成后的操作,便于用户继承现有的节点、边 */ - afterDraw(/* cfg, group */) { }, + afterDraw(/* cfg, group */) {}, // update(cfg, item) // 默认不定义 - afterUpdate(/* cfg, item */) { }, + afterUpdate(/* cfg, item */) {}, /** * 设置节点、边状态 */ - setState(/* name, value, item */) { }, + setState(/* name, value, item */) {}, /** * 获取控制点 * @param {Object} cfg 节点、边的配置项 diff --git a/packages/core/src/shape/shapeBase.ts b/packages/core/src/shape/shapeBase.ts index dcfa0954da..09c7ee10df 100644 --- a/packages/core/src/shape/shapeBase.ts +++ b/packages/core/src/shape/shapeBase.ts @@ -73,7 +73,7 @@ export const shapeBase: ShapeOptions = { fontFamily: typeof window !== 'undefined' ? window.getComputedStyle(document.body, null).getPropertyValue('font-family') || - 'Arial, sans-serif' + 'Arial, sans-serif' : 'Arial, sans-serif', }, }, @@ -82,7 +82,7 @@ export const shapeBase: ShapeOptions = { fontFamily: typeof window !== 'undefined' ? window.getComputedStyle(document.body, null).getPropertyValue('font-family') || - 'Arial, sans-serif' + 'Arial, sans-serif' : 'Arial, sans-serif', }, }, @@ -114,7 +114,7 @@ export const shapeBase: ShapeOptions = { * @param group * @param keyShape */ - afterDraw(cfg?: ModelConfig, group?: IGroup, keyShape?: IShape) { }, + afterDraw(cfg?: ModelConfig, group?: IGroup, keyShape?: IShape) {}, drawShape(cfg?: ModelConfig, group?: IGroup): IShape { return null as any; }, @@ -335,7 +335,7 @@ export const shapeBase: ShapeOptions = { }, // update(cfg, item) // 默认不定义 - afterUpdate(cfg?: ModelConfig, item?: Item) { }, + afterUpdate(cfg?: ModelConfig, item?: Item) {}, /** * 设置节点的状态,主要是交互状态,业务状态请在 draw 方法中实现 * 单图形的节点仅考虑 selected、active 状态,有其他状态需求的用户自己复写这个方法 diff --git a/packages/core/tests/unit/graph/controller/view-spec.ts b/packages/core/tests/unit/graph/controller/view-spec.ts index 55b26a32d9..a6c5de7ca9 100644 --- a/packages/core/tests/unit/graph/controller/view-spec.ts +++ b/packages/core/tests/unit/graph/controller/view-spec.ts @@ -50,7 +50,7 @@ describe('view', () => { graph.render(); bbox = graph.get('canvas').getCanvasBBox(); - console.log(bbox) + console.log(bbox); expect(numberEqual(bbox.x, 90, 1)).toBe(true); expect(numberEqual(bbox.maxX, 410, 1)).toBe(true); @@ -78,7 +78,7 @@ describe('view', () => { graph.render(); graph.fitView([50, 50]); const bbox = graph.get('canvas').getCanvasBBox(); - console.log(bbox) + console.log(bbox); expect(numberEqual(bbox.x, 116, 1)).toBe(true); expect(numberEqual(bbox.y, 50)).toBe(true); expect(numberEqual(bbox.width, 266, 1)).toBe(true); diff --git a/packages/core/tests/unit/graph/svg-spec.ts b/packages/core/tests/unit/graph/svg-spec.ts index fa14dad97d..b4cec75365 100644 --- a/packages/core/tests/unit/graph/svg-spec.ts +++ b/packages/core/tests/unit/graph/svg-spec.ts @@ -16,9 +16,9 @@ class Graph extends AbstractGraph { super(cfg); } - initEventController() { } + initEventController() {} - initLayoutController() { } + initLayoutController() {} initCanvas() { let container: string | HTMLElement | Element | null = this.get('container'); @@ -48,7 +48,7 @@ class Graph extends AbstractGraph { this.set('canvas', canvas); } - initPlugins() { } + initPlugins() {} } describe('graph', () => { diff --git a/packages/core/tests/unit/implement-graph.ts b/packages/core/tests/unit/implement-graph.ts index 20ab0862d0..2152b02f4d 100644 --- a/packages/core/tests/unit/implement-graph.ts +++ b/packages/core/tests/unit/implement-graph.ts @@ -6,9 +6,9 @@ export default class Graph extends AbstractGraph { super(cfg); } - initEventController() { } + initEventController() {} - initLayoutController() { } + initLayoutController() {} initCanvas() { let container: string | HTMLElement | Element | null = this.get('container'); @@ -38,5 +38,5 @@ export default class Graph extends AbstractGraph { this.set('canvas', canvas); } - initPlugins() { } + initPlugins() {} } diff --git a/packages/core/tests/unit/shape/node-spec.ts b/packages/core/tests/unit/shape/node-spec.ts index 663a633d66..4d1dbe99d8 100644 --- a/packages/core/tests/unit/shape/node-spec.ts +++ b/packages/core/tests/unit/shape/node-spec.ts @@ -251,6 +251,5 @@ describe('shape node test', () => { it('clear', () => { canvas.destroy(); }); - }); }); diff --git a/packages/core/tests/unit/shape/nodes/circle-spec.ts b/packages/core/tests/unit/shape/nodes/circle-spec.ts index 696eece72b..403a2eb465 100644 --- a/packages/core/tests/unit/shape/nodes/circle-spec.ts +++ b/packages/core/tests/unit/shape/nodes/circle-spec.ts @@ -222,6 +222,5 @@ describe('circle test', () => { graph.destroy(); expect(graph.destroyed).toBe(true); }); - }); }); diff --git a/packages/core/tests/unit/shape/nodes/rect-spec.ts b/packages/core/tests/unit/shape/nodes/rect-spec.ts index 26edd2cf02..197c975468 100644 --- a/packages/core/tests/unit/shape/nodes/rect-spec.ts +++ b/packages/core/tests/unit/shape/nodes/rect-spec.ts @@ -110,7 +110,7 @@ describe('rect test', () => { }, }); const group = node.get('group'); - console.log(group) + console.log(group); expect(group.getCount()).toEqual(2); const keyShape = node.getKeyShape(); expect(keyShape.attr('width')).toBe(30);