@depche/core
Advanced tools
Comparing version 0.0.1-rcb to 0.0.1-rcb.0
import * as path from 'path'; | ||
import { join } from 'path'; | ||
import * as fs from 'fs'; | ||
import http from 'http'; | ||
@@ -62,17 +61,17 @@ function isFileExists(filePath) { | ||
function isArrContainObj(arr, obj) { | ||
return arr.some(function (node) { return node.depName === obj.depName; }); | ||
return arr.some(function (node) { return node.dependence === obj.dependence; }); | ||
} | ||
var DepGraph = /** @class */ (function () { | ||
function DepGraph() { | ||
this.Nodes = []; | ||
this.Edges = []; | ||
this.nodes = []; | ||
this.edges = []; | ||
} | ||
DepGraph.prototype.insertNode = function (dependence, version, category) { | ||
DepGraph.prototype.insertNode = function (dependence, version, level) { | ||
var node = { | ||
name: dependence + version, | ||
depName: dependence, | ||
value: version, | ||
category: category | ||
id: dependence + version, | ||
dependence: dependence, | ||
version: version, | ||
level: level | ||
}; | ||
!isArrContainObj(this.Nodes, node) && this.Nodes.push(node); | ||
!isArrContainObj(this.nodes, node) && this.nodes.push(node); | ||
}; | ||
@@ -119,113 +118,4 @@ return DepGraph; | ||
/****************************************************************************** | ||
Copyright (c) Microsoft Corporation. | ||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted. | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | ||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */ | ||
/* global Reflect, Promise, SuppressedError, Symbol */ | ||
var __assign = function() { | ||
__assign = Object.assign || function __assign(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { | ||
var e = new Error(message); | ||
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; | ||
}; | ||
function webServerPostHook(depGraph) { | ||
var categories = [ | ||
{ name: 'depth1', color: '#ff6e76', symbolSize: 100 }, | ||
{ name: 'depth2', color: '#4992ff', symbolSize: 70 }, | ||
{ name: 'depth3', color: '#7cffb2', symbolSize: 50 }, | ||
{ name: 'depth4', color: '#8d48e3', symbolSize: 30 }, | ||
{ name: 'depth5', color: '#58d9f9', symbolSize: 20 }, | ||
{ name: 'depth6', color: '#05c091', symbolSize: 15 }, | ||
{ name: 'depth7', color: '#ff8a45', symbolSize: 10 }, | ||
]; | ||
var option = { | ||
title: { | ||
text: "test depanlz", | ||
left: "center" | ||
}, | ||
color: ['#ff6e76', '#4992ff', '#7cffb2', '#8d48e3', '#58d9f9', '#05c091', '#ff8a45'], | ||
legend: { | ||
right: 0, | ||
orient: 'vertical', | ||
textStyle: { | ||
color: "white" | ||
}, | ||
padding: 20, | ||
itemWidth: 30, | ||
itemHeight: 15, | ||
data: ["depth1", "depth2", "depth3", "depth4", "depth5", "depth6", "depth7"] | ||
}, | ||
darkMode: true, | ||
backgroundColor: "#100C2A", | ||
series: [ | ||
{ | ||
type: 'graph', | ||
layout: 'force', | ||
force: { | ||
edgeLength: 300, | ||
repulsion: 4000, | ||
gravity: 0.1 | ||
}, | ||
draggable: true, | ||
roam: true, | ||
edgeSymbol: ["none", "arrow"], | ||
edgeSymbolSize: [4, 10], | ||
label: { | ||
show: true, | ||
rotate: 0, | ||
formatter: "{b} {@value}" | ||
}, | ||
emphasis: { | ||
focus: 'adjacency', | ||
label: { | ||
position: 'right', | ||
show: true | ||
} | ||
}, | ||
lineStyle: { | ||
width: 0.5, | ||
curveness: 0.3, | ||
opacity: 0.7 | ||
}, | ||
categories: categories.map(function (category) { return ({ name: category.name }); }), | ||
nodes: depGraph.Nodes.map(function (node) { return (__assign(__assign({}, node), { symbolSize: categories[node.category].symbolSize, itemStyle: { color: categories[node.category].color } })); }), | ||
edges: depGraph.Edges, | ||
} | ||
] | ||
}; | ||
var str = JSON.stringify(option, null, 2); | ||
http.createServer(function (req, res) { | ||
var html = "\n<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n <meta charset=\"UTF-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n <title>Document</title>\n</head>\n<style>\nhtml, body {\n margin: 0;\n padding: 0;\n width: 100vw;\n height: 100vh;\n}\n\n#container {\n width: 100%;\n height: 100%;\n}\n</style>\n<body>\n <div id=\"container\"></div>\n <script src=\"https://cdn.jsdelivr.net/npm/echarts@5.4.3/dist/echarts.min.js\"></script>\n <script>\n const myChart = echarts.init(document.getElementById('container'));\n myChart.showLoading();\n myChart.hideLoading();\n const option = ".concat(str, "\n myChart.setOption(option);\n console.log(echarts)\n </script>\n</body>\n</html>\n "); | ||
res.end(html); | ||
}).listen(3000, function () { | ||
console.log("http://localhost:3000"); | ||
}); | ||
} | ||
var DepAnlz = /** @class */ (function () { | ||
function DepAnlz(webServer) { | ||
this.webServer = false; | ||
this.webServer = webServer; | ||
function DepAnlz() { | ||
} | ||
@@ -238,4 +128,4 @@ DepAnlz.prototype.preHook = function () { | ||
}; | ||
DepAnlz.prototype.postHook = function (depGraph) { | ||
webServerPostHook(depGraph); | ||
DepAnlz.prototype.postHook = function (depGraph, callback) { | ||
callback(depGraph); | ||
}; | ||
@@ -245,5 +135,2 @@ DepAnlz.prototype.lifeCycle = function () { | ||
var depGraph = this.coreHook(config); | ||
if (this.webServer) { | ||
this.postHook(depGraph); | ||
} | ||
return depGraph; | ||
@@ -250,0 +137,0 @@ }; |
{ | ||
"name": "@depche/core", | ||
"version": "0.0.1-rcb", | ||
"version": "0.0.1-rcb.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/bundler.cjs", |
type DepNode = { | ||
name: string, | ||
depName: string, | ||
value: string, | ||
category: number | ||
id: string, | ||
dependence: string, | ||
version: string, | ||
level: number | ||
} | ||
@@ -14,29 +14,28 @@ | ||
function isArrContainObj(arr: Array<DepNode>, obj: DepNode): boolean { | ||
return arr.some(node => node.depName === obj.depName); | ||
return arr.some(node => node.dependence === obj.dependence); | ||
} | ||
class DepGraph { | ||
Nodes: Array<DepNode> | ||
Edges: Array<DepRel> | ||
nodes: Array<DepNode> | ||
edges: Array<DepRel> | ||
constructor() { | ||
this.Nodes = [] | ||
this.Edges = [] | ||
this.nodes = [] | ||
this.edges = [] | ||
} | ||
insertNode(dependence: string, version: string, category: number) { | ||
insertNode(dependence: string, version: string, level: number) { | ||
const node: DepNode = { | ||
name: dependence + version, | ||
depName: dependence, | ||
value: version, | ||
category | ||
id: dependence + version, | ||
dependence, | ||
version, | ||
level | ||
} | ||
!isArrContainObj(this.Nodes, node) && this.Nodes.push(node) | ||
!isArrContainObj(this.nodes, node) && this.nodes.push(node) | ||
} | ||
// insertEgde(depName, version, fromNode) { | ||
// insertEgde(dependence, version, fromNode) { | ||
// const edge = { | ||
// source: fromNode, | ||
// target: depName + version | ||
// target: dependence + version | ||
// } | ||
@@ -43,0 +42,0 @@ |
@@ -9,29 +9,10 @@ type Config = { | ||
constructor(); | ||
constructor(webServer: boolean); | ||
webServer: boolean; | ||
preHook(): Config; | ||
coreHook(config: Config): DepGraph; | ||
postHook(depGraph: DepGraph): void; | ||
lifeCycle(): DepGraph; | ||
} | ||
declare class DepGraph { | ||
Nodes: Array<DepNode> | ||
Edges: Array<DepRel> | ||
constructor(); | ||
insertNode(dependence: string, version: string, category: number): void | ||
// insertEgde(depName, version, fromNode) { | ||
// const edge = { | ||
// source: fromNode, | ||
// target: depName + version | ||
// } | ||
// this.edges.push(edge) | ||
// } | ||
coreHook(config: Config): Graph; | ||
lifeCycle(): Graph; | ||
} | ||
export { | ||
Config, | ||
DepAnlz, | ||
DepGraph | ||
DepAnlz | ||
} |
@@ -0,30 +1,25 @@ | ||
import { Config } from './global' | ||
import preHook from "./hooks/preHook" | ||
import { Config, DepGraph } from './global' | ||
import coreHook from "./hooks/coreHook"; | ||
import webServerPostHook from "./hooks/webServerPostHook"; | ||
import DepGraph from './DepGraph'; | ||
class DepAnlz { | ||
constructor(webServer: boolean) { | ||
this.webServer = webServer | ||
} | ||
constructor() {} | ||
webServer: boolean = false | ||
preHook() { | ||
preHook(): Config { | ||
return preHook(); | ||
} | ||
coreHook(config: Config) { | ||
coreHook(config: Config): DepGraph { | ||
return coreHook(config); | ||
} | ||
postHook(depGraph: DepGraph) { | ||
webServerPostHook(depGraph) | ||
postHook (depGraph: DepGraph, callback: (depGraph: DepGraph) => void) { | ||
callback(depGraph) | ||
} | ||
lifeCycle() { | ||
const config = this.preHook(); | ||
const depGraph = this.coreHook(config) | ||
const config: Config = this.preHook(); | ||
const depGraph: DepGraph = this.coreHook(config) | ||
return depGraph | ||
@@ -31,0 +26,0 @@ } |
Sorry, the diff of this file is not supported yet
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
0
15689
11
479