feat(docs): draw the landing diagram from the engine, with ports - #899
Merged
Merged
Conversation
…to feature/landing-rendered-diagram
…ions Co-Authored-By: jason.han <hanhuijun@gmail.com>
Co-Authored-By: jason.han <hanhuijun@gmail.com>
Co-Authored-By: jason.han <hanhuijun@gmail.com>
Co-Authored-By: jason.han <hanhuijun@gmail.com>
… feature/landing-rendered-diagram
Co-Authored-By: jason.han <hanhuijun@gmail.com>
Contributor
Author
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
Co-Authored-By: jason.han <hanhuijun@gmail.com>
Co-Authored-By: jason.han <hanhuijun@gmail.com>
Co-Authored-By: jason.han <hanhuijun@gmail.com>
Co-Authored-By: jason.han <hanhuijun@gmail.com>
…ls away Co-Authored-By: jason.han <hanhuijun@gmail.com>
Co-Authored-By: jason.han <hanhuijun@gmail.com>
Co-Authored-By: jason.han <hanhuijun@gmail.com>
Co-Authored-By: jason.han <hanhuijun@gmail.com>
Co-Authored-By: jason.han <hanhuijun@gmail.com>
Co-Authored-By: jason.han <hanhuijun@gmail.com>
Co-Authored-By: jason.han <hanhuijun@gmail.com>
Co-Authored-By: jason.han <hanhuijun@gmail.com>
Co-Authored-By: jason.han <hanhuijun@gmail.com>
Co-Authored-By: jason.han <hanhuijun@gmail.com>
…between them Co-Authored-By: jason.han <hanhuijun@gmail.com>
…ired to Co-Authored-By: jason.han <hanhuijun@gmail.com>
Co-Authored-By: jason.han <hanhuijun@gmail.com>
…ed too close Co-Authored-By: jason.han <hanhuijun@gmail.com>
Co-Authored-By: jason.han <hanhuijun@gmail.com>
Contributor
Author
3 of 6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
The landing page's diagram was a hand-drawn SVG, so it could drift from the model it describes. It also showed no ports, and dragging a box didn't reroute its wires. This PR draws it in the browser from
docs/assets/opensysml-stack.sysml, using the engine'sRenderViewcall (#888) and the VS Code panel's shared layout, drawing and port-routing code (#890).docs/assets/opensysml-stack.sysml): fourProjectparts, each with anapiport, joined byInterchangeinterface connections, plus theModelJourneystate machine. Its journey events (Commit,Pull,Check,Push) are declared asitem defs, so the model analyses cleanly.editors/vscode/src/landing/):model.tscallsParseSources, thenRenderView(ports: "minimal") andInstantiate. It lifts the four parts out of their container and keeps their ports, along with each edge'sfromPort/toPort.present.tsmaps each part'slabel/kind/lang/roleattributes onto the box. It drops wire labels, so connection names appear in the right-click cards and labels can't collide with boxes.main.tslays the diagram out with ELK, draws it with the shared canvas, and reroutes edges to their port faces with libavoid on every animation frame while a box is dragged, so wires stay orthogonal during the drag. A dropped box moves to the nearest spot that keeps two routing clearances from every other box and one from the hero edge, so libavoid always has a corridor out of each port; boxes nobody moved keep their ELK positions across resize and edits. If a dropped box's port lands less than one grid square (16) out of line with a port it's wired to,alignedPlacementmoves the box so the two line up and the wire runs straight. It only does this when the aligned spot is still free and in bounds. Ports are only lined up when they face each other. On a drag frame where libavoid can't route a wire, because the held box is too close to another,keepOrthogonalRouteskeeps that wire's previous right-angled route and reattaches its ends to the current port faces (reattachRoute). If reattaching would turn an exit leg back through its own box, the wire is rebuilt as a short orthogonal path leaving each port outward. It also handles:ExecuteStateonModelJourney.stack.json) when the engine can't load.overrides/home.html): the hand-drawn SVG is replaced by a stage thatassets/landing/diagram.jsdraws into. The hero, header, buttons and graph paper are unchanged. The licensing list links the new third-party notices.npm run build:landing(editors/vscode/tools/build-landing.mjs) writesdocs/assets/landing/{diagram.js, libavoid.wasm, libavoid-js.LICENSE.txt}. These are build outputs and gitignored, like the engine assets.make docs-landing-assetsruns the bundle build.overrides/now counts as a docs change area.editors/vscode/src/webview/): ELK now places each port across its node's border (elk.port.borderOffset), as the square is drawn, so automatic routes end on the port square instead of half a port short of it. This also fixes the VS Code panel.nodeExtent/clampNodeToBoundsgive the landing page a node's extent including its ports, port labels and the pin's exit leg, so a box clamped at the hero's edge keeps its wires inside the hero. libavoid also gets the hero as frame obstacles, so rerouted wires stay inside it, and pin positions are clamped to the[0, 1]range libavoid accepts. After routing,straightenJogsremoves bends shorter than one grid square (16) where a straight segment would stay clear of every box's routing buffer, keep its endpoints' exit legs, stay in bounds and add no wire crossings; jogs forced by two slightly offset ports are left alone. The VS Code panel gets this pass too.docs/project/third-party-notices.md, listed under Reference): elkjs 0.12.0 is EPL-2.0 OR GPL-3.0-or-later; libavoid-js 0.4.5 is LGPL-2.1-or-later. The notices give copyright holders, exact source revisions, libavoid-js's header patch, and how to substitute a modified libavoid. The LGPL text ships next to the.wasm.How it was verified
cd editors/vscode && npm run typecheck && npm test(289 pass, including the newpresent.test.tsandmodel.test.ts, and seeded routing tests for drop placement, jog straightening, port alignment on drop, route reattachment (including the captured too-close drag frame) and pin portions) andnpm run build:landing.go build ./...,go test -count=1 ./tests/wasm/...,go test -count=1 ./tests/hygiene -run TestRuntimeModelsCarryArgumentTyping.scripts/ci-changed-areas-test.sh,python3 scripts/changelog.py check,python3 scripts/check-doc-links.py,python3 scripts/check-doc-ids.py, andmake docs(strict) aftermake docs-engine-assetsandmake docs-landing-assets.In Chrome, against the built site at desktop and 390 px widths:
;keeps the last clean diagram and showsline 5:34: missing ';';Size:
diagram.jsis 1.5 MB minified (about 476 KB gzipped, mostly ELK) and loads on landing visits. The engine still loads separately.Browser, desktop and phone widths: 25 drops, including stacking one box onto another; every wire stayed orthogonal, attached to its port and inside the hero, with no pin warnings. Routing plus drawing during a held drag took 1.1 ms per frame median and 1.7 ms worst.
Checklist
make testandmake lintpass locallychanges/unreleased/<slug>.<section>.md, not as an edit toCHANGELOG.mdmake docs-countsrun if a gate count moved (compliance rows need nothing: the census is counted at docs build)F4,K5) in the body, docs, or changelogLink to Devin session: https://nasa-jpl-demo.devinenterprise.com/sessions/72fc89eb61334dafbfa6880cda547310
Open in Devin Desktop: https://nasa-jpl-demo.devinenterprise.com/desktop/session/72fc89eb61334dafbfa6880cda547310?variant=devin
Requested by: @HuiJun