Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@antv/g6-core

Package Overview
Dependencies
Maintainers
61
Versions
122
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@antv/g6-core - npm Package Compare versions

Comparing version 0.7.10 to 0.7.11

5

es/element/combo.js

@@ -147,2 +147,3 @@ import { __assign } from "tslib";

var iconShapeExist = collapsedIconShape && !collapsedIconShape.destroyed;
var keyShape = item.get('keyShape');
if (collapsed && show) {

@@ -156,3 +157,3 @@ if (iconShapeExist) {

};
group.addShape('image', {
collapsedIconShape = group.addShape('image', {
attrs: __assign({

@@ -167,4 +168,6 @@ img: img,

}
keyShape.hide();
} else if (iconShapeExist) {
collapsedIconShape.hide();
keyShape.show();
}

@@ -171,0 +174,0 @@ },

2

es/global.js

@@ -50,3 +50,3 @@ var subjectColor = 'rgb(95, 149, 255)';

export default {
version: '0.7.10',
version: '0.7.11',
rootContainerClassName: 'root-container',

@@ -53,0 +53,0 @@ nodeContainerClassName: 'node-container',

@@ -5,27 +5,5 @@ import { Item } from '../../types';

private graph;
private cachedStates;
destroyed: boolean;
constructor(graph: IAbstractGraph);
/**
* 检查 cache 的可用性
*
* @private
* @param {Item} item
* @param {string} state
* @param {object} cache
* @returns
* @memberof State
*/
private static checkCache;
/**
* 缓存 state
*
* @private
* @param {Item} item Item 实例
* @param {string} state 状态名称
* @param {object} states
* @memberof State
*/
private static cacheState;
/**
* 更新 Item 的状态

@@ -38,3 +16,3 @@ *

*/
updateState(item: Item, state: string, enabled: boolean): void;
updateState(item: Item, state: string, enabled: string | boolean): void;
/**

@@ -48,10 +26,4 @@ * 批量更新 states,兼容 updateState,支持更新一个 state

*/
updateStates(item: Item, states: string | string[], enabled: boolean): void;
/**
* 更新 states
*
* @memberof State
*/
updateGraphStates(): void;
updateStates(item: Item, states: string | string[], enabled: string | boolean): void;
destroy(): void;
}

@@ -1,55 +0,8 @@

import { each, isString } from '@antv/util';
var timer = null;
import { isString } from '@antv/util';
var StateController = /** @class */function () {
function StateController(graph) {
this.graph = graph;
/**
* this.cachedStates = {
* enabled: {
* hover: [Node]
* },
* disabled: {}
* }
*/
this.cachedStates = {
enabled: {},
disabled: {}
};
this.destroyed = false;
}
/**
* 检查 cache 的可用性
*
* @private
* @param {Item} item
* @param {string} state
* @param {object} cache
* @returns
* @memberof State
*/
StateController.checkCache = function (item, state, cache) {
if (!cache[state]) {
return;
}
var index = cache[state].indexOf(item);
if (index >= 0) {
cache[state].splice(index, 1);
}
};
/**
* 缓存 state
*
* @private
* @param {Item} item Item 实例
* @param {string} state 状态名称
* @param {object} states
* @memberof State
*/
StateController.cacheState = function (item, state, states) {
if (!states[state]) {
states[state] = [];
}
states[state].push(item);
};
/**
* 更新 Item 的状态

@@ -63,25 +16,13 @@ *

StateController.prototype.updateState = function (item, state, enabled) {
var _this = this;
var checkCache = StateController.checkCache,
cacheState = StateController.cacheState;
if (item.destroyed) {
return;
}
var cachedStates = this.cachedStates;
var enabledStates = cachedStates.enabled;
var disabledStates = cachedStates.disabled;
if (enabled) {
checkCache(item, state, disabledStates);
cacheState(item, state, enabledStates);
} else {
checkCache(item, state, enabledStates);
cacheState(item, state, disabledStates);
}
if (timer) {
clearTimeout(timer);
}
timer = setTimeout(function () {
timer = null;
_this.updateGraphStates();
}, 16);
var graphStates = this.graph.get('states');
var key = state;
if (isString(enabled)) key = "".concat(state, ":").concat(enabled);
if (!graphStates[key]) graphStates[key] = [];
if (enabled) graphStates[key].push(item);else graphStates[key] = graphStates[key].filter(function (itemInState) {
return itemInState !== item;
});
this.graph.set('states', graphStates);
this.graph.emit('graphstatechange', {
states: graphStates
});
};

@@ -97,62 +38,19 @@ /**

StateController.prototype.updateStates = function (item, states, enabled) {
var _this = this;
if (isString(states)) {
this.updateState(item, states, enabled);
} else {
states.forEach(function (state) {
_this.updateState(item, state, enabled);
var graphStates = this.graph.get('states');
var stateNames = isString(states) ? [states] : states;
stateNames.forEach(function (stateName) {
var key = stateName;
if (!graphStates[key]) graphStates[key] = [];
if (isString(enabled)) key = "".concat(stateName, ":").concat(enabled);
if (enabled) graphStates[key].push(item);else graphStates[key] = graphStates[key].filter(function (itemInState) {
return itemInState !== item;
});
}
};
/**
* 更新 states
*
* @memberof State
*/
StateController.prototype.updateGraphStates = function () {
var states = this.graph.get('states');
var cachedStates = this.cachedStates;
each(cachedStates.disabled, function (val, key) {
if (states[key]) {
states[key] = states[key].filter(function (item) {
return val.indexOf(item) < 0 && !val.destroyed;
});
}
});
each(cachedStates.enabled, function (val, key) {
if (!states[key]) {
states[key] = val;
} else {
var map_1 = {};
states[key].forEach(function (item) {
if (!item.destroyed) {
map_1[item.get('id')] = true;
}
});
val.forEach(function (item) {
if (!item.destroyed) {
var id = item.get('id');
if (!map_1[id]) {
map_1[id] = true;
states[key].push(item);
}
}
});
}
});
this.graph.set('states', graphStates);
this.graph.emit('graphstatechange', {
states: states
});
this.cachedStates = {
enabled: {},
disabled: {}
};
};
StateController.prototype.destroy = function () {
this.graph = null;
this.cachedStates = null;
if (timer) {
clearTimeout(timer);
}
timer = null;
this.destroyed = true;

@@ -159,0 +57,0 @@ };

@@ -150,2 +150,3 @@ "use strict";

var iconShapeExist = collapsedIconShape && !collapsedIconShape.destroyed;
var keyShape = item.get('keyShape');
if (collapsed && show) {

@@ -159,3 +160,3 @@ if (iconShapeExist) {

};
group.addShape('image', {
collapsedIconShape = group.addShape('image', {
attrs: (0, _tslib.__assign)({

@@ -170,4 +171,6 @@ img: img,

}
keyShape.hide();
} else if (iconShapeExist) {
collapsedIconShape.hide();
keyShape.show();
}

@@ -174,0 +177,0 @@ },

@@ -56,3 +56,3 @@ "use strict";

var _default = {
version: '0.7.10',
version: '0.7.11',
rootContainerClassName: 'root-container',

@@ -59,0 +59,0 @@ nodeContainerClassName: 'node-container',

@@ -5,27 +5,5 @@ import { Item } from '../../types';

private graph;
private cachedStates;
destroyed: boolean;
constructor(graph: IAbstractGraph);
/**
* 检查 cache 的可用性
*
* @private
* @param {Item} item
* @param {string} state
* @param {object} cache
* @returns
* @memberof State
*/
private static checkCache;
/**
* 缓存 state
*
* @private
* @param {Item} item Item 实例
* @param {string} state 状态名称
* @param {object} states
* @memberof State
*/
private static cacheState;
/**
* 更新 Item 的状态

@@ -38,3 +16,3 @@ *

*/
updateState(item: Item, state: string, enabled: boolean): void;
updateState(item: Item, state: string, enabled: string | boolean): void;
/**

@@ -48,10 +26,4 @@ * 批量更新 states,兼容 updateState,支持更新一个 state

*/
updateStates(item: Item, states: string | string[], enabled: boolean): void;
/**
* 更新 states
*
* @memberof State
*/
updateGraphStates(): void;
updateStates(item: Item, states: string | string[], enabled: string | boolean): void;
destroy(): void;
}

@@ -8,55 +8,8 @@ "use strict";

var _util = require("@antv/util");
var timer = null;
var StateController = /** @class */function () {
function StateController(graph) {
this.graph = graph;
/**
* this.cachedStates = {
* enabled: {
* hover: [Node]
* },
* disabled: {}
* }
*/
this.cachedStates = {
enabled: {},
disabled: {}
};
this.destroyed = false;
}
/**
* 检查 cache 的可用性
*
* @private
* @param {Item} item
* @param {string} state
* @param {object} cache
* @returns
* @memberof State
*/
StateController.checkCache = function (item, state, cache) {
if (!cache[state]) {
return;
}
var index = cache[state].indexOf(item);
if (index >= 0) {
cache[state].splice(index, 1);
}
};
/**
* 缓存 state
*
* @private
* @param {Item} item Item 实例
* @param {string} state 状态名称
* @param {object} states
* @memberof State
*/
StateController.cacheState = function (item, state, states) {
if (!states[state]) {
states[state] = [];
}
states[state].push(item);
};
/**
* 更新 Item 的状态

@@ -70,25 +23,13 @@ *

StateController.prototype.updateState = function (item, state, enabled) {
var _this = this;
var checkCache = StateController.checkCache,
cacheState = StateController.cacheState;
if (item.destroyed) {
return;
}
var cachedStates = this.cachedStates;
var enabledStates = cachedStates.enabled;
var disabledStates = cachedStates.disabled;
if (enabled) {
checkCache(item, state, disabledStates);
cacheState(item, state, enabledStates);
} else {
checkCache(item, state, enabledStates);
cacheState(item, state, disabledStates);
}
if (timer) {
clearTimeout(timer);
}
timer = setTimeout(function () {
timer = null;
_this.updateGraphStates();
}, 16);
var graphStates = this.graph.get('states');
var key = state;
if ((0, _util.isString)(enabled)) key = "".concat(state, ":").concat(enabled);
if (!graphStates[key]) graphStates[key] = [];
if (enabled) graphStates[key].push(item);else graphStates[key] = graphStates[key].filter(function (itemInState) {
return itemInState !== item;
});
this.graph.set('states', graphStates);
this.graph.emit('graphstatechange', {
states: graphStates
});
};

@@ -104,62 +45,19 @@ /**

StateController.prototype.updateStates = function (item, states, enabled) {
var _this = this;
if ((0, _util.isString)(states)) {
this.updateState(item, states, enabled);
} else {
states.forEach(function (state) {
_this.updateState(item, state, enabled);
var graphStates = this.graph.get('states');
var stateNames = (0, _util.isString)(states) ? [states] : states;
stateNames.forEach(function (stateName) {
var key = stateName;
if (!graphStates[key]) graphStates[key] = [];
if ((0, _util.isString)(enabled)) key = "".concat(stateName, ":").concat(enabled);
if (enabled) graphStates[key].push(item);else graphStates[key] = graphStates[key].filter(function (itemInState) {
return itemInState !== item;
});
}
};
/**
* 更新 states
*
* @memberof State
*/
StateController.prototype.updateGraphStates = function () {
var states = this.graph.get('states');
var cachedStates = this.cachedStates;
(0, _util.each)(cachedStates.disabled, function (val, key) {
if (states[key]) {
states[key] = states[key].filter(function (item) {
return val.indexOf(item) < 0 && !val.destroyed;
});
}
});
(0, _util.each)(cachedStates.enabled, function (val, key) {
if (!states[key]) {
states[key] = val;
} else {
var map_1 = {};
states[key].forEach(function (item) {
if (!item.destroyed) {
map_1[item.get('id')] = true;
}
});
val.forEach(function (item) {
if (!item.destroyed) {
var id = item.get('id');
if (!map_1[id]) {
map_1[id] = true;
states[key].push(item);
}
}
});
}
});
this.graph.set('states', graphStates);
this.graph.emit('graphstatechange', {
states: states
});
this.cachedStates = {
enabled: {},
disabled: {}
};
};
StateController.prototype.destroy = function () {
this.graph = null;
this.cachedStates = null;
if (timer) {
clearTimeout(timer);
}
timer = null;
this.destroyed = true;

@@ -166,0 +64,0 @@ };

{
"name": "@antv/g6-core",
"version": "0.7.10",
"version": "0.7.11",
"description": "A Graph Visualization Framework in JavaScript",

@@ -5,0 +5,0 @@ "keywords": [

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc