- 1The round tripRead, rebuild, compare. Every file comes back byte for byte.
- 2Three modesStudio, mixed, code: how much of a file Studio will touch.
- 3The previewThe page is drawn by a separate process on its own origin.
- 4SelectionTree and canvas agree without anything added to your files.
1. The round trip
A Xonry project is two things: wireframes.php, which lists the pages and the sections on each, and the section files under layers/. Studio does three things with them.
Read
Studio parses each file into a model: pages, sections and elements, each with the place in the file where it starts and ends. It parses PHP with PHP's own tokenizer and HTML with a tokenizer of its own. It never runs the file.
Rebuild
From the model alone, Studio writes each file again.
Compare
The result must equal the original, byte for byte. If Studio cannot model a file that exactly, it treats the file as code and does not edit inside it.
| project | files | bytes | identical | ignored | refused | modes ||-------------|-------|-------|-----------|---------|---------------------|-------------------------|| demo-site | 15 | 5389 | 15/15 | 0 | island-unbalanced:1 | code:8 mixed:1 studio:6 || legacy-grid | 2 | 36 | 2/2 | 0 | - | code:1 studio:1 |total: projects=2 files=17 bytes=5425 identical=17 different=0REFUSED demo-site/layers/files/files.php island-unbalancedOn the 12 project folders of the author's working install the same command gave 146 of 146 files identical: 1,300,369 bytes.
An edit is a splice
Because every element has a start and an end, a change is a replacement of that range.
GET /api/v0/projects/demo-site/sections/hero/nodes/r.2HTTP/1.1 200 OKETag: "sha256-e9f9c77f8bdb95452f089137f7adb817a033ca781cbcbb878d0085d807edbd51"{ "id": "r.2", "type": "element", "span": [ 44, 96 ], "rev": "sha256-adf5aa5ffacd2f761b19f0927e2a526d795982e9be7013c4e86e8ea576d98b4e", "line": 2, "endLine": 2, "source": "<h1 class=\"title\">A page is a list of sections.</h1>", "truncated": false, "withheld": null}<p class="eyebrow">layers/hero/hero.php</p><h1 class="title">A page is a list of sections.</h1><p class="lead">This heading is one file. Its place on the page is one entry in <code>wireframes.php</code>.</p><a class="button" href="/about">About this demo</a>To change this heading, Studio would replace bytes inside 44 to 96 and leave the other 210 bytes as they are. Before writing, it parses its own result again and compares it with the model it expected; if they differ, nothing is written. A write is refused if the file changed on disk after Studio read it.
| project | trials | applied | no-op | restored | lint | inverse-exact | inverse byte/model/differs | failures ||-----------|--------|---------|-------|----------|------|---------------|----------------------------|----------|| demo-site | 212 | 212 | 0 | 212/212 | 212 | 116/116 | 136/0/14 | 0 |This engine is tested from the command line: 212 trial edits on a copy of the demo project, each undone to the original bytes, and 2,397 on copies of six real project folders. No button in the interface calls it yet.
2. Three modes: studio, mixed, code
Not every file can be edited visually without risk. Studio sorts each file into one of three modes and shows the mode as a badge. The mode is worked out from the file each time; it is not stored anywhere.
studio
Plain markup that Studio models completely.
<p class="eyebrow">layers/hero/hero.php</p><h1 class="title">A page is a list of sections.</h1><p class="lead">This heading is one file. Its place on the page is one entry in <code>wireframes.php</code>.</p><a class="button" href="/about">About this demo</a>mixed
Markup with PHP inside it, where each piece of PHP stays inside one element. Studio can work around the PHP. It never changes, moves or removes it.
<p class="small">Demo site. A fixture written to show Xonry and OnceBuilder Studio.</p><p class="small">Rendered by PHP <span class="version"><?= PHP_MAJOR_VERSION ?>.<?= PHP_MINOR_VERSION ?></span>.</p>code
Anything else: for example a loop that opens in one piece of PHP and closes in another. Studio shows the file and the reason and does not touch its inside. The section can still be placed on a page and moved.
<?php $files = array('wireframes.php', 'head.php', 'foot.php', 'layers/hero/hero.php', 'layers/counter/counter.php'); ?><h2 class="heading">This list comes from a PHP loop</h2><ul class="file-list"><?php foreach ($files as $file) { ?> <li><code><?= htmlspecialchars($file) ?></code></li><?php } ?></ul>Style sheets and scripts are always in code mode in this version: Studio keeps their bytes and does not look inside.




3. The preview runs on a separate origin
Two kinds of process make up Studio.
The Studio server
It serves the interface and answers its questions from the model. It reads wireframes.php and the section files as data. It never includes a project file, and it never opens config.php, keys or data folders.
The preview process
It draws the page for the canvas by handing the project to the unmodified Xonry engine. This does run the project's PHP, on your computer, as you. It starts for a project only after you have confirmed it, and the choice ends when Studio stops.








Each previewed project is served under its own host name and port, which makes it a separate origin for the browser: its cookies, storage and scripts are apart from Studio's and from those of any other project. Studio's own interface does not answer on that origin, and only Studio may place the page in a frame.
The preview changes no file. What it needs for selection it adds in memory, while the engine reads a section. A button, "Show page without Studio", shows the page with nothing added at all.
| check | result ||----------------------------------------------------------|--------|| public API calls made over the two fixtures | 55 || markers created by Studio | 0 || positive control: markers created by a plain php include | 1 |TRIPWIRE OK: nothing was executed, and the control shows the marker can fire4. Selection writes nothing into your pages
The tree and the canvas have to agree on which element is which. Studio does not add ids or attributes to your files for that. The Studio server and the preview each work out the same id for an element from the same bytes of the file.




Click an element on the canvas and its row is selected in the tree. Click a row and the element is outlined. In the recorded test run every sampled element matched, on a real project and on the fixtures. Where markup is produced by PHP and has no place of its own in the file, Studio selects the nearest element around it that has.


Properties are read from the file, not from the browser: tag, id, classes and attributes as written, the file, the mode, the byte range and the lines.


The canvas can be set to five fixed widths or fitted to the window. The outline follows the element.
5. What comes next
The next step is editing in the interface: connecting the tested edit engine to the tree, the canvas and the properties, with a safe way to write to a project. It is not built, and no date is promised.
What works today, and what does not How Xonry builds a page from these files (opens another website)