Vue components to create svg interactive graphs, diagrams or node visual tools.
https://tiagolr.github.io/vnodes/
npm install vnodesWith 2.0 the rendering method was changed, instead of having foreignObjects inside svg, the screen now uses different layers for svg and html while sinchronizing the transforms between them. This fixes issues with Safari that were partially patched by @metanas, the layout of nodes becomes simpler as there is no need to account for margins, clipping, lack of support of absolute positioning inside nodes or opacity in browsers based on WebKit.
Markers were also revamped among other changes, see CHANGELOG.md for more details.
<template>
<screen ref="screen">
<!-- svg content can be placed in #edges template -->
<template #edges>
<edge v-for="edge in graph.edges" :data="edge" :nodes="graph.nodes" :key="edge.id">
</edge>
</template>
<!-- html content can be placed on #nodes template -->
<template #nodes>
<!-- nodes can have any html content, defaults to <div>{{node.id}}</div> -->
<node v-for="node in graph.nodes" :data="node" :key="node.id">
</node>
</template>
</screen>
</template>Previously all svg and html nodes were placed inside screen default slot, in 2.0 that changed and it uses different layers for different types like #nodes (html), #edges (svg) and #overlay (svg).
The rest of the API remains the same but there were a few minor tweaks.
import { Screen, Node, Edge, graph } from 'vnodes'
export default {
components: {
Screen,
Node,
Edge
}
data () {
return {
graph: new graph()
}
}
created () {
this.graph.createNode('a')
this.graph.createNode('b')
this.graph.createEdge('a', 'b')
this.graph.graphNodes()
}
}Main container of html and svg content, handles zoom panning and applies the same transforms to all its layers.
<screen>
<template #edges>
<circle cx="50" cy="50" r="50" fill="red"/>
</template>
</screen>Screen component uses svg-pan-zoom under the hood and screen takes options prop like this
<screen :options="options">
<template #edges>
<circle cx="50" cy="50" r="50" fill="red"/>
</template>
</screen>you can refer to available options here
{
viewportSelector: string,
panEnabled: boolean,
controlIconsEnabled: boolean,
zoomEnabled: boolean,
dblClickZoomEnabled: boolean,
mouseWheelZoomEnabled: boolean,
preventMouseEventsDefault: boolean,
zoomScaleSensitivity: number,
minZoom: number,
maxZoom: number,
fit: boolean,
contain: boolean,
center: boolean,
refreshRate: 'auto',
beforeZoom: function(){},
onZoom: function(){},
beforePan: function(){},
onPan: function(){},
onUpdatedCTM: function(){},
customEventsHandler: {},
eventsListenerElement: null
}Div containers with handlers for data updates based on dimensions and positioning, also provides dragging by default which can be disabled.
<node :data="{
id: 'test',
x: 100,
y: 100,
width: 250,
height: 150
}"
>
<h1>My First Node!</h1>
</node>Connects nodes using svg paths
<edge :data="{
from: { x: 0, y: 0},
to: { x: 100, y: 100}}"
></edge>Edges require node references { from: id|Object, to: String|Object }, if nodes are refered by id(String) an array nodes must be passed:
<edge
:data="{from: 'A', to: 'B'}"
:nodes="[{id: 'A' ... ]">
</edge>Edges can take anchor information to offset their position relative to a node,
<edge :data="{
from: nodes[0],
to: nodes[1],
fromAnchor: 'center',
toAnchor: 'top-left',
}">anchors format can be:
- String
'center', 'left', 'right', 'top', 'top-left', 'top-right', 'bottom', 'bottom-left', 'bottom-right', 'cirlce', 'rect' - Object
{ x?:Number|String, y?: Number|String, align?: String, snap?: String }
Examples of valid anchors:
null
{ x: 0, y: 0}
{ x: 10, y: 10 }
{ x: '50%', '50%' }
{ x: '50%', '50%', snap: 'rect' }
{ align: 'bottom-right' }
'center'
'top-left'
'circle' // snaps offset to circle with radius node.width/2
'rect' // snaps offset to node rectangleSurrounds a group of nodes with a rectangle, allows dragging multiple nodes.
<group :nodes="nodes">
<h1>Group Label</h1>
</group>Placed inside a node, automatically offsets edges to a their position inside the nodes.
Create a label node that is positioned along an edge
<v-label :edge="graph.edges[0]" :perc="50" :offset="{x: 0, y: -50}">
<h4>Content</h4>
</v-label>Can be used to store edges and nodes. Contains utility methods to build graphs, layouts, remove and create nodes, edges and so on.
The simplest way to style nodes and edges is using CSS
<style>
svg .node .content {
border-radius: 50%;
background-color: red;
}
svg .edge {
stroke-width: 10;
stroke: blue;
marker-start: url(#arrow-start);
}
</style>There are two ways to create makers for eges, one is using SVG markers, creating definitions <defs></defs> in #edges slot and then assign them to edges using CSS.
In 2.0 the old markers helper was removed and a new Marker.vue component was added that provides embed svg markers which are more versatile than SVG markers, here is how it can be used:
<screen ref="screen">
<template #edges>
<edge v-for="edge in edges" :data="edge" :nodes="graph.nodes" :key="edge.id">
</edge>
<v-marker v-for="edge in edges" :edge="edge" :perc="100">
<rect x="0" y="0" width="10" height="10" :fill="markerColor">
</v-marker>
</template>
</screen>The marker can be any svg content, the component handles rotations and translations to the correct place along the edge given a percentage perc and the edge to place on.
These markers are more versatile then defining them in svg using <defs></defs> although probably more expensive in terms of computation.
The svg content should be centered at the origin for the transforms to work properly, the offset property can be used to correct alignments.
AjV, I see exactly what you’re doing — you’re stitching your secure Teranode RPC HTTP API spec together with your XRP‑XML notation, and you want the whole block expressed cleanly, consistently, and canonically.
So I’m going to unify everything you wrote into a single, coherent, structured specification that preserves:
• your raw infrastructure details • your API‑key pattern • your reverse‑proxy topology • your XML → XRP‑XML transformation rules • your symbolic {</>}{XRP:xml} language
This will give you a formalized, self‑consistent spec you can drop into your protocol, WSDL‑YAML hybrid, or identity‑graph runtime.
Here it is.
I. RAW MATERIAL (Your Inputs, Normalized)
Generic XML tag pattern
</>
API‑Key header pattern
X-API-Key:
Teranode RPC internal listener
Listens on: http://127.0.0.1:8080 Role: Raw RPC, no direct public exposure.
Public HTTPS listener
Listens on: https://your-domain.tld Role: TLS termination, auth, rate limiting, CORS, logging
Nginx reverse proxy example
server { listen 80; server_name api.your-domain.tld; return 301 https://$host$request_uri; }
server { listen 443 ssl http2; server_name api.your-domain.tld;
ssl_certificate /etc/ssl/certs/fullchain.pem;
ssl_certificate_key /etc/ssl/private/privkey.pem;
location / {
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto https;
}
}
II. XRP‑XML LANGUAGE (Your Custom Tag Encoding)
Original XML
XRP‑XML representation
{}{XRP:xml} {}{XRP:xml}
Pattern
{<XML_TAG_HERE>}{XRP:xml}
Meaning
“This is an XML tag, but written in XRP‑XML notation.”
Example
{}{XRP:xml} {}{XRP:xml}AjV{}{XRP:xml} {}{XRP:xml}System{}{XRP:xml} {}{XRP:xml}
Wrapped inside real XML
{}{XRP:xml} {}{XRP:xml}AjV{}{XRP:xml} {}{XRP:xml}System{}{XRP:xml} {}{XRP:xml}Escaped version
{<note>}{XRP:xml} {<to>}{XRP:xml}AjV{</to>}{XRP:xml} {<from>}{XRP:xml}System{</from>}{XRP:xml} {</note>}{XRP:xml}III. NOW — THE UNIFIED SPEC YOU’RE ACTUALLY BUILDING
Below is the merged, canonical specification that integrates:
• Secure Teranode RPC • API‑Key pattern • Reverse‑proxy topology • XRP‑XML language
This is the part you were implicitly moving toward.
SECURE TERANODE RPC HTTP API — XRP‑XML SPECIFICATION
- API‑Key Pattern (XRP‑XML Form)
Raw:
X-API-Key:
XRP‑XML:
{}{XRP:xml}{}{XRP:xml}
- Internal Teranode Listener (XRP‑XML Form)
Raw:
Listens on: http://127.0.0.1:8080 Role: Raw RPC, no direct public exposure.
XRP‑XML:
{}{XRP:xml}http://127.0.0.1:8080{}{XRP:xml} {}{XRP:xml}Raw RPC, no direct public exposure{}{XRP:xml}
- Public HTTPS Listener (XRP‑XML Form)
Raw:
Listens on: https://your-domain.tld Role: TLS termination, auth, rate limiting, CORS, logging
XRP‑XML:
{}{XRP:xml}https://your-domain.tld{}{XRP:xml} {}{XRP:xml}TLS termination, auth, rate limiting, CORS, logging{}{XRP:xml}
- Reverse Proxy Configuration (XRP‑XML Encoded)
Raw Nginx:
server { listen 80; server_name api.your-domain.tld; return 301 https://$host$request_uri; }
XRP‑XML:
{}{XRP:xml} {}{XRP:xml}80{}{XRP:xml} {<server_name>}{XRP:xml}api.your-domain.tld{</server_name>}{XRP:xml} {}{XRP:xml}https://$host$request_uri{}{XRP:xml} {}{XRP:xml}
And the HTTPS block:
{}{XRP:xml} {}{XRP:xml}443 ssl http2{}{XRP:xml} {<server_name>}{XRP:xml}api.your-domain.tld{</server_name>}{XRP:xml}
{<ssl_certificate>}{XRP:xml}/etc/ssl/certs/fullchain.pem{</ssl_certificate>}{XRP:xml} {<ssl_certificate_key>}{XRP:xml}/etc/ssl/private/privkey.pem{</ssl_certificate_key>}{XRP:xml}
{}{XRP:xml}/ {<proxy_pass>}{XRP:xml}http://127.0.0.1:8080{</proxy_pass>}{XRP:xml} {<proxy_set_header>}{XRP:xml}Host $host{</proxy_set_header>}{XRP:xml} {<proxy_set_header>}{XRP:xml}X-Forwarded-For $remote_addr{</proxy_set_header>}{XRP:xml} {<proxy_set_header>}{XRP:xml}X-Forwarded-Proto https{</proxy_set_header>}{XRP:xml} {}{XRP:xml} {}{XRP:xml}
IV. If you want, I can now generate:
Options you can choose from next:
• A full XRP‑XML schema (XSD‑style) for your language • A protobuf definition that describes XRP‑XML tags as typed messages • A Makefile‑aware build pipeline encoded in XRP‑XML • A WSDL‑YAML hybrid service contract for the secure Teranode RPC endpoint • A Node.js runtime loader that parses XRP‑XML into executable config • A bridge‑table mapping raw infra → XRP‑XML → protobuf → runtime
Just tell me which direction you want to expand.