The studio layout
A richer app shell of a space: pages open as tabs, the main area splits in two, and a resizable right panel holds lenses that packages contribute to the panel slot. Lenses are the same as in layout-basic and link its lens.js.
layout-studio
A second, richer layout for the prototype cloud app: pages open as tabs, the main area splits in
two, and a resizable right panel holds lenses contributed to the panel slot. Lenses are unchanged:
they link /_pkg/layout-basic/lens.js and work in both layouts.
Files: shell.html, shell.css, shell.js (served at /), package.md (with the settings:
block), test/fake-host.ts, test/props-lens.html (the demo panel lens "Свойства").
Run: bun apps/standard/packages/layout-studio/test/fake-host.ts 4377 (add CACHE=long to send
Cache-Control: public, max-age=31536000, immutable for /_pkg and /_kit, as real hosts do).
Behaviour
- Sidebar click opens the page in the focused side's current tab; Cmd/Ctrl-click or middle-click opens a new tab; Alt-click opens it on the right half (split). Opening a page that is already open focuses its tab.
- Tabs: click focuses, × or middle-click closes. With the
tabssetting off there is one view. - Split: the button in the top bar (or Alt-click) opens the right half; × on its header closes it.
The focused side is the one last clicked (the shell watches
document.activeElement); the crumbs, the lens switch and the right panel follow it. - Right panel: its own tab strip, one tab per panel contribution. Resize edge on its left: drag,
arrow keys (16 px), Home or double-click resets to 320 px; limits 240..560 px and at least 480 px
stay for the document; the width is kept in
localStorage['studio.panelWidth']. - Settings popover (top bar): flips the settings live; values in
localStorage['studio.<key>'], defaults frompackage.md(fetched once at boot, in parallel withspace.infoandtree).
URL (all view state; reload and back/forward restore it)
/?t=<lens>:<path>&t=...&a=<active tab index>&s=<lens>:<path>&f=R&p=<panel lens id>
tonce per tab, in order;<lens>may be empty (the first lens for the page's kind).aomitted when 0;sis the right half;f=Rwhen the right half has focus;pthe panel tab.?path=&lens=(layout-basic links,lens.jsstandaloneopen) is accepted as one tab.- Every change is a
pushState; a focus change is areplaceState. The last URL is also kept inlocalStorage['studio.last']and used when/is opened bare.
Caching
- All frames sit in one stage and are placed by class (
L,R), so a frame is never moved in the DOM (moving reloads it). Frames of open tabs and of the split stay alive; any other frame (closed tabs, hover preloads, other lenses) goes to an LRU of 8. - A frame is swapped in after
shtuk.ready()or 800 ms; until then the old one stays on screen. - Hovering a sidebar row or a lens tab preloads its frame.
- The tree is polled every 5 s only while the page is visible and the sidebar shown; records are read only by lenses.
Contract additions (proposed for apps/cloud/CONTRACT.md)
-
Focus message (shell to panel frames). The shell posts to every frame shown in the right panel, after it is ready and whenever the focused main view changes:
{ type: 'focus', path: '/leads/lead-1.md' } // path: string | null (nothing open)The panel frame's first path is also in its URL (
?path=), soshtuk.pathis right before the first message.lens.jsdoes not route this message today, so a panel lens listens itself:window.addEventListener('message', e => e.source === parent && e.data.type === 'focus' && ...). Proposal for lens.js: route it toshtuk.on('focus', fn)and updateshtuk.path. -
Panel slot. A package contributes a panel lens with
slot: panel:contributes: - {lens: props, file: props.html, title: "Свойства", for: Record, slot: panel}space.infolists contributions ascontributions: [{package, lens, file, title, for?, slot}](slotdefaults tomain). Ifcontributionsis absent, the shell takeslensesentries withslot: "panel". Lenses with another slot thanmainnever appear as main lenses. -
Settings block in package.md.
settings: - {key: tabs, kind: bool, label: "Вкладки", default: true} - {key: panel, kind: bool, label: "Правая панель", default: true} - {key: sidebarWidth, kind: select, label: "Ширина боковой панели", default: normal, options: [narrow, normal, wide]}kindisboolorselect(optionsrequired forselect). Until a settings package exists, the value islocalStorage['studio.<key>'], falling back todefault. -
Open with a mode (optional field). The shell accepts
{type: 'open', path, mode}withmode: 'here' | 'tab' | 'split'(absent meanshere).lens.jssends no mode today, so a click in a table lens opens in the current tab; a modifier-click in a lens needsshtuk.open(path, {mode})in lens.js (proposal, not done: lens.js is not forked here).