@chapeaux/cpx-operator-graph
Advanced tools
Comparing version 0.4.1 to 0.4.2
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.CPXOperatorGraph = void 0; | ||
const semver_parser_1 = require("https://cdn.skypack.dev/semver-parser"); | ||
const semver_parser_1 = require("semver-parser"); | ||
const tmpl = `<style> | ||
.node { fill: transparent; stroke-width: var(--cpxOGStrokeWidth,3); stroke: var(--cpxOGDisconnectedColor, #ccc); } | ||
.edges { fill: transparent; stroke-width: var(--cpxOGStrokeWidth,3); stroke: var(--cpxOGConnectedColor,#369); } | ||
.inbound, .outbound, .active { display: none; } | ||
[active] .node { stroke: var(--cpxOGActiveColor,#090); } | ||
[active] .active, [inbound] .inbound, [outbound] .outbound { display: block; } | ||
[active] .active { fill: var(--cpxOGActiveColor, #090); } | ||
[connect] .node { stroke: var(--cpxOGConnectedColor,#00F); } | ||
table { table-layout: fixed; max-width: 100%; width: 100%; border-collapse: collapse; border-spacing: 0; } | ||
thead th:nth-child(1) { width: 5%; } | ||
thead th:nth-child(2) { width: 25%; text-align:left; } | ||
thead th:nth-child(3) { width: 25%; } | ||
thead th:nth-child(4) { width: 25%; text-align: left; } | ||
thead th:nth-child(5) { width: 20%; text-align: left; } | ||
tr { border-bottom: 1px solid #999; } | ||
td { padding: 0; } | ||
tbody td:nth-child(1) {} | ||
tbody th:nth-child(2) { color: #369; text-align: left; } | ||
tbody td:nth-child(3) { text-align: right; } | ||
tbody td:nth-child(4) {} | ||
tbody td:nth-child(5) {} | ||
svg { display: block; max-width: 100px; } | ||
</style> | ||
<section> | ||
<h3>Channel</h3> | ||
<pfe-select><select id="channels"></select></pfe-select> | ||
<input type="checkbox" name="all-channels" value="all" id="all-channels"> | ||
<label for="all-channels">All operator versions</label> | ||
<table> | ||
<caption></caption> | ||
<thead><tr> | ||
<th scope="col"></th> | ||
<th scope="col">Version</th> | ||
<th scope="col"></th> | ||
<th scope="col">Update Paths</th> | ||
<th scope="col">Other Available Channels</th> | ||
</tr></thead> | ||
<tbody></tbody> | ||
</table>`; | ||
function versionSelector(strings, csv, versions, all) { | ||
return `<tr> | ||
<td><input name="${csv.packageName}" type="radio" id="${csv.version}" /></td> | ||
<td><label for="${csv.version}">${csv.version}</label> | ||
<!--<ul> | ||
${csv.replaces ? `<li>Replaces: ${csv.replaces}</li>` : ''} | ||
${csv.skips ? `<li>Skips: ${csv.skips}</li>` : ''} | ||
<li>Channel: ${csv.channelName}</li> | ||
</ul>--> | ||
</td> | ||
<td></td> | ||
${all || true ? `<td> | ||
<ul> | ||
<li>${[...versions]}</li> | ||
</ul> | ||
</td>` : ''} | ||
</tr>`; | ||
<td>Head</td> | ||
<th scope="row"> | ||
<input name="${csv.packageName}" type="radio" id="${csv.version}" /> | ||
<label for="${csv.version}">${csv.version}</label> | ||
</th> | ||
<td> | ||
${csv.replaces ? `Replaces: ${csv.replaces}` : ''} | ||
${csv.skips ? `Skips: ${csv.skips}` : ''} | ||
</td> | ||
<td><!-- INACTIVE ONLY IN --> | ||
<svg active inbound viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg"> | ||
<g class="node"> | ||
<circle cx="20" cy="50" r="10"/> | ||
<circle class="active" cx="20" cy="50" r="3"/> | ||
<line class="inbound outbound" x1="10" y1="50" x2="30" y2="50"/> | ||
<line class="inbound" x1="5" y1="43" x2="35" y2="43" stroke="white" stroke-width="12"/> | ||
<line class="outbound" x1="5" y1="57" x2="35" y2="57" stroke="white" stroke-width="12"/> | ||
</g> | ||
<g class="edges"> | ||
<path d="M 31 53 C 50 58, 80 60, 80 100" /> | ||
<path d="M 31 53 C 50 58, 90 60, 90 100" /> | ||
</g> | ||
</svg> | ||
</td> | ||
<td>beta</td> | ||
</tr>`; | ||
} | ||
@@ -56,2 +107,14 @@ function setCurve(edge) { | ||
}); | ||
Object.defineProperty(this, "connected", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: false | ||
}); | ||
Object.defineProperty(this, "graph", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: document.createElementNS('http://www.w3.org/2000/svg', 'svg') | ||
}); | ||
} | ||
@@ -86,14 +149,2 @@ } | ||
super(); | ||
Object.defineProperty(this, "template", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: void 0 | ||
}); | ||
Object.defineProperty(this, "cy", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: void 0 | ||
}); | ||
Object.defineProperty(this, "_url", { | ||
@@ -153,4 +204,9 @@ enumerable: true, | ||
}); | ||
Object.defineProperty(this, "_body", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: void 0 | ||
}); | ||
this.attachShadow({ mode: "open" }); | ||
this.template = this.querySelector("template").cloneNode(true); | ||
} | ||
@@ -182,2 +238,20 @@ static get tag() { | ||
if (this._data) { | ||
this._data.map(csv => { | ||
if (!this.versions.has(csv.version)) { | ||
this.versions.set(csv.version, new Set(csv.version)); | ||
} | ||
else { | ||
if (!this.versions.get(csv.version).has(csv.version)) { | ||
this.versions.get(csv.version).add(csv.version); | ||
} | ||
} | ||
if (this.channels.has(csv.channel_name)) { | ||
const channelInfo = this.channels.get(csv.channel_name); | ||
channelInfo.push(csv); | ||
this.channels.set(csv.channel_name, channelInfo); | ||
} | ||
else { | ||
this.channels.set(csv.channel_name, [csv]); | ||
} | ||
}); | ||
this.channels.forEach((versions, channel, d) => { | ||
@@ -251,4 +325,9 @@ d.set(channel, versions.sort((a, b) => { | ||
} | ||
get body() { | ||
if (!this._body) { | ||
this._body = this.shadowRoot.querySelector('tbody'); | ||
} | ||
return this._body; | ||
} | ||
connectedCallback() { | ||
this.shadowRoot.appendChild(this.template.content.cloneNode(true)); | ||
this.addEventListener('pfe-select:change', evt => this.channel = evt['detail'].value); | ||
@@ -262,26 +341,34 @@ } | ||
} | ||
handleClick(id) { | ||
return (e) => { | ||
const active = this.shadowRoot.querySelector('[active]'); | ||
if (active) { | ||
active.removeAttribute('active'); | ||
} | ||
this.shadowRoot.getElementById(id).setAttribute('active', ''); | ||
}; | ||
} | ||
render(all) { | ||
if (this.channels.size > 0) { | ||
this.template = this.querySelector("template").cloneNode(true); | ||
const channelSelect = this.template.content.querySelector('#channels'); | ||
[...this.channels.keys()].forEach(channel => { | ||
const opt = document.createElement('option'); | ||
opt.innerHTML = channel; | ||
opt.setAttribute('value', channel); | ||
if (this.channel === channel) { | ||
opt.setAttribute('selected', 'selected'); | ||
} | ||
channelSelect.appendChild(opt); | ||
}); | ||
const versionsNode = this.template.content.querySelector('[data-repeat="versions"]'); | ||
this.shadowRoot.innerHTML = tmpl; | ||
if (this.channels.get(this.channel)) { | ||
this.channels.get(this.channel).forEach(csv => { | ||
versionsNode.innerHTML += versionSelector `${csv}${this.versions}${all}`; | ||
let row = document.createElement('tr'); | ||
row.id = csv['_id']; | ||
row.onclick = this.handleClick(row.id); | ||
row.innerHTML = `<td></td> | ||
<th scope="row">${csv['version']}</th> | ||
<td>${csv['replaces'] || ''}</td> | ||
<td><svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg"> | ||
<g class="node"> | ||
<circle cx="20" cy="50" r="10"/> | ||
<circle class="active" cx="20" cy="50" r="3"/> | ||
<line class="inbound outbound" x1="10" y1="50" x2="30" y2="50"/> | ||
<line class="inbound" x1="5" y1="43" x2="35" y2="43" stroke="white" stroke-width="12"/> | ||
<line class="outbound" x1="5" y1="57" x2="35" y2="57" stroke="white" stroke-width="12"/> | ||
</g> | ||
<g class="edges"></g> | ||
</svg></td> | ||
<td>${csv['channels'] || ''}</td>`; | ||
this.body.appendChild(row); | ||
}); | ||
const graphImg = versionsNode.querySelector('tr td:nth-child(3)'); | ||
graphImg.id = 'graph'; | ||
graphImg.innerHTML = '<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg"><circle cx="20" cy="50" r="10" stroke="black" fill="transparent" stroke-width="3"></circle></svg>'; | ||
while (this.shadowRoot.firstChild) { | ||
this.shadowRoot.removeChild(this.shadowRoot.firstChild); | ||
} | ||
this.shadowRoot.appendChild(this.template.content.cloneNode(true)); | ||
} | ||
@@ -288,0 +375,0 @@ } |
@@ -1,20 +0,70 @@ | ||
import cytoscape from "https://cdnjs.cloudflare.com/ajax/libs/cytoscape/3.19.1/cytoscape.esm.min.js"; | ||
import { compareSemVer } from 'https://cdn.skypack.dev/semver-parser'; | ||
const tmpl = `<style> | ||
.node { fill: transparent; stroke-width: var(--cpxOGStrokeWidth,3); stroke: var(--cpxOGDisconnectedColor, #ccc); } | ||
.edges { fill: transparent; stroke-width: var(--cpxOGStrokeWidth,3); stroke: var(--cpxOGConnectedColor,#369); } | ||
.inbound, .outbound, .active { display: none; } | ||
[active] .node { stroke: var(--cpxOGActiveColor,#090); } | ||
[active] .active, [inbound] .inbound, [outbound] .outbound { display: block; } | ||
[active] .active { fill: var(--cpxOGActiveColor, #090); } | ||
[connect] .node { stroke: var(--cpxOGConnectedColor,#00F); } | ||
table { table-layout: fixed; max-width: 100%; width: 100%; border-collapse: collapse; border-spacing: 0; } | ||
thead th:nth-child(1) { width: 5%; } | ||
thead th:nth-child(2) { width: 25%; text-align:left; } | ||
thead th:nth-child(3) { width: 25%; } | ||
thead th:nth-child(4) { width: 25%; text-align: left; } | ||
thead th:nth-child(5) { width: 20%; text-align: left; } | ||
tr { border-bottom: 1px solid #999; } | ||
td { padding: 0; } | ||
tbody td:nth-child(1) {} | ||
tbody th:nth-child(2) { color: #369; text-align: left; } | ||
tbody td:nth-child(3) { text-align: right; } | ||
tbody td:nth-child(4) {} | ||
tbody td:nth-child(5) {} | ||
svg { display: block; max-width: 100px; } | ||
</style> | ||
<section> | ||
<h3>Channel</h3> | ||
<pfe-select><select id="channels"></select></pfe-select> | ||
<input type="checkbox" name="all-channels" value="all" id="all-channels"> | ||
<label for="all-channels">All operator versions</label> | ||
<table> | ||
<caption></caption> | ||
<thead><tr> | ||
<th scope="col"></th> | ||
<th scope="col">Version</th> | ||
<th scope="col"></th> | ||
<th scope="col">Update Paths</th> | ||
<th scope="col">Other Available Channels</th> | ||
</tr></thead> | ||
<tbody></tbody> | ||
</table>`; | ||
function versionSelector(strings, csv, versions, all) { | ||
return `<tr> | ||
<td><input name="${csv.packageName}" type="radio" id="${csv.version}" /></td> | ||
<td><label for="${csv.version}">${csv.version}</label> | ||
<!--<ul> | ||
${csv.replaces ? `<li>Replaces: ${csv.replaces}</li>` : ''} | ||
${csv.skips ? `<li>Skips: ${csv.skips}</li>` : ''} | ||
<li>Channel: ${csv.channelName}</li> | ||
</ul>--> | ||
</td> | ||
<td></td> | ||
${all || true ? `<td> | ||
<ul> | ||
<li>${[...versions]}</li> | ||
</ul> | ||
</td>` : ''} | ||
</tr>`; | ||
<td>Head</td> | ||
<th scope="row"> | ||
<input name="${csv.packageName}" type="radio" id="${csv.version}" /> | ||
<label for="${csv.version}">${csv.version}</label> | ||
</th> | ||
<td> | ||
${csv.replaces ? `Replaces: ${csv.replaces}` : ''} | ||
${csv.skips ? `Skips: ${csv.skips}` : ''} | ||
</td> | ||
<td><!-- INACTIVE ONLY IN --> | ||
<svg active inbound viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg"> | ||
<g class="node"> | ||
<circle cx="20" cy="50" r="10"/> | ||
<circle class="active" cx="20" cy="50" r="3"/> | ||
<line class="inbound outbound" x1="10" y1="50" x2="30" y2="50"/> | ||
<line class="inbound" x1="5" y1="43" x2="35" y2="43" stroke="white" stroke-width="12"/> | ||
<line class="outbound" x1="5" y1="57" x2="35" y2="57" stroke="white" stroke-width="12"/> | ||
</g> | ||
<g class="edges"> | ||
<path d="M 31 53 C 50 58, 80 60, 80 100" /> | ||
<path d="M 31 53 C 50 58, 90 60, 90 100" /> | ||
</g> | ||
</svg> | ||
</td> | ||
<td>beta</td> | ||
</tr>`; | ||
} | ||
@@ -34,2 +84,36 @@ function setCurve(edge) { | ||
} | ||
class OperatorGraph { | ||
constructor() { | ||
Object.defineProperty(this, "active", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: false | ||
}); | ||
Object.defineProperty(this, "inbound", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: false | ||
}); | ||
Object.defineProperty(this, "outbound", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: false | ||
}); | ||
Object.defineProperty(this, "connected", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: false | ||
}); | ||
Object.defineProperty(this, "graph", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: document.createElementNS('http://www.w3.org/2000/svg', 'svg') | ||
}); | ||
} | ||
} | ||
class OperatorBundle { | ||
@@ -49,2 +133,8 @@ constructor() { | ||
}); | ||
Object.defineProperty(this, "index", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: void 0 | ||
}); | ||
} | ||
@@ -57,14 +147,2 @@ getVersions() { } | ||
super(); | ||
Object.defineProperty(this, "template", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: void 0 | ||
}); | ||
Object.defineProperty(this, "cy", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: void 0 | ||
}); | ||
Object.defineProperty(this, "_url", { | ||
@@ -124,4 +202,9 @@ enumerable: true, | ||
}); | ||
Object.defineProperty(this, "_body", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: void 0 | ||
}); | ||
this.attachShadow({ mode: "open" }); | ||
this.template = this.querySelector("template").cloneNode(true); | ||
} | ||
@@ -152,2 +235,28 @@ static get tag() { | ||
this._data = val; | ||
if (this._data) { | ||
this._data.map(csv => { | ||
if (!this.versions.has(csv.version)) { | ||
this.versions.set(csv.version, new Set(csv.version)); | ||
} | ||
else { | ||
if (!this.versions.get(csv.version).has(csv.version)) { | ||
this.versions.get(csv.version).add(csv.version); | ||
} | ||
} | ||
if (this.channels.has(csv.channel_name)) { | ||
const channelInfo = this.channels.get(csv.channel_name); | ||
channelInfo.push(csv); | ||
this.channels.set(csv.channel_name, channelInfo); | ||
} | ||
else { | ||
this.channels.set(csv.channel_name, [csv]); | ||
} | ||
}); | ||
this.channels.forEach((versions, channel, d) => { | ||
d.set(channel, versions.sort((a, b) => { | ||
const ord = { desc: 1, asc: -1 }; | ||
return compareSemVer(b['version'], a['version']) * ord[this.order]; | ||
})); | ||
}); | ||
} | ||
this.render(); | ||
@@ -214,4 +323,9 @@ } | ||
} | ||
get body() { | ||
if (!this._body) { | ||
this._body = this.shadowRoot.querySelector('tbody'); | ||
} | ||
return this._body; | ||
} | ||
connectedCallback() { | ||
this.shadowRoot.appendChild(this.template.content.cloneNode(true)); | ||
this.addEventListener('pfe-select:change', evt => this.channel = evt['detail'].value); | ||
@@ -225,92 +339,34 @@ } | ||
} | ||
handleClick(id) { | ||
return (e) => { | ||
const active = this.shadowRoot.querySelector('[active]'); | ||
if (active) { | ||
active.removeAttribute('active'); | ||
} | ||
this.shadowRoot.getElementById(id).setAttribute('active', ''); | ||
}; | ||
} | ||
render(all) { | ||
if (this.data && this.filter !== "" && this.query !== "") { | ||
const filteredData = this._data.filter((d) => d[this.filter] === this.query); | ||
filteredData.map(csv => { | ||
if (this.channels.has(csv.channelName)) { | ||
let channelInfo = this.channels.get(csv.channelName); | ||
channelInfo.push(csv); | ||
this.channels.set(csv.channelName, channelInfo); | ||
} | ||
else { | ||
this.channels.set(csv.channelName, [csv]); | ||
} | ||
}); | ||
this.channels.forEach((versions, channel, d) => { | ||
d.set(channel, versions.sort((a, b) => { | ||
const ord = { desc: 1, asc: -1 }; | ||
return compareSemVer(b['version'], a['version']) * ord[this.order]; | ||
})); | ||
}); | ||
} | ||
if (this.channels.size > 0) { | ||
this.template = this.querySelector("template").cloneNode(true); | ||
const channelSelect = this.template.content.querySelector('#channels'); | ||
[...this.channels.keys()].forEach(channel => { | ||
const opt = document.createElement('option'); | ||
opt.innerHTML = channel; | ||
opt.setAttribute('value', channel); | ||
if (this.channel === channel) { | ||
opt.setAttribute('selected', 'selected'); | ||
} | ||
channelSelect.appendChild(opt); | ||
}); | ||
const versionsNode = this.template.content.querySelector('[data-repeat="versions"]'); | ||
this.shadowRoot.innerHTML = tmpl; | ||
if (this.channels.get(this.channel)) { | ||
this.channels.get(this.channel).forEach(csv => { | ||
versionsNode.innerHTML += versionSelector `${csv}${this.versions}${all}`; | ||
let row = document.createElement('tr'); | ||
row.id = csv['_id']; | ||
row.onclick = this.handleClick(row.id); | ||
row.innerHTML = `<td></td> | ||
<th scope="row">${csv['version']}</th> | ||
<td>${csv['replaces'] || ''}</td> | ||
<td><svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg"> | ||
<g class="node"> | ||
<circle cx="20" cy="50" r="10"/> | ||
<circle class="active" cx="20" cy="50" r="3"/> | ||
<line class="inbound outbound" x1="10" y1="50" x2="30" y2="50"/> | ||
<line class="inbound" x1="5" y1="43" x2="35" y2="43" stroke="white" stroke-width="12"/> | ||
<line class="outbound" x1="5" y1="57" x2="35" y2="57" stroke="white" stroke-width="12"/> | ||
</g> | ||
<g class="edges"></g> | ||
</svg></td> | ||
<td>${csv['channels'] || ''}</td>`; | ||
this.body.appendChild(row); | ||
}); | ||
const graphImg = versionsNode.querySelector('tr td:nth-child(3)'); | ||
graphImg.id = 'graph'; | ||
graphImg.setAttribute('rowspan', [...this.channels.get(this.channel)].length.toString()); | ||
graphImg.innerHTML = '<div id="cy"></div>'; | ||
while (this.shadowRoot.firstChild) { | ||
this.shadowRoot.removeChild(this.shadowRoot.firstChild); | ||
} | ||
this.shadowRoot.appendChild(this.template.content.cloneNode(true)); | ||
this.cy = cytoscape({ | ||
container: this.shadowRoot.querySelector("#cy"), | ||
elements: [...this.channels.get(this.channel)].reduce((a, csv) => { | ||
a = a.concat([{ data: { id: csv.csvName } }]); | ||
if (csv.replaces) { | ||
a = a.concat([{ data: { | ||
id: csv.csvName + 'replace', | ||
source: csv.replaces, | ||
target: csv.csvName, | ||
controlPointDistances: '0 0' | ||
} | ||
}]); | ||
} | ||
return a; | ||
}, []), | ||
zoomingEnabled: false, | ||
panningEnabled: false, | ||
boxSelectionEnabled: false, | ||
autoungrabify: true, | ||
style: [ | ||
{ | ||
selector: "node", | ||
style: { | ||
"width": 25, | ||
"height": 25, | ||
"background-color": "#fff", | ||
"border-width": 3, | ||
"border-color": "#00F", | ||
}, | ||
}, | ||
{ | ||
selector: "edge", | ||
style: { | ||
"width": 3, | ||
"line-color": "#00F", | ||
"curve-style": "unbundled-bezier", | ||
'control-point-weights': '0.1 0.2 0.5 0.8 0.9', | ||
'control-point-distances': '30 40 40 40 30' | ||
} | ||
}, | ||
], | ||
layout: { | ||
name: "grid", | ||
columns: 1, | ||
}, | ||
}); | ||
} | ||
@@ -320,2 +376,1 @@ } | ||
window.customElements.define(CPXOperatorGraph.tag, CPXOperatorGraph); | ||
//# sourceMappingURL=cpx-operator-graph.js.map |
{ | ||
"name": "@chapeaux/cpx-operator-graph", | ||
"version": "0.4.1", | ||
"version": "0.4.2", | ||
"description": "Chapeaux Operator Graph Component", | ||
@@ -32,3 +32,6 @@ "type": "module", | ||
"homepage": "https://github.com/chapeaux/cpx-components/components/cpx-operator-graph", | ||
"gitHead": "dcaa7eae112fdcf003d4f869272123e418b8f104" | ||
"gitHead": "da1d23d27058c4b6b02190b7e8e580891fe680b2", | ||
"dependencies": { | ||
"semver-parser": "^4.0.0" | ||
} | ||
} |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 2 instances in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
3
0
4
61135
1
6
776
+ Addedsemver-parser@^4.0.0
+ Addedsemver-parser@4.1.7(transitive)