@isothrum/editor 0.0.0-stage → 0.1.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/LICENSE +202 -0
- package/NOTICE +8 -0
- package/PUBLISHING.md +93 -0
- package/README.md +106 -2
- package/desktop-editor/editor.css +11 -0
- package/desktop-editor/index.html +14 -0
- package/desktop-editor/main.tsx +26 -0
- package/dist/desktop/editor.css +1 -0
- package/dist/desktop/editor.js +181 -0
- package/dist/desktop/fonts/geist-cyrillic-ext-wght-normal-RO72NYA2.woff2 +0 -0
- package/dist/desktop/fonts/geist-cyrillic-wght-normal-CK2XY27K.woff2 +0 -0
- package/dist/desktop/fonts/geist-latin-ext-wght-normal-XEQ56JUF.woff2 +0 -0
- package/dist/desktop/fonts/geist-latin-wght-normal-T72VVCUW.woff2 +0 -0
- package/dist/desktop/fonts/geist-mono-cyrillic-ext-wght-normal-QXKVIKFD.woff2 +0 -0
- package/dist/desktop/fonts/geist-mono-cyrillic-wght-normal-GOIAQAGU.woff2 +0 -0
- package/dist/desktop/fonts/geist-mono-latin-ext-wght-normal-HU3ZAWN6.woff2 +0 -0
- package/dist/desktop/fonts/geist-mono-latin-wght-normal-CJNQKXUG.woff2 +0 -0
- package/dist/desktop/fonts/geist-mono-symbols2-wght-normal-WZJJVLQO.woff2 +0 -0
- package/dist/desktop/fonts/geist-mono-vietnamese-wght-normal-KW5NM6YV.woff2 +0 -0
- package/dist/desktop/fonts/geist-vietnamese-wght-normal-Y2R7JZKV.woff2 +0 -0
- package/dist/desktop/fonts/shantell-sans-cyrillic-ext-wght-normal-ILPQWRJJ.woff2 +0 -0
- package/dist/desktop/fonts/shantell-sans-cyrillic-wght-normal-RKC6NDPM.woff2 +0 -0
- package/dist/desktop/fonts/shantell-sans-latin-ext-wght-normal-SNKHG3LM.woff2 +0 -0
- package/dist/desktop/fonts/shantell-sans-latin-wght-normal-7CHHGC3N.woff2 +0 -0
- package/dist/desktop/fonts/shantell-sans-vietnamese-wght-normal-IPFAQSBA.woff2 +0 -0
- package/dist/desktop/index.html +14 -0
- package/dist/desktop/styles.css +2 -0
- package/dist/desktop/wasm/isothrum_wasm.d.ts +60 -0
- package/dist/desktop/wasm/isothrum_wasm.js +312 -0
- package/dist/desktop/wasm/isothrum_wasm_bg.wasm +0 -0
- package/dist/index.js +7059 -0
- package/dist/index.js.map +7 -0
- package/dist/model.js +745 -0
- package/dist/model.js.map +7 -0
- package/dist/types/components/tool/canvas/cable-edge.d.ts +4 -0
- package/dist/types/components/tool/canvas/contexts.d.ts +12 -0
- package/dist/types/components/tool/canvas/device-icon.d.ts +17 -0
- package/dist/types/components/tool/canvas/inline-text.d.ts +15 -0
- package/dist/types/components/tool/canvas/lan-node.d.ts +8 -0
- package/dist/types/components/tool/canvas/machine-addresses.d.ts +14 -0
- package/dist/types/components/tool/canvas/machine-node.d.ts +4 -0
- package/dist/types/components/tool/canvas/note-node.d.ts +7 -0
- package/dist/types/components/tool/canvas/port-led.d.ts +10 -0
- package/dist/types/components/tool/canvas/router-node.d.ts +8 -0
- package/dist/types/components/tool/canvas/sketch.d.ts +50 -0
- package/dist/types/components/tool/canvas/status-dot.d.ts +5 -0
- package/dist/types/components/tool/canvas/switch-node.d.ts +8 -0
- package/dist/types/components/tool/canvas/use-measured-ports.d.ts +7 -0
- package/dist/types/components/tool/context-menus.d.ts +5 -0
- package/dist/types/components/tool/device-block.d.ts +12 -0
- package/dist/types/components/tool/editor-menu.d.ts +28 -0
- package/dist/types/components/tool/export/copy-button.d.ts +9 -0
- package/dist/types/components/tool/export/export-panel.d.ts +17 -0
- package/dist/types/components/tool/export/target-list.d.ts +15 -0
- package/dist/types/components/tool/floating-window.d.ts +13 -0
- package/dist/types/components/tool/flow-canvas.d.ts +6 -0
- package/dist/types/components/tool/hooks/use-cabling.d.ts +23 -0
- package/dist/types/components/tool/hooks/use-captures.d.ts +9 -0
- package/dist/types/components/tool/hooks/use-clipboard.d.ts +12 -0
- package/dist/types/components/tool/hooks/use-context-menus.d.ts +25 -0
- package/dist/types/components/tool/hooks/use-design.d.ts +10 -0
- package/dist/types/components/tool/hooks/use-desktop.d.ts +50 -0
- package/dist/types/components/tool/hooks/use-devices.d.ts +17 -0
- package/dist/types/components/tool/hooks/use-downloads.d.ts +9 -0
- package/dist/types/components/tool/hooks/use-editor.d.ts +609 -0
- package/dist/types/components/tool/hooks/use-engine.d.ts +9 -0
- package/dist/types/components/tool/hooks/use-history.d.ts +9 -0
- package/dist/types/components/tool/hooks/use-lab-actions.d.ts +25 -0
- package/dist/types/components/tool/hooks/use-lab-run.d.ts +25 -0
- package/dist/types/components/tool/hooks/use-lab.d.ts +18 -0
- package/dist/types/components/tool/hooks/use-lan-carry.d.ts +8 -0
- package/dist/types/components/tool/hooks/use-machine-actions.d.ts +26 -0
- package/dist/types/components/tool/hooks/use-placement.d.ts +27 -0
- package/dist/types/components/tool/hooks/use-project.d.ts +25 -0
- package/dist/types/components/tool/hooks/use-projects.d.ts +34 -0
- package/dist/types/components/tool/hooks/use-shared-link.d.ts +23 -0
- package/dist/types/components/tool/hooks/use-toast.d.ts +2 -0
- package/dist/types/components/tool/hooks/use-tools.d.ts +17 -0
- package/dist/types/components/tool/lab-canvas.d.ts +18 -0
- package/dist/types/components/tool/overlays.d.ts +5 -0
- package/dist/types/components/tool/projects-list.d.ts +9 -0
- package/dist/types/components/tool/text.d.ts +418 -0
- package/dist/types/components/tool/toolbar.d.ts +5 -0
- package/dist/types/components/tool/top-bars.d.ts +10 -0
- package/dist/types/components/tool/windows/conditions-fields.d.ts +6 -0
- package/dist/types/components/tool/windows/editor-windows.d.ts +5 -0
- package/dist/types/components/tool/windows/fields.d.ts +4 -0
- package/dist/types/components/tool/windows/lab-status.d.ts +6 -0
- package/dist/types/components/tool/windows/lab-windows.d.ts +13 -0
- package/dist/types/components/tool/windows/link-controls.d.ts +21 -0
- package/dist/types/components/tool/windows/machine-controls.d.ts +16 -0
- package/dist/types/components/tool/windows/machine-inspector.d.ts +11 -0
- package/dist/types/components/tool/windows/runs-fields.d.ts +18 -0
- package/dist/types/components/tool/windows/selected-windows.d.ts +21 -0
- package/dist/types/components/ui/button.d.ts +8 -0
- package/dist/types/components/ui/dropdown-menu.d.ts +21 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/lib/auth.d.ts +38 -0
- package/dist/types/lib/brand.d.ts +19 -0
- package/dist/types/lib/i18n.d.ts +19 -0
- package/dist/types/lib/tool/blocks.d.ts +35 -0
- package/dist/types/lib/tool/cables.d.ts +48 -0
- package/dist/types/lib/tool/clone.d.ts +12 -0
- package/dist/types/lib/tool/conditions.d.ts +31 -0
- package/dist/types/lib/tool/create.d.ts +22 -0
- package/dist/types/lib/tool/desktop.d.ts +63 -0
- package/dist/types/lib/tool/draft.d.ts +20 -0
- package/dist/types/lib/tool/engine.d.ts +33 -0
- package/dist/types/lib/tool/examples.d.ts +11 -0
- package/dist/types/lib/tool/export-targets.d.ts +21 -0
- package/dist/types/lib/tool/facing.d.ts +9 -0
- package/dist/types/lib/tool/geometry.d.ts +36 -0
- package/dist/types/lib/tool/gns3-cables.d.ts +17 -0
- package/dist/types/lib/tool/gns3-import.d.ts +15 -0
- package/dist/types/lib/tool/gns3-parts.d.ts +25 -0
- package/dist/types/lib/tool/issues.d.ts +12 -0
- package/dist/types/lib/tool/layout.d.ts +52 -0
- package/dist/types/lib/tool/live.d.ts +21 -0
- package/dist/types/lib/tool/logos.d.ts +7 -0
- package/dist/types/lib/tool/model.d.ts +173 -0
- package/dist/types/lib/tool/os.d.ts +20 -0
- package/dist/types/lib/tool/pins.d.ts +5 -0
- package/dist/types/lib/tool/placement.d.ts +21 -0
- package/dist/types/lib/tool/ports.d.ts +21 -0
- package/dist/types/lib/tool/presets.d.ts +21 -0
- package/dist/types/lib/tool/projects-api.d.ts +37 -0
- package/dist/types/lib/tool/router-ports.d.ts +22 -0
- package/dist/types/lib/tool/selection.d.ts +19 -0
- package/dist/types/lib/tool/storage.d.ts +25 -0
- package/dist/types/lib/tool/switch-edit.d.ts +17 -0
- package/dist/types/lib/tool/text/de.d.ts +2 -0
- package/dist/types/lib/tool/text/en.d.ts +429 -0
- package/dist/types/lib/tool/text/es.d.ts +2 -0
- package/dist/types/lib/tool/text/fr.d.ts +2 -0
- package/dist/types/lib/tool/text/index.d.ts +419 -0
- package/dist/types/lib/tool/topology.d.ts +2 -0
- package/dist/types/lib/tool/vlans.d.ts +24 -0
- package/dist/types/lib/utils.d.ts +2 -0
- package/dist/types/model.d.ts +13 -0
- package/package.json +88 -4
- package/scripts/build-desktop-editor.mjs +43 -0
- package/scripts/build-lib.mjs +38 -0
- package/src/components/tool/canvas/cable-edge.tsx +112 -0
- package/src/components/tool/canvas/contexts.ts +18 -0
- package/src/components/tool/canvas/device-icon.tsx +105 -0
- package/src/components/tool/canvas/inline-text.tsx +69 -0
- package/src/components/tool/canvas/lan-node.tsx +148 -0
- package/src/components/tool/canvas/machine-addresses.tsx +117 -0
- package/src/components/tool/canvas/machine-node.tsx +114 -0
- package/src/components/tool/canvas/note-node.tsx +109 -0
- package/src/components/tool/canvas/port-led.tsx +21 -0
- package/src/components/tool/canvas/router-node.tsx +114 -0
- package/src/components/tool/canvas/sketch.tsx +130 -0
- package/src/components/tool/canvas/status-dot.tsx +29 -0
- package/src/components/tool/canvas/switch-node.tsx +143 -0
- package/src/components/tool/canvas/use-measured-ports.ts +25 -0
- package/src/components/tool/context-menus.tsx +142 -0
- package/src/components/tool/device-block.tsx +107 -0
- package/src/components/tool/editor-menu.tsx +191 -0
- package/src/components/tool/export/copy-button.tsx +45 -0
- package/src/components/tool/export/export-panel.tsx +127 -0
- package/src/components/tool/export/target-list.tsx +87 -0
- package/src/components/tool/floating-window.tsx +69 -0
- package/src/components/tool/flow-canvas.tsx +138 -0
- package/src/components/tool/hooks/use-cabling.ts +66 -0
- package/src/components/tool/hooks/use-captures.ts +24 -0
- package/src/components/tool/hooks/use-clipboard.ts +54 -0
- package/src/components/tool/hooks/use-context-menus.ts +37 -0
- package/src/components/tool/hooks/use-design.ts +24 -0
- package/src/components/tool/hooks/use-desktop.ts +100 -0
- package/src/components/tool/hooks/use-devices.ts +58 -0
- package/src/components/tool/hooks/use-downloads.ts +42 -0
- package/src/components/tool/hooks/use-editor.ts +114 -0
- package/src/components/tool/hooks/use-engine.ts +29 -0
- package/src/components/tool/hooks/use-history.ts +107 -0
- package/src/components/tool/hooks/use-lab-actions.ts +57 -0
- package/src/components/tool/hooks/use-lab-run.ts +61 -0
- package/src/components/tool/hooks/use-lab.ts +32 -0
- package/src/components/tool/hooks/use-lan-carry.ts +43 -0
- package/src/components/tool/hooks/use-machine-actions.ts +57 -0
- package/src/components/tool/hooks/use-placement.ts +80 -0
- package/src/components/tool/hooks/use-project.ts +112 -0
- package/src/components/tool/hooks/use-projects.ts +85 -0
- package/src/components/tool/hooks/use-shared-link.ts +64 -0
- package/src/components/tool/hooks/use-toast.ts +16 -0
- package/src/components/tool/hooks/use-tools.ts +60 -0
- package/src/components/tool/lab-canvas.tsx +96 -0
- package/src/components/tool/overlays.tsx +104 -0
- package/src/components/tool/projects-list.tsx +96 -0
- package/src/components/tool/text.ts +9 -0
- package/src/components/tool/toolbar.tsx +106 -0
- package/src/components/tool/top-bars.tsx +90 -0
- package/src/components/tool/windows/conditions-fields.tsx +43 -0
- package/src/components/tool/windows/editor-windows.tsx +73 -0
- package/src/components/tool/windows/fields.ts +6 -0
- package/src/components/tool/windows/lab-status.tsx +68 -0
- package/src/components/tool/windows/lab-windows.tsx +130 -0
- package/src/components/tool/windows/link-controls.tsx +69 -0
- package/src/components/tool/windows/machine-controls.tsx +116 -0
- package/src/components/tool/windows/machine-inspector.tsx +83 -0
- package/src/components/tool/windows/runs-fields.tsx +127 -0
- package/src/components/tool/windows/selected-windows.tsx +147 -0
- package/src/components/ui/button.tsx +59 -0
- package/src/components/ui/dropdown-menu.tsx +185 -0
- package/src/index.ts +21 -0
- package/src/lib/auth.tsx +43 -0
- package/src/lib/brand.tsx +46 -0
- package/src/lib/i18n.ts +53 -0
- package/src/lib/tool/blocks.test.ts +64 -0
- package/src/lib/tool/blocks.ts +78 -0
- package/src/lib/tool/cable-wiring.test.ts +74 -0
- package/src/lib/tool/cables.test.ts +75 -0
- package/src/lib/tool/cables.ts +215 -0
- package/src/lib/tool/clone.test.ts +54 -0
- package/src/lib/tool/clone.ts +48 -0
- package/src/lib/tool/conditions.test.ts +170 -0
- package/src/lib/tool/conditions.ts +132 -0
- package/src/lib/tool/create.test.ts +67 -0
- package/src/lib/tool/create.ts +83 -0
- package/src/lib/tool/desktop.test.ts +59 -0
- package/src/lib/tool/desktop.ts +99 -0
- package/src/lib/tool/draft.test.ts +150 -0
- package/src/lib/tool/draft.ts +109 -0
- package/src/lib/tool/engine.test.ts +39 -0
- package/src/lib/tool/engine.ts +58 -0
- package/src/lib/tool/examples.test.ts +35 -0
- package/src/lib/tool/examples.ts +71 -0
- package/src/lib/tool/export-targets.test.ts +47 -0
- package/src/lib/tool/export-targets.ts +84 -0
- package/src/lib/tool/facing.test.ts +72 -0
- package/src/lib/tool/facing.ts +100 -0
- package/src/lib/tool/geometry.test.ts +80 -0
- package/src/lib/tool/geometry.ts +109 -0
- package/src/lib/tool/gns3-cables.test.ts +47 -0
- package/src/lib/tool/gns3-cables.ts +81 -0
- package/src/lib/tool/gns3-import.test.ts +102 -0
- package/src/lib/tool/gns3-import.ts +198 -0
- package/src/lib/tool/gns3-layout.test.ts +62 -0
- package/src/lib/tool/gns3-parts.test.ts +47 -0
- package/src/lib/tool/gns3-parts.ts +68 -0
- package/src/lib/tool/issues.test.ts +35 -0
- package/src/lib/tool/issues.ts +60 -0
- package/src/lib/tool/layout.test.ts +128 -0
- package/src/lib/tool/layout.ts +229 -0
- package/src/lib/tool/live.test.ts +46 -0
- package/src/lib/tool/live.ts +49 -0
- package/src/lib/tool/logos.test.ts +30 -0
- package/src/lib/tool/logos.ts +99 -0
- package/src/lib/tool/model.test.ts +128 -0
- package/src/lib/tool/model.ts +238 -0
- package/src/lib/tool/os.test.ts +45 -0
- package/src/lib/tool/os.ts +57 -0
- package/src/lib/tool/parity.test.ts +145 -0
- package/src/lib/tool/pins.test.ts +24 -0
- package/src/lib/tool/pins.ts +11 -0
- package/src/lib/tool/placement.test.ts +79 -0
- package/src/lib/tool/placement.ts +60 -0
- package/src/lib/tool/ports.test.ts +39 -0
- package/src/lib/tool/ports.ts +48 -0
- package/src/lib/tool/presets.test.ts +50 -0
- package/src/lib/tool/presets.ts +77 -0
- package/src/lib/tool/projects-api.test.ts +59 -0
- package/src/lib/tool/projects-api.ts +47 -0
- package/src/lib/tool/router-ports.test.ts +63 -0
- package/src/lib/tool/router-ports.ts +88 -0
- package/src/lib/tool/selection.test.ts +44 -0
- package/src/lib/tool/selection.ts +34 -0
- package/src/lib/tool/storage.test.ts +123 -0
- package/src/lib/tool/storage.ts +127 -0
- package/src/lib/tool/switch-edit.test.ts +49 -0
- package/src/lib/tool/switch-edit.ts +38 -0
- package/src/lib/tool/text/de.ts +358 -0
- package/src/lib/tool/text/en.ts +371 -0
- package/src/lib/tool/text/es.ts +358 -0
- package/src/lib/tool/text/fr.ts +358 -0
- package/src/lib/tool/text/index.ts +21 -0
- package/src/lib/tool/text/text.test.ts +33 -0
- package/src/lib/tool/topology.test.ts +108 -0
- package/src/lib/tool/topology.ts +116 -0
- package/src/lib/tool/vlans.test.ts +64 -0
- package/src/lib/tool/vlans.ts +79 -0
- package/src/lib/utils.ts +6 -0
- package/src/model.ts +13 -0
- package/src/test/arbitrary.ts +41 -0
- package/src/test/engine.ts +48 -0
- package/src/test/lab.ts +101 -0
- package/styles/globals.css +258 -0
- package/styles/theme.css +192 -0
- package/tsconfig.build.json +12 -0
- package/tsconfig.json +22 -0
- package/wasm/isothrum_wasm.d.ts +60 -0
- package/wasm/isothrum_wasm.js +312 -0
- package/wasm/isothrum_wasm_bg.wasm +0 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { NoteShape } from "./model";
|
|
2
|
+
/** Pieces of a GNS3 import that read one thing: an OS from an image name, a note from a drawing. */
|
|
3
|
+
/** The editor's words for what a GNS3 import can't carry over (see the editor's text). */
|
|
4
|
+
export interface Gns3Text {
|
|
5
|
+
notGns3: string;
|
|
6
|
+
noTopology: string;
|
|
7
|
+
cisco: (node: string, kind: string) => string;
|
|
8
|
+
firewall: (node: string) => string;
|
|
9
|
+
noEquivalent: (node: string, type: string) => string;
|
|
10
|
+
noNodes: string;
|
|
11
|
+
}
|
|
12
|
+
export interface G3Drawing {
|
|
13
|
+
x?: number;
|
|
14
|
+
y?: number;
|
|
15
|
+
svg?: string;
|
|
16
|
+
}
|
|
17
|
+
/** The Isoloom OS a VM's image or name suggests (Debian 12 when nothing does). */
|
|
18
|
+
export declare function guessOs(text: string): string;
|
|
19
|
+
/** The text of an SVG drawing, and its shape and size (scaled by `scale`). */
|
|
20
|
+
export declare function drawingNote(d: G3Drawing, scale: number): {
|
|
21
|
+
text: string;
|
|
22
|
+
shape: NoteShape;
|
|
23
|
+
w: number;
|
|
24
|
+
h: number;
|
|
25
|
+
} | null;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type LabNode } from "./model";
|
|
2
|
+
/** The editor's words for what the canvas finds wrong (see the editor's text). */
|
|
3
|
+
export interface IssueText {
|
|
4
|
+
vlanBlocks: (vlan: string, block: string, other: string, sw: string) => string;
|
|
5
|
+
areaBlock: (lan: string, block: string, switches: string) => string;
|
|
6
|
+
noName: Record<"machine" | "lan" | "switch", string>;
|
|
7
|
+
sameName: Record<"machine" | "lan" | "switch", (name: string) => string>;
|
|
8
|
+
/** A ports field entry Isoloom couldn't take: the machine and the entry. */
|
|
9
|
+
badPort: (machine: string, entry: string) => string;
|
|
10
|
+
}
|
|
11
|
+
/** What the canvas can tell before the engine runs: names Isoloom would reject or merge, ports it couldn't take. */
|
|
12
|
+
export declare function canvasIssues(nodes: LabNode[], text: IssueText): string[];
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A lab given as the engine's topology (what an assistant writes through the MCP server), laid
|
|
3
|
+
* out on the canvas: LANs side by side with their machines in a grid inside, automatic routers
|
|
4
|
+
* under the LANs they join (cabled to each), the machines on no LAN in a row below, and the
|
|
5
|
+
* cables between machines. The inverse of `toTopology`, for labs nobody drew.
|
|
6
|
+
*/
|
|
7
|
+
import { type Tc } from "./conditions";
|
|
8
|
+
import { type Service } from "./ports";
|
|
9
|
+
import { type Draft } from "./model";
|
|
10
|
+
type TopologyNode = {
|
|
11
|
+
kind: {
|
|
12
|
+
container?: {
|
|
13
|
+
image: string;
|
|
14
|
+
idle?: boolean;
|
|
15
|
+
};
|
|
16
|
+
vm?: {
|
|
17
|
+
os: string;
|
|
18
|
+
provision?: string[];
|
|
19
|
+
};
|
|
20
|
+
router?: object;
|
|
21
|
+
};
|
|
22
|
+
access?: boolean;
|
|
23
|
+
services?: Service[];
|
|
24
|
+
networks?: Record<string, number | null>;
|
|
25
|
+
};
|
|
26
|
+
export interface Topology {
|
|
27
|
+
name: string;
|
|
28
|
+
nodes: Record<string, TopologyNode>;
|
|
29
|
+
networks?: Record<string, {
|
|
30
|
+
cidr: string;
|
|
31
|
+
internet?: boolean;
|
|
32
|
+
tc?: Tc;
|
|
33
|
+
}>;
|
|
34
|
+
links?: {
|
|
35
|
+
a: {
|
|
36
|
+
node: string;
|
|
37
|
+
port: string;
|
|
38
|
+
};
|
|
39
|
+
b: {
|
|
40
|
+
node: string;
|
|
41
|
+
port: string;
|
|
42
|
+
};
|
|
43
|
+
tc?: Tc;
|
|
44
|
+
}[];
|
|
45
|
+
}
|
|
46
|
+
/** A topology laid out: the draft, and each value in the topology the drawing leaves out. */
|
|
47
|
+
export interface LaidOut {
|
|
48
|
+
draft: Draft;
|
|
49
|
+
problems: string[];
|
|
50
|
+
}
|
|
51
|
+
export declare function draftFromTopology(topo: Topology): LaidOut;
|
|
52
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type LabLive, type Status, type SuspendedLink } from "./desktop";
|
|
2
|
+
import type { CableEdge, LabNode } from "./model";
|
|
3
|
+
/**
|
|
4
|
+
* The running lab as the canvas shows it (desktop app; null: not running, or in a browser).
|
|
5
|
+
* Machines by name; ports by `machine/network` (up, down, or null: unknown); cables by edge id;
|
|
6
|
+
* LANs by name, with how many of their ports are up.
|
|
7
|
+
*/
|
|
8
|
+
export type CableStatus = "up" | "cut" | "down" | "unknown";
|
|
9
|
+
export interface LiveView {
|
|
10
|
+
machines: Partial<Record<string, {
|
|
11
|
+
status: Status;
|
|
12
|
+
detail: string;
|
|
13
|
+
}>>;
|
|
14
|
+
ports: Partial<Record<string, boolean | null>>;
|
|
15
|
+
cables: Partial<Record<string, CableStatus>>;
|
|
16
|
+
lans: Partial<Record<string, {
|
|
17
|
+
up: number;
|
|
18
|
+
total: number;
|
|
19
|
+
}>>;
|
|
20
|
+
}
|
|
21
|
+
export declare function liveViewOf(live: LabLive, links: SuspendedLink[], nodes: LabNode[], edges: CableEdge[]): LiveView;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type SimpleIcon } from "simple-icons";
|
|
2
|
+
import { type MachineData } from "./model";
|
|
3
|
+
export declare function logoFor(m: Pick<MachineData, "kind" | "image" | "os">): SimpleIcon | null;
|
|
4
|
+
/** The fallback for a container whose image we don't know: Docker's whale. */
|
|
5
|
+
export declare const dockerLogo: SimpleIcon;
|
|
6
|
+
/** Brand colors too dark to read on a dark background (AlmaLinux and others use black). */
|
|
7
|
+
export declare function isDark(hex: string): boolean;
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import type { Edge, Node, XYPosition } from "@xyflow/react";
|
|
2
|
+
/**
|
|
3
|
+
* The lab as drawn on the canvas: machines, LANs, switches and notes are nodes, cables are edges
|
|
4
|
+
* between two ports. `toTopology` translates it into the topology JSON the engine reads
|
|
5
|
+
* (`isothrum_compiler::Topology`), which it compiles to Isoloom's isoloom.yml.
|
|
6
|
+
*/
|
|
7
|
+
export type IconId = "container" | "server" | "router" | "shield" | "monitor" | "laptop";
|
|
8
|
+
/** The Cisco OSes a container node can be (Isoloom's `app.appliance`). */
|
|
9
|
+
export type Appliance = "cisco-iol" | "cisco-iol-l2" | "cisco-vios" | "cisco-vios-l2" | "cisco-csr1000v" | "cisco-c8000v" | "cisco-dynamips";
|
|
10
|
+
/** Each Cisco OS: its usual vrnetlab image (none for Dynamips: Isoloom builds the emulator). */
|
|
11
|
+
export declare const APPLIANCES: {
|
|
12
|
+
id: Appliance;
|
|
13
|
+
label: string;
|
|
14
|
+
image: string;
|
|
15
|
+
switch?: boolean;
|
|
16
|
+
kvm?: boolean;
|
|
17
|
+
}[];
|
|
18
|
+
/** The OS's name for the `k`th data interface (from 1), as Isoloom numbers them. */
|
|
19
|
+
export declare function applianceInterface(kind: Appliance, k: number): string;
|
|
20
|
+
export type MachineData = {
|
|
21
|
+
name: string;
|
|
22
|
+
/** "router": an automatic router, not a machine (its networks reach each other). */
|
|
23
|
+
kind: "container" | "vm" | "router";
|
|
24
|
+
icon: IconId;
|
|
25
|
+
/** Container image (`kind: container`): Isoloom's `app.image`. */
|
|
26
|
+
image: string;
|
|
27
|
+
/** The OS, as Isoloom writes it (`debian@12`, see `OS_CHOICES`) (`kind: vm`): Isoloom's `os`. */
|
|
28
|
+
os: string;
|
|
29
|
+
/** Provisioning steps, one per line (`kind: vm`): Isoloom's `app.steps`. */
|
|
30
|
+
provision: string;
|
|
31
|
+
/** Service ports, comma-separated, each a port and what it speaks when it isn't TCP (`80, 53/udp`): see `readPorts`. */
|
|
32
|
+
ports: string;
|
|
33
|
+
/** The machine the user lands on. */
|
|
34
|
+
access: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* A container with no service of its own (a stock Linux image), kept running idle as a
|
|
37
|
+
* machine to work from. Unset: guessed from the image (see `idleByDefault`).
|
|
38
|
+
*/
|
|
39
|
+
idle?: boolean;
|
|
40
|
+
/** A network OS in its container, wired as its image expects (Cisco IOL, built with vrnetlab). */
|
|
41
|
+
appliance?: Appliance;
|
|
42
|
+
/** The appliance's own configuration (IOS commands), added to the one Isoloom generates. */
|
|
43
|
+
config?: string;
|
|
44
|
+
/** Addresses fixed by hand: LAN name -> last octet. Others take the next free one. */
|
|
45
|
+
pins?: Record<string, number>;
|
|
46
|
+
};
|
|
47
|
+
/** An image's name: its last path segment, without the tag, in lowercase. */
|
|
48
|
+
export declare function imageName(image: string): string;
|
|
49
|
+
export declare function idleByDefault(image: string): boolean;
|
|
50
|
+
/** How a cable or a LAN behaves, as a slow or lossy link: one-way delay and its jitter (ms),
|
|
51
|
+
* loss (%), bandwidth (Mbit/s). Isoloom applies it with `tc netem` (its `tc`). */
|
|
52
|
+
export type LinkConditions = {
|
|
53
|
+
delay?: number;
|
|
54
|
+
jitter?: number;
|
|
55
|
+
loss?: number;
|
|
56
|
+
rate?: number;
|
|
57
|
+
};
|
|
58
|
+
/** The two ends of a cable: `aPort` on the source machine, `bPort` on the target. */
|
|
59
|
+
export type CableData = {
|
|
60
|
+
aPort: string;
|
|
61
|
+
bPort: string;
|
|
62
|
+
/** How the cable behaves (between two machines; a cable to a LAN takes the LAN's). */
|
|
63
|
+
tc?: LinkConditions;
|
|
64
|
+
/** Drawing only, worked out from what the cable is plugged into (never saved). */
|
|
65
|
+
color?: string;
|
|
66
|
+
};
|
|
67
|
+
/** A LAN (or VLAN) drawn as an area: machines inside it are on it. */
|
|
68
|
+
export type LanData = {
|
|
69
|
+
name: string;
|
|
70
|
+
cidr: string;
|
|
71
|
+
internet: boolean;
|
|
72
|
+
/** How the LAN behaves (not on a switch's VLAN yet). */
|
|
73
|
+
tc?: LinkConditions;
|
|
74
|
+
/** Only its label is drawn: the LAN, its machines and their addresses are unchanged. */
|
|
75
|
+
hidden?: boolean;
|
|
76
|
+
};
|
|
77
|
+
/** A VLAN on a switch: `vlan<id>`, with its block. VLANs are lab-wide: `vlan10` is the same
|
|
78
|
+
* network on every switch, and a LAN area named `vlan10` is that VLAN too. */
|
|
79
|
+
type Vlan = {
|
|
80
|
+
id: number;
|
|
81
|
+
cidr: string;
|
|
82
|
+
};
|
|
83
|
+
/** A switch port: a VLAN (access), "trunk" (every VLAN of the switch), or nothing. */
|
|
84
|
+
export type PortMode = number | "trunk" | null;
|
|
85
|
+
/**
|
|
86
|
+
* A switch: access ports, each in a VLAN (or none), and one trunk port that carries every VLAN
|
|
87
|
+
* of the switch. Not a machine: it is the network fabric, so it never appears in isoloom.yml;
|
|
88
|
+
* its VLANs do, as networks, and a machine cabled to a port joins the port's VLAN.
|
|
89
|
+
*/
|
|
90
|
+
type SwitchData = {
|
|
91
|
+
name: string;
|
|
92
|
+
vlans: Vlan[];
|
|
93
|
+
ports: PortMode[];
|
|
94
|
+
};
|
|
95
|
+
/** A note on the canvas: text, a box or an ellipse. Drawing only: never in isoloom.yml. */
|
|
96
|
+
export type NoteShape = "text" | "rect" | "ellipse";
|
|
97
|
+
export declare const NOTE_COLORS: readonly ["yellow", "red", "blue", "green", "violet"];
|
|
98
|
+
type NoteData = {
|
|
99
|
+
text: string;
|
|
100
|
+
shape: NoteShape;
|
|
101
|
+
color: (typeof NOTE_COLORS)[number];
|
|
102
|
+
};
|
|
103
|
+
export type MachineNode = Node<MachineData, "machine">;
|
|
104
|
+
export type LanNode = Node<LanData, "lan">;
|
|
105
|
+
export type SwitchNode = Node<SwitchData, "switch">;
|
|
106
|
+
export type NoteNode = Node<NoteData, "note">;
|
|
107
|
+
export type LabNode = MachineNode | LanNode | SwitchNode | NoteNode;
|
|
108
|
+
export type CableEdge = Edge<CableData, "cable">;
|
|
109
|
+
export declare const isMachine: (n: LabNode) => n is MachineNode;
|
|
110
|
+
/**
|
|
111
|
+
* A router you configure (FRR as a container, or a VM): drawn as a faceplate with interfaces,
|
|
112
|
+
* like a switch. The automatic router (kind "router") has no interfaces to show.
|
|
113
|
+
*/
|
|
114
|
+
export declare const isRealRouter: (n: LabNode) => n is MachineNode;
|
|
115
|
+
export declare const ROUTER_PORTS = 4;
|
|
116
|
+
export declare const ROUTER_W = 168;
|
|
117
|
+
export declare const ROUTER_H = 74;
|
|
118
|
+
export declare const routerPort: (i: number) => string;
|
|
119
|
+
/** Routers and firewalls: one connection point, and they snap onto a LAN's edge. */
|
|
120
|
+
export declare const isAppliance: (n: LabNode) => n is MachineNode;
|
|
121
|
+
export declare const isLan: (n: LabNode) => n is LanNode;
|
|
122
|
+
export declare const isSwitch: (n: LabNode) => n is SwitchNode;
|
|
123
|
+
export declare const isNote: (n: LabNode) => n is NoteNode;
|
|
124
|
+
/** A node's name as lists show it (a note has none). */
|
|
125
|
+
export declare const nodeName: (n: LabNode) => string;
|
|
126
|
+
export declare const SWITCH_PORTS = 8;
|
|
127
|
+
/** A switch's faceplate on the canvas (see `SwitchNodeView`). */
|
|
128
|
+
export declare const SWITCH_W = 306;
|
|
129
|
+
export declare const SWITCH_H = 74;
|
|
130
|
+
export declare const TRUNK = "trunk";
|
|
131
|
+
/** A machine's box on the canvas (see `MachineNodeView`). */
|
|
132
|
+
export declare const MACHINE_W = 120;
|
|
133
|
+
export declare const MACHINE_H = 116;
|
|
134
|
+
export declare const LAN_W = 420;
|
|
135
|
+
export declare const LAN_H = 300;
|
|
136
|
+
/** How big a node is drawn: what snapping and "is it inside the LAN" go by. */
|
|
137
|
+
export declare function sizeOf(n: LabNode): {
|
|
138
|
+
w: number;
|
|
139
|
+
h: number;
|
|
140
|
+
};
|
|
141
|
+
/** A node's center on the canvas, by its drawn size (measured by React Flow, or `fallback`). */
|
|
142
|
+
export declare function centerOf(n: LabNode, fallback?: {
|
|
143
|
+
w: number;
|
|
144
|
+
h: number;
|
|
145
|
+
}): XYPosition;
|
|
146
|
+
/**
|
|
147
|
+
* How a LAN behaves on the canvas, as an Excalidraw frame: it is moved and selected by its label
|
|
148
|
+
* only, so a click or a drag inside it reaches the canvas (placing a device, drawing a selection
|
|
149
|
+
* box). Not saved: applied to every LAN when it is created or loaded.
|
|
150
|
+
*/
|
|
151
|
+
export declare const LAN_BEHAVIOR: {
|
|
152
|
+
readonly dragHandle: ".lan-handle";
|
|
153
|
+
readonly className: "pointer-events-none";
|
|
154
|
+
};
|
|
155
|
+
/** Which side of a LAN an appliance sits on, when it is snapped onto one. */
|
|
156
|
+
export type Side = "top" | "bottom" | "left" | "right";
|
|
157
|
+
/** The canvas's look (see `DesignContext`): hand-drawn, or crisp for a report. */
|
|
158
|
+
export type Design = "sketch" | "business";
|
|
159
|
+
export declare const DESIGNS: Design[];
|
|
160
|
+
export type Draft = {
|
|
161
|
+
name: string;
|
|
162
|
+
nodes: LabNode[];
|
|
163
|
+
edges: CableEdge[];
|
|
164
|
+
design?: Design;
|
|
165
|
+
};
|
|
166
|
+
/** Machine names are Isoloom keys: lowercase letters, digits and dashes. */
|
|
167
|
+
export declare function cleanName(name: string): string;
|
|
168
|
+
export declare function uid(prefix: string): string;
|
|
169
|
+
/** The first `<prefix><n>` no machine or LAN uses yet. */
|
|
170
|
+
export declare function freeName(prefix: string, nodes: LabNode[]): string;
|
|
171
|
+
/** Every node unselected: what placing or pasting something does to the rest. */
|
|
172
|
+
export declare function unselected<T extends LabNode | CableEdge>(items: T[]): T[];
|
|
173
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Appliance } from "./model";
|
|
2
|
+
/**
|
|
3
|
+
* The OSes a machine can be, as Isoloom writes them (`<family>@<version>`): exactly Isoloom's list,
|
|
4
|
+
* which its engine gives (`choices_json`, checked by the tests). A machine of one of them is its
|
|
5
|
+
* OS, set up by its provisioning steps; each target decides whether it runs as a VM or as a
|
|
6
|
+
* container built from the OS's image.
|
|
7
|
+
*/
|
|
8
|
+
export declare const OS_CHOICES: string[];
|
|
9
|
+
/** The OS a new VM gets. */
|
|
10
|
+
export declare const DEFAULT_OS = "debian@12";
|
|
11
|
+
/**
|
|
12
|
+
* An OS as a lab stored before Isoloom's new format named it (its image-table name: `debian-12`,
|
|
13
|
+
* `almalinux-9`, `kali`, `windows-server-2022`), in today's spelling; any other value as it is.
|
|
14
|
+
*/
|
|
15
|
+
export declare function currentOs(os: string): string;
|
|
16
|
+
/** A machine as a stored lab or device holds it, in today's spelling: its OS and its Cisco OS. */
|
|
17
|
+
export declare function currentMachine<M extends {
|
|
18
|
+
os: string;
|
|
19
|
+
appliance?: Appliance;
|
|
20
|
+
}>(m: M): M;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fixing a machine's address on a LAN by hand: same block, a new last number (typed alone, or
|
|
3
|
+
* as a whole address); clearing it goes back to the next free one. Null: not a valid address.
|
|
4
|
+
*/
|
|
5
|
+
export declare function pinned(pins: Record<string, number> | undefined, net: string, ip: string, typed: string): Record<string, number> | null;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { NodeChange, XYPosition } from "@xyflow/react";
|
|
2
|
+
import { type LabNode, type LanNode } from "./model";
|
|
3
|
+
import type { Preset } from "./presets";
|
|
4
|
+
/** Placing devices: where they land, and what comes with them. */
|
|
5
|
+
/** A device placed from the palette (no point given): in the middle of the view, staggered so machines added in a row don't stack exactly. */
|
|
6
|
+
export declare function paletteSpot(viewCenter: XYPosition, nodes: LabNode[]): XYPosition;
|
|
7
|
+
/**
|
|
8
|
+
* The nodes after placing a router or firewall at `position`: near a LAN's border it lands on
|
|
9
|
+
* it, as when dragged; away from any LAN it comes with its own LAN under it (it is that LAN's
|
|
10
|
+
* gateway). `dropped`: placed at a point (a click, a drop), centered there like a machine.
|
|
11
|
+
*/
|
|
12
|
+
export declare function placeAppliance(preset: Preset, position: XYPosition, dropped: boolean, nodes: LabNode[], lans: LanNode[]): LabNode[];
|
|
13
|
+
/** The nodes after placing a machine at `position`, selected. */
|
|
14
|
+
export declare function placeMachine(preset: Preset, position: XYPosition, nodes: LabNode[]): LabNode[];
|
|
15
|
+
/**
|
|
16
|
+
* The nodes after placing a switch at `at`: on a LAN's edge when near one; away from any LAN it
|
|
17
|
+
* comes with its LAN, its first VLAN, hanging under it.
|
|
18
|
+
*/
|
|
19
|
+
export declare function placeSwitch(at: XYPosition, nodes: LabNode[], lans: LanNode[]): LabNode[];
|
|
20
|
+
/** Routers, firewalls and switches are magnetic: dragged near a LAN's border, they land on it. */
|
|
21
|
+
export declare function snapMoves(changes: NodeChange<LabNode>[], nodes: LabNode[], lans: LanNode[]): NodeChange<LabNode>[];
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A machine's ports field (`80, 443/https, 53/udp`): each entry a port, 1 to 65535, and what it
|
|
3
|
+
* speaks when it isn't plain TCP: Isoloom's port `protocol`. An entry Isoloom couldn't take is
|
|
4
|
+
* kept out of the topology and reported (see `canvasIssues`), never guessed.
|
|
5
|
+
*/
|
|
6
|
+
/** What a port speaks: TCP (the default), UDP, or TCP that speaks HTTP, HTTPS or TLS. */
|
|
7
|
+
export declare const PORT_PROTOCOLS: readonly ["tcp", "udp", "http", "https", "tls"];
|
|
8
|
+
type PortProtocol = (typeof PORT_PROTOCOLS)[number];
|
|
9
|
+
/** A port as the engine's topology takes it (`protocol` left out for TCP). */
|
|
10
|
+
export interface Service {
|
|
11
|
+
port: number;
|
|
12
|
+
protocol?: PortProtocol;
|
|
13
|
+
}
|
|
14
|
+
/** The ports field read: its ports, and each entry it couldn't read. */
|
|
15
|
+
export declare function readPorts(text: string): {
|
|
16
|
+
services: Service[];
|
|
17
|
+
bad: string[];
|
|
18
|
+
};
|
|
19
|
+
/** Ports as the field writes them: `80, 53/udp`. */
|
|
20
|
+
export declare function portsText(services: readonly Service[]): string;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type MachineData } from "./model";
|
|
2
|
+
/** The devices the toolbar places, and the ones saved from the canvas. */
|
|
3
|
+
export interface Preset {
|
|
4
|
+
id: string;
|
|
5
|
+
/** Toolbar groups: network appliances first, then containers, then VMs, then saved devices. */
|
|
6
|
+
group: "network" | "container" | "vm" | "mine";
|
|
7
|
+
/** A saved device's name. The built-in devices are named in the editor's text, by their id. */
|
|
8
|
+
label?: string;
|
|
9
|
+
/** Prefix of the generated machine name (`router1`, `router2`...). */
|
|
10
|
+
prefix: string;
|
|
11
|
+
data: Omit<MachineData, "name">;
|
|
12
|
+
}
|
|
13
|
+
export declare const PRESETS: Preset[];
|
|
14
|
+
/** Keys 1–9 then 0 pick the devices, in toolbar order. */
|
|
15
|
+
export declare function shortcutOf(presetId: string): string | null;
|
|
16
|
+
/** The device a number key picks: 1–9 the first nine, 0 the tenth. */
|
|
17
|
+
export declare function presetForKey(key: string): Preset | undefined;
|
|
18
|
+
/** A device from a machine on the canvas: everything but its name and fixed addresses. */
|
|
19
|
+
export declare function deviceFrom(m: MachineData): Preset;
|
|
20
|
+
/** What changes when a machine is set to run as `kind`: a VM keeps its OS (Debian 12 by default), a container its image (FRR for a router, Alpine otherwise). */
|
|
21
|
+
export declare function runAs(m: MachineData, kind: string): Partial<MachineData> | null;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { Draft } from "./model";
|
|
2
|
+
/**
|
|
3
|
+
* The site's project store (`/api/projects`), for a signed-in user: their projects, each with
|
|
4
|
+
* its earlier versions. Errors carry the server's message, or the HTTP status.
|
|
5
|
+
*/
|
|
6
|
+
export interface ProjectSummary {
|
|
7
|
+
id: string;
|
|
8
|
+
name: string;
|
|
9
|
+
updatedAt: string;
|
|
10
|
+
}
|
|
11
|
+
export interface ProjectVersion {
|
|
12
|
+
id: number;
|
|
13
|
+
savedAt: string;
|
|
14
|
+
}
|
|
15
|
+
export declare const listProjects: () => Promise<ProjectSummary[]>;
|
|
16
|
+
export declare const getProject: (id: string) => Promise<{
|
|
17
|
+
id: string;
|
|
18
|
+
name: string;
|
|
19
|
+
draft: Draft;
|
|
20
|
+
}>;
|
|
21
|
+
export declare const deleteProject: (id: string) => Promise<unknown>;
|
|
22
|
+
export declare const listVersions: (id: string) => Promise<ProjectVersion[]>;
|
|
23
|
+
export declare const getVersion: (id: string, version: number) => Promise<{
|
|
24
|
+
draft: Draft;
|
|
25
|
+
}>;
|
|
26
|
+
/** Saves the lab as a new project (POST), or as the next version of `id` (PUT). */
|
|
27
|
+
export declare function saveProject(id: string | null, body: {
|
|
28
|
+
name?: string;
|
|
29
|
+
draft: Draft;
|
|
30
|
+
isoloomYml: string | null;
|
|
31
|
+
}): Promise<ProjectSummary>;
|
|
32
|
+
/** A project by the id in a link (#project=…), or null when it can't be read. */
|
|
33
|
+
export declare function projectFromLink(id: string): Promise<{
|
|
34
|
+
id: string;
|
|
35
|
+
name: string;
|
|
36
|
+
draft: unknown;
|
|
37
|
+
} | null>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type CableEdge, type LabNode, type LanNode } from "./model";
|
|
2
|
+
/**
|
|
3
|
+
* A real router's interfaces: each port's color (striped when it is a trunk), and the list of
|
|
4
|
+
* interfaces with the network and address on each; a trunk port has one sub-interface per VLAN
|
|
5
|
+
* (eth0.10, eth0.20), as router-on-a-stick.
|
|
6
|
+
*/
|
|
7
|
+
export interface RouterPorts {
|
|
8
|
+
colors: Partial<Record<string, string>>;
|
|
9
|
+
interfaces: {
|
|
10
|
+
name: string;
|
|
11
|
+
network: string;
|
|
12
|
+
ip?: string;
|
|
13
|
+
color: string;
|
|
14
|
+
}[];
|
|
15
|
+
}
|
|
16
|
+
/** Each machine's addresses (from the engine), by machine name: [network, IPv4][]. */
|
|
17
|
+
export type Addresses = Partial<Record<string, [string, string][]>>;
|
|
18
|
+
/**
|
|
19
|
+
* Each real router's interfaces, by node id: the network on each port, its address there, and a
|
|
20
|
+
* color. On a LAN's edge, the LAN is on eth0 (or the first port no cable uses).
|
|
21
|
+
*/
|
|
22
|
+
export declare function routerPortsOf(nodes: LabNode[], edges: CableEdge[], lans: LanNode[], addresses: Addresses): Record<string, RouterPorts>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type IssueText } from "./issues";
|
|
2
|
+
import type { Plan } from "./engine";
|
|
3
|
+
import { type CableEdge, type LabNode } from "./model";
|
|
4
|
+
/** What is selected: one thing opens its window; several open the "selection" window instead. */
|
|
5
|
+
export declare function selectionOf(nodes: LabNode[], edges: CableEdge[]): {
|
|
6
|
+
selectedNodes: LabNode[];
|
|
7
|
+
selectedEdges: CableEdge[];
|
|
8
|
+
count: number;
|
|
9
|
+
machine: import("./model").MachineNode | undefined;
|
|
10
|
+
lan: import("./model").LanNode | undefined;
|
|
11
|
+
edge: CableEdge | undefined;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* What to fix before the lab runs: the canvas's own findings, then the engine's. An empty canvas
|
|
15
|
+
* isn't a lab with problems yet: nothing until there is something to check.
|
|
16
|
+
*/
|
|
17
|
+
export declare function labIssues(nodes: LabNode[], plan: Plan | null, text: IssueText): string[];
|
|
18
|
+
/** A node's name by its id, as the windows show it ("?" for one that is gone). */
|
|
19
|
+
export declare function nameById(nodes: LabNode[], id: string): string;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Design, Draft } from "./model";
|
|
2
|
+
import type { Preset } from "./presets";
|
|
3
|
+
/** The last lab drawn in this browser; none (a blank canvas) when what is kept hasn't a lab's shape. */
|
|
4
|
+
export declare function loadDraft(): Draft | null;
|
|
5
|
+
/** Keeps the lab, without its UI state (selection is not part of the lab). */
|
|
6
|
+
export declare function saveDraft(draft: Draft): void;
|
|
7
|
+
/** Devices saved from the canvas (GNS3's appliances), placed from the toolbar like the built-in ones. */
|
|
8
|
+
export declare function loadDevices(): Preset[];
|
|
9
|
+
export declare function saveDevices(list: Preset[]): void;
|
|
10
|
+
/** The canvas's look picked in this browser, if any. */
|
|
11
|
+
export declare function loadDesign(): Design | null;
|
|
12
|
+
export declare function saveDesign(design: Design): void;
|
|
13
|
+
/** The kind each toolbar block places, by block id, as picked last. */
|
|
14
|
+
export declare function loadBlockChoices(): Record<string, string> | null;
|
|
15
|
+
export declare function saveBlockChoices(choices: Record<string, string>): void;
|
|
16
|
+
/** Whether `lab` starts when the app opens on it. */
|
|
17
|
+
export declare function autoStarts(lab: string): boolean;
|
|
18
|
+
export declare function setAutoStarts(lab: string, on: boolean): void;
|
|
19
|
+
/** The saved project the editor is attached to. */
|
|
20
|
+
export interface ProjectRef {
|
|
21
|
+
id: string;
|
|
22
|
+
name: string;
|
|
23
|
+
}
|
|
24
|
+
export declare function loadProject(): ProjectRef | null;
|
|
25
|
+
export declare function saveProject(p: ProjectRef | null): void;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type SwitchNode } from "./model";
|
|
2
|
+
/** Editing a switch on the canvas: each change returns the switch's fields that change. */
|
|
3
|
+
type SwitchData = SwitchNode["data"];
|
|
4
|
+
/** A click steps a port through each VLAN, then trunk, then unassigned. */
|
|
5
|
+
export declare function cyclePort(data: SwitchData, i: number): Pick<SwitchData, "ports">;
|
|
6
|
+
/** A VLAN's number or block changed; a new number moves its ports along. */
|
|
7
|
+
export declare function changeVlan(data: SwitchData, old: number, patch: {
|
|
8
|
+
id?: number;
|
|
9
|
+
cidr?: string;
|
|
10
|
+
}): Pick<SwitchData, "vlans" | "ports">;
|
|
11
|
+
/** A VLAN removed: its ports are left unassigned. */
|
|
12
|
+
export declare function removeVlan(data: SwitchData, vid: number): Pick<SwitchData, "vlans" | "ports">;
|
|
13
|
+
/** A new VLAN, numbered 10 after the highest, with its own block. */
|
|
14
|
+
export declare function addVlan(data: SwitchData): Pick<SwitchData, "vlans">;
|
|
15
|
+
/** A typed VLAN number, if it can be one: 1–4094, and not one the switch has already. */
|
|
16
|
+
export declare function vlanNumber(data: SwitchData, typed: string): number | null;
|
|
17
|
+
export {};
|