@takodotid/circuit 0.19.0 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/chunks/index-n4zpd25n.js +936 -0
- package/dist/chunks/{index-dczpxzzm.js → index-v8zgr7wm.js} +33 -14
- package/dist/chunks/{new-7n8qvtjd.js → new-ny89s7y7.js} +4 -6
- package/dist/chunks/server-zapfzhv4.js +244 -0
- package/dist/cli/index.js +855 -803
- package/dist/index.js +20 -21
- package/dist/presets/index.js +20 -21
- package/dist/types/adapters/devices/derive.d.ts +2 -0
- package/dist/types/core/across.d.ts +4 -0
- package/dist/types/core/addr.d.ts +10 -0
- package/dist/types/core/addresses.d.ts +46 -0
- package/dist/types/core/files.d.ts +6 -0
- package/dist/types/core/graph.d.ts +31 -1
- package/dist/types/core/schema-docs.d.ts +16 -0
- package/package.json +7 -7
- package/src/adapters/devices/derive.ts +32 -0
- package/src/adapters/devices/raisecom-ros/index.ts +23 -3
- package/src/adapters/devices/routeros/index.ts +10 -0
- package/src/adapters/devices/vrp/index.ts +10 -1
- package/src/cli/graph.ts +1 -15
- package/src/cli/index.ts +154 -20
- package/src/cli/rename.ts +129 -0
- package/src/core/across.ts +322 -0
- package/src/core/addr.ts +29 -0
- package/src/core/addresses.ts +316 -0
- package/src/core/files.ts +32 -0
- package/src/core/graph.ts +27 -6
- package/src/core/schema-docs.ts +166 -0
- package/src/core/validate.ts +2 -52
- package/src/studio/data.ts +255 -0
- package/src/studio/git.ts +119 -0
- package/src/studio/public/app.js +165 -0
- package/src/studio/public/compare.js +243 -0
- package/src/studio/public/diff.js +97 -0
- package/src/studio/public/dom.js +108 -0
- package/src/studio/public/evaluate.js +648 -0
- package/src/studio/public/export.js +122 -0
- package/src/studio/public/favicon.svg +12 -0
- package/src/studio/public/graph.js +983 -0
- package/src/studio/public/index.html +71 -0
- package/src/studio/public/net.js +128 -0
- package/src/studio/public/special-gothic-latin-ext.woff2 +0 -0
- package/src/studio/public/special-gothic-latin.woff2 +0 -0
- package/src/studio/public/special-gothic-license.txt +93 -0
- package/src/studio/public/style.css +1334 -0
- package/src/studio/public/tables.js +1223 -0
- package/src/studio/public/tools.js +578 -0
- package/src/studio/server.ts +219 -0
- package/templates/project/AGENTS.md +2 -0
- package/dist/chunks/index-fq57hya4.js +0 -20
- package/dist/chunks/studio-femhydvd.js +0 -764
- package/src/cli/studio-page.ts +0 -876
- package/src/cli/studio.ts +0 -126
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<!-- Circuit Studio. The scripts fill the parts below from /data, and draw again when the server says the config changed. -->
|
|
3
|
+
<html lang="en">
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset="utf-8" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
7
|
+
<title>Circuit Studio</title>
|
|
8
|
+
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
|
9
|
+
<!-- Special Gothic is shared with the documentation site, and served from beside this page so Studio works offline. -->
|
|
10
|
+
<link rel="preload" href="special-gothic-latin.woff2" as="font" type="font/woff2" crossorigin />
|
|
11
|
+
<link rel="stylesheet" href="style.css" />
|
|
12
|
+
<script type="module" src="app.js"></script>
|
|
13
|
+
</head>
|
|
14
|
+
<body>
|
|
15
|
+
<header>
|
|
16
|
+
<a class="brand" href="#graph" aria-label="Circuit Studio, back to the graph"
|
|
17
|
+
><span class="wordmark">Circuit</span><span class="product">Studio</span></a
|
|
18
|
+
>
|
|
19
|
+
<nav id="views" aria-label="Views">
|
|
20
|
+
<button data-view="graph">Graph</button>
|
|
21
|
+
<button data-view="devices">Devices</button>
|
|
22
|
+
<button data-view="vlans">VLANs</button>
|
|
23
|
+
<button data-view="addresses">Addresses</button>
|
|
24
|
+
<button data-view="sessions">BGP</button>
|
|
25
|
+
<button data-view="cables">Cables</button>
|
|
26
|
+
<button data-view="tools">Tools</button>
|
|
27
|
+
<button data-view="compare">Compare</button>
|
|
28
|
+
<button data-view="problems">Problems<span id="problem-count" class="count"></span></button>
|
|
29
|
+
</nav>
|
|
30
|
+
<input id="search" type="search" placeholder="Search the config" aria-label="Search the config" />
|
|
31
|
+
<div class="status-rail" aria-label="Network status">
|
|
32
|
+
<span id="summary" class="summary"></span>
|
|
33
|
+
<span id="live" class="live">connecting</span>
|
|
34
|
+
</div>
|
|
35
|
+
</header>
|
|
36
|
+
|
|
37
|
+
<pre id="banner" class="banner" hidden></pre>
|
|
38
|
+
|
|
39
|
+
<main>
|
|
40
|
+
<section id="graph-view" class="view">
|
|
41
|
+
<div class="toolbar">
|
|
42
|
+
<nav id="layers" aria-label="Layers"></nav>
|
|
43
|
+
<div class="actions">
|
|
44
|
+
<button id="fit" title="Fit the drawing to the window">Fit</button>
|
|
45
|
+
<button id="lay-out" title="Forget where nodes were moved, and lay them out again">Lay out again</button>
|
|
46
|
+
<details class="menu">
|
|
47
|
+
<summary>Save image</summary>
|
|
48
|
+
<div class="menu-items">
|
|
49
|
+
<button id="save-svg" title="Save this layer as an SVG image">SVG</button>
|
|
50
|
+
<button id="save-png" title="Save this layer as a PNG image">PNG</button>
|
|
51
|
+
</div>
|
|
52
|
+
</details>
|
|
53
|
+
</div>
|
|
54
|
+
</div>
|
|
55
|
+
<div class="stage">
|
|
56
|
+
<svg id="canvas" class="canvas" role="img" aria-label="The network">
|
|
57
|
+
<g id="viewport">
|
|
58
|
+
<g id="edges"></g>
|
|
59
|
+
<g id="nodes"></g>
|
|
60
|
+
</g>
|
|
61
|
+
</svg>
|
|
62
|
+
<aside id="panel"></aside>
|
|
63
|
+
</div>
|
|
64
|
+
</section>
|
|
65
|
+
|
|
66
|
+
<section id="tables-view" class="view" hidden>
|
|
67
|
+
<div id="tables" class="tables"></div>
|
|
68
|
+
</section>
|
|
69
|
+
</main>
|
|
70
|
+
</body>
|
|
71
|
+
</html>
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
// Address arithmetic for the browser, for both families, as src/core/addr.ts does it for Circuit: addresses as numbers, so IPv4 and IPv6 share one path.
|
|
3
|
+
|
|
4
|
+
/** @typedef {"ipv4" | "ipv6"} Family */
|
|
5
|
+
/** @typedef {{ family: Family, value: bigint }} Address */
|
|
6
|
+
/** @typedef {{ family: Family, first: bigint, last: bigint, length: number }} Range */
|
|
7
|
+
|
|
8
|
+
/** @param {Family} family */
|
|
9
|
+
const bitsOf = (family) => (family === "ipv4" ? 32 : 128);
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* An address as a number, or undefined when the text is not one.
|
|
13
|
+
*
|
|
14
|
+
* @param {string} text
|
|
15
|
+
* @returns {Address | undefined}
|
|
16
|
+
*/
|
|
17
|
+
export function parseAddress(text) {
|
|
18
|
+
if (!text.includes(":")) {
|
|
19
|
+
const octets = text.split(".");
|
|
20
|
+
if (octets.length !== 4 || !octets.every((octet) => /^\d{1,3}$/.test(octet) && Number(octet) <= 255)) return undefined;
|
|
21
|
+
return { family: "ipv4", value: octets.reduce((value, octet) => (value << 8n) | BigInt(octet), 0n) };
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const [before, after, extra] = text.split("::");
|
|
25
|
+
if (extra !== undefined || before === undefined) return undefined;
|
|
26
|
+
|
|
27
|
+
/** @param {string | undefined} part */
|
|
28
|
+
const groupsOf = (part) => (part ? part.split(":") : []);
|
|
29
|
+
const leading = groupsOf(before);
|
|
30
|
+
const trailing = groupsOf(after);
|
|
31
|
+
|
|
32
|
+
// `::` stands for as many zero groups as make eight.
|
|
33
|
+
const zeros = after === undefined ? 0 : 8 - leading.length - trailing.length;
|
|
34
|
+
if (zeros < 0) return undefined;
|
|
35
|
+
const groups = [...leading, ...Array(zeros).fill("0"), ...trailing];
|
|
36
|
+
if (groups.length !== 8 || !groups.every((group) => /^[0-9a-fA-F]{1,4}$/.test(group))) return undefined;
|
|
37
|
+
|
|
38
|
+
return { family: "ipv6", value: groups.reduce((value, group) => (value << 16n) | BigInt(parseInt(group, 16)), 0n) };
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* A prefix, or a lone address as the prefix of just itself, as the range of numbers it covers. Undefined when the text is neither.
|
|
43
|
+
*
|
|
44
|
+
* @param {string} text
|
|
45
|
+
* @returns {Range | undefined}
|
|
46
|
+
*/
|
|
47
|
+
export function parseRange(text) {
|
|
48
|
+
const [addressText, lengthText] = text.split("/");
|
|
49
|
+
const address = parseAddress(addressText ?? "");
|
|
50
|
+
if (!address) return undefined;
|
|
51
|
+
|
|
52
|
+
const bits = bitsOf(address.family);
|
|
53
|
+
const length = lengthText === undefined ? bits : Number(lengthText);
|
|
54
|
+
if (!Number.isInteger(length) || length < 0 || length > bits) return undefined;
|
|
55
|
+
|
|
56
|
+
const hostBits = (1n << BigInt(bits - length)) - 1n;
|
|
57
|
+
const first = address.value & ~hostBits & ((1n << BigInt(bits)) - 1n);
|
|
58
|
+
return { family: address.family, first, last: first | hostBits, length };
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Whether a prefix, or an address, holds an address or a whole other prefix.
|
|
63
|
+
*
|
|
64
|
+
* @param {string} outer
|
|
65
|
+
* @param {string} inner
|
|
66
|
+
*/
|
|
67
|
+
export function covers(outer, inner) {
|
|
68
|
+
const a = parseRange(outer);
|
|
69
|
+
const b = parseRange(inner);
|
|
70
|
+
return Boolean(a && b && a.family === b.family && a.first <= b.first && b.last <= a.last);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* The same prefix, however it is written: same family, same length, same network.
|
|
75
|
+
*
|
|
76
|
+
* @param {string} a
|
|
77
|
+
* @param {string} b
|
|
78
|
+
*/
|
|
79
|
+
export function samePrefix(a, b) {
|
|
80
|
+
const x = parseRange(a);
|
|
81
|
+
const y = parseRange(b);
|
|
82
|
+
return Boolean(x && y && x.family === y.family && x.length === y.length && x.first === y.first);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* The family of an address or prefix, or undefined when it is not one.
|
|
87
|
+
*
|
|
88
|
+
* @param {string} text
|
|
89
|
+
*/
|
|
90
|
+
export const familyOf = (text) => parseRange(text)?.family;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* A number back to the address it stands for, with IPv6 written short as RFC 5952 asks.
|
|
94
|
+
*
|
|
95
|
+
* @param {bigint} value
|
|
96
|
+
* @param {Family} family
|
|
97
|
+
*/
|
|
98
|
+
export function formatAddress(value, family) {
|
|
99
|
+
if (family === "ipv4") return [24n, 16n, 8n, 0n].map((shift) => String((value >> shift) & 255n)).join(".");
|
|
100
|
+
|
|
101
|
+
const groups = Array.from({ length: 8 }, (_, index) => ((value >> BigInt(112 - index * 16)) & 0xffffn).toString(16));
|
|
102
|
+
|
|
103
|
+
// The longest run of two or more zero groups becomes `::`.
|
|
104
|
+
let start = -1;
|
|
105
|
+
let length = 0;
|
|
106
|
+
for (let at = 0; at < 8;) {
|
|
107
|
+
let end = at;
|
|
108
|
+
while (end < 8 && groups[end] === "0") end++;
|
|
109
|
+
if (end - at > length && end - at > 1) {
|
|
110
|
+
start = at;
|
|
111
|
+
length = end - at;
|
|
112
|
+
}
|
|
113
|
+
at = end === at ? at + 1 : end;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (start < 0) return groups.join(":");
|
|
117
|
+
return `${groups.slice(0, start).join(":")}::${groups.slice(start + length).join(":")}`;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* The network a prefix or interface address is in, such as `10.0.0.0/24` for `10.0.0.1/24`.
|
|
122
|
+
*
|
|
123
|
+
* @param {string} text
|
|
124
|
+
*/
|
|
125
|
+
export function networkOf(text) {
|
|
126
|
+
const range = parseRange(text);
|
|
127
|
+
return range ? `${formatAddress(range.first, range.family)}/${range.length}` : text;
|
|
128
|
+
}
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
Copyright 2023 The Special Gothic Project Authors (https://github.com/AlistairMcCready/Special-Gothic/)
|
|
2
|
+
|
|
3
|
+
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
|
4
|
+
This license is copied below, and is also available with a FAQ at:
|
|
5
|
+
https://openfontlicense.org
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
-----------------------------------------------------------
|
|
9
|
+
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
|
10
|
+
-----------------------------------------------------------
|
|
11
|
+
|
|
12
|
+
PREAMBLE
|
|
13
|
+
The goals of the Open Font License (OFL) are to stimulate worldwide
|
|
14
|
+
development of collaborative font projects, to support the font creation
|
|
15
|
+
efforts of academic and linguistic communities, and to provide a free and
|
|
16
|
+
open framework in which fonts may be shared and improved in partnership
|
|
17
|
+
with others.
|
|
18
|
+
|
|
19
|
+
The OFL allows the licensed fonts to be used, studied, modified and
|
|
20
|
+
redistributed freely as long as they are not sold by themselves. The
|
|
21
|
+
fonts, including any derivative works, can be bundled, embedded,
|
|
22
|
+
redistributed and/or sold with any software provided that any reserved
|
|
23
|
+
names are not used by derivative works. The fonts and derivatives,
|
|
24
|
+
however, cannot be released under any other type of license. The
|
|
25
|
+
requirement for fonts to remain under this license does not apply
|
|
26
|
+
to any document created using the fonts or their derivatives.
|
|
27
|
+
|
|
28
|
+
DEFINITIONS
|
|
29
|
+
"Font Software" refers to the set of files released by the Copyright
|
|
30
|
+
Holder(s) under this license and clearly marked as such. This may
|
|
31
|
+
include source files, build scripts and documentation.
|
|
32
|
+
|
|
33
|
+
"Reserved Font Name" refers to any names specified as such after the
|
|
34
|
+
copyright statement(s).
|
|
35
|
+
|
|
36
|
+
"Original Version" refers to the collection of Font Software components as
|
|
37
|
+
distributed by the Copyright Holder(s).
|
|
38
|
+
|
|
39
|
+
"Modified Version" refers to any derivative made by adding to, deleting,
|
|
40
|
+
or substituting -- in part or in whole -- any of the components of the
|
|
41
|
+
Original Version, by changing formats or by porting the Font Software to a
|
|
42
|
+
new environment.
|
|
43
|
+
|
|
44
|
+
"Author" refers to any designer, engineer, programmer, technical
|
|
45
|
+
writer or other person who contributed to the Font Software.
|
|
46
|
+
|
|
47
|
+
PERMISSION & CONDITIONS
|
|
48
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
49
|
+
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
|
50
|
+
redistribute, and sell modified and unmodified copies of the Font
|
|
51
|
+
Software, subject to the following conditions:
|
|
52
|
+
|
|
53
|
+
1) Neither the Font Software nor any of its individual components,
|
|
54
|
+
in Original or Modified Versions, may be sold by itself.
|
|
55
|
+
|
|
56
|
+
2) Original or Modified Versions of the Font Software may be bundled,
|
|
57
|
+
redistributed and/or sold with any software, provided that each copy
|
|
58
|
+
contains the above copyright notice and this license. These can be
|
|
59
|
+
included either as stand-alone text files, human-readable headers or
|
|
60
|
+
in the appropriate machine-readable metadata fields within text or
|
|
61
|
+
binary files as long as those fields can be easily viewed by the user.
|
|
62
|
+
|
|
63
|
+
3) No Modified Version of the Font Software may use the Reserved Font
|
|
64
|
+
Name(s) unless explicit written permission is granted by the corresponding
|
|
65
|
+
Copyright Holder. This restriction only applies to the primary font name as
|
|
66
|
+
presented to the users.
|
|
67
|
+
|
|
68
|
+
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
|
69
|
+
Software shall not be used to promote, endorse or advertise any
|
|
70
|
+
Modified Version, except to acknowledge the contribution(s) of the
|
|
71
|
+
Copyright Holder(s) and the Author(s) or with their explicit written
|
|
72
|
+
permission.
|
|
73
|
+
|
|
74
|
+
5) The Font Software, modified or unmodified, in part or in whole,
|
|
75
|
+
must be distributed entirely under this license, and must not be
|
|
76
|
+
distributed under any other license. The requirement for fonts to
|
|
77
|
+
remain under this license does not apply to any document created
|
|
78
|
+
using the Font Software.
|
|
79
|
+
|
|
80
|
+
TERMINATION
|
|
81
|
+
This license becomes null and void if any of the above conditions are
|
|
82
|
+
not met.
|
|
83
|
+
|
|
84
|
+
DISCLAIMER
|
|
85
|
+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
86
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
|
87
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
|
88
|
+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
|
89
|
+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
90
|
+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
|
91
|
+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
92
|
+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
|
93
|
+
OTHER DEALINGS IN THE FONT SOFTWARE.
|