Web viewer¶
The web viewer opens, edits and renders uniwire documents directly in the browser, with nothing to
install. It runs the real uniwire Python library (the same code as the CLI) on
Pyodide, so validation messages, rule findings, drawings and the bill of
materials are exactly those you get with uniwire validate, check, render and bom.
Everything runs on your machine: documents are never uploaded. The first visit downloads the Python runtime (about 10 MB, then cached by the browser). Meanwhile the drawing is already shown: the examples come with their first sheet drawn in advance, and the short links of the hosted server with the first sheet drawn by the server; the live drawing replaces it as soon as the editor is ready.
Large drawings are drawn with the compiled link router of the library (uniwire-native, built for Pyodide, about
65 kB more to download), as with pip install "uniwire[native]": the same drawings, several times faster on
large ones. If the browser cannot load it, the editor draws the same drawings in pure Python, only slower.
Features¶
- Editor with JSON syntax highlighting, error markers in the gutter and live re-rendering (400 ms after the last keystroke). Open a file with Open, drag and drop it onto the page, or paste a document.
- Drawing: one tab per sheet, numbered as in the drawing set of the document's views (the numbers of the title
blocks and of the PDF), zoom with the mouse wheel or the +/− buttons, pan by dragging (dragging
never selects text: double-click a text to select it, or drag with
Alt/Optionheld), Fit to show the whole sheet. Switch between the document's views and between the single-line and multi-line diagrams. The drawing language followsmeta.langof the document. - Exploring the drawing:
- hover a symbol to see its tag, type, ratings and cable, with its path up to the source highlighted in orange and everything it feeds in blue;
- hover a link (transfer, tie, interlock, data…) to highlight it and its two ends, with a tooltip giving its kind, both ends, the device it carries and its cable;
- in the multi-line diagram, hover a conductor (L1, L2, L3, N, PE…) to follow it across the sheet;
- click (or tap) to keep the highlight;
Escor a click on an empty area clears it; - click an off-page reference ("→ sheet 3") to jump to that sheet, centred on the target;
Back (or
Alt+←, or the browser's back button) returns to the previous sheet and view.
- Colours: the Colours menu re-renders the drawing coloured by conductor, phase, source, status or voltage, and the Conductors menu picks the conductor colour convention (IEC or US). As in the document keeps the document's own view settings. The sheet stays white in dark mode.
- Keyboard (outside the editor):
←/→orPageUp/PageDownchange sheet,For0fits the sheet,+/-zoom,↑/↓andShift+arrows pan,Escclears the selection,Alt+←goes back. - Issues: validation errors with their JSON path, and rule findings (severity, rule, message,
node), in the language of the document (
meta.lang) when uniwire has it, else in that of the interface. Clicking a finding highlights the node in the drawing and in the editor; clicking a symbol in the drawing selects its node in the editor. While the document is invalid, the last valid drawing stays visible. - Examples: every document of the examples gallery is available from the Examples menu.
- Downloads: current sheet as SVG, all sheets as a print-ready page (print to PDF from the browser), PDF generated in the browser, bill of materials (CSV), normalized JSON and the source JSON.
- Sharing: Share copies a link that contains the whole document (compressed in the URL fragment, so it is not sent to the server). Very large documents give long links that some tools truncate: share the file instead.
- English and French interface (follows the browser language; switch with EN / FR).
Links¶
| URL | Opens |
|---|---|
https://uniwire.sh/viewer/ |
the last document edited in this browser, else the first example |
https://uniwire.sh/viewer/?example=03 |
an example, by number or full name (03_house_three_phase_heat_pump_ev) |
https://uniwire.sh/viewer/#doc=… |
a document shared with the Share button |
…?example=07#sheet=3 |
a given sheet (also written to the address bar when you follow an off-page reference) |
Limits¶
- A recent browser is required (WebAssembly, Web Workers,
CompressionStream). - PDF export downloads the PDF engine (reportlab) on first use. The PDF is written with the font shipped in the uniwire package (Liberation Sans), as on any other system, so it is the same PDF as the one the library writes elsewhere. All sheets (print / PDF) prints the SVG sheets instead.
- The optional data packages (such as
uniwire-data-iec81346) are not loaded.
Running it locally¶
The viewer is a static site in the viewer/
directory of the repository:
python viewer/build.py # builds the wheel and copies the examples
python -m http.server -d viewer 8000 # open http://localhost:8000/
The compiled link router is optional. To serve it too, build it for the Pyodide release of the viewer (needs Python 3.12 or later and rustup; the script installs the matching Emscripten SDK and Rust toolchain in user space), then pass it to the build:
packages/uniwire-native/build-pyodide.sh
python viewer/build.py --native packages/uniwire-native/target/pyodide