ShtukbaseStandard
файл пакета→ .shtukbase/packages/layout-studio/README.md

README.md

89 строк, 4.9 КБ.

Этот текст ещё не переведён. Ниже английский оригинал.

  1. # layout-studio
  2. A second, richer layout for the prototype cloud app: pages open as tabs, the main area splits in
  3. two, and a resizable right panel holds lenses contributed to the `panel` slot. Lenses are unchanged:
  4. they link `/_pkg/layout-basic/lens.js` and work in both layouts.
  5. Files: `shell.html`, `shell.css`, `shell.js` (served at `/`), `package.md` (with the `settings:`
  6. block), `test/fake-host.ts`, `test/props-lens.html` (the demo panel lens "Свойства").
  7. Run: `bun apps/standard/packages/layout-studio/test/fake-host.ts 4377` (add `CACHE=long` to send
  8. `Cache-Control: public, max-age=31536000, immutable` for `/_pkg` and `/_kit`, as real hosts do).
  9. ## Behaviour
  10. - Sidebar click opens the page in the focused side's current tab; Cmd/Ctrl-click or middle-click
  11. opens a new tab; Alt-click opens it on the right half (split). Opening a page that is already open
  12. focuses its tab.
  13. - Tabs: click focuses, × or middle-click closes. With the `tabs` setting off there is one view.
  14. - Split: the button in the top bar (or Alt-click) opens the right half; × on its header closes it.
  15. The focused side is the one last clicked (the shell watches `document.activeElement`); the crumbs,
  16. the lens switch and the right panel follow it.
  17. - Right panel: its own tab strip, one tab per panel contribution. Resize edge on its left: drag,
  18. arrow keys (16 px), Home or double-click resets to 320 px; limits 240..560 px and at least 480 px
  19. stay for the document; the width is kept in `localStorage['studio.panelWidth']`.
  20. - Settings popover (top bar): flips the settings live; values in `localStorage['studio.<key>']`,
  21. defaults from `package.md` (fetched once at boot, in parallel with `space.info` and `tree`).
  22. ## URL (all view state; reload and back/forward restore it)
  23. `/?t=<lens>:<path>&t=...&a=<active tab index>&s=<lens>:<path>&f=R&p=<panel lens id>`
  24. - `t` once per tab, in order; `<lens>` may be empty (the first lens for the page's kind).
  25. - `a` omitted when 0; `s` is the right half; `f=R` when the right half has focus; `p` the panel tab.
  26. - `?path=&lens=` (layout-basic links, `lens.js` standalone `open`) is accepted as one tab.
  27. - Every change is a `pushState`; a focus change is a `replaceState`. The last URL is also kept in
  28. `localStorage['studio.last']` and used when `/` is opened bare.
  29. ## Caching
  30. - All frames sit in one stage and are placed by class (`L`, `R`), so a frame is never moved in the
  31. DOM (moving reloads it). Frames of open tabs and of the split stay alive; any other frame (closed
  32. tabs, hover preloads, other lenses) goes to an LRU of 8.
  33. - A frame is swapped in after `shtuk.ready()` or 800 ms; until then the old one stays on screen.
  34. - Hovering a sidebar row or a lens tab preloads its frame.
  35. - The tree is polled every 5 s only while the page is visible and the sidebar shown; records are
  36. read only by lenses.
  37. ## Contract additions (proposed for apps/cloud/CONTRACT.md)
  38. 1. **Focus message (shell to panel frames).** The shell posts to every frame shown in the right
  39. panel, after it is ready and whenever the focused main view changes:
  40. ```js
  41. { type: 'focus', path: '/leads/lead-1.md' } // path: string | null (nothing open)
  42. ```
  43. The panel frame's first path is also in its URL (`?path=`), so `shtuk.path` is right before the
  44. first message. `lens.js` does not route this message today, so a panel lens listens itself:
  45. `window.addEventListener('message', e => e.source === parent && e.data.type === 'focus' && ...)`.
  46. Proposal for lens.js: route it to `shtuk.on('focus', fn)` and update `shtuk.path`.
  47. 2. **Panel slot.** A package contributes a panel lens with `slot: panel`:
  48. ```yaml
  49. contributes:
  50. - {lens: props, file: props.html, title: "Свойства", for: Record, slot: panel}
  51. ```
  52. `space.info` lists contributions as
  53. `contributions: [{package, lens, file, title, for?, slot}]` (`slot` defaults to `main`). If
  54. `contributions` is absent, the shell takes `lenses` entries with `slot: "panel"`. Lenses with
  55. another slot than `main` never appear as main lenses.
  56. 3. **Settings block in package.md.**
  57. ```yaml
  58. settings:
  59. - {key: tabs, kind: bool, label: "Вкладки", default: true}
  60. - {key: panel, kind: bool, label: "Правая панель", default: true}
  61. - {key: sidebarWidth, kind: select, label: "Ширина боковой панели", default: normal, options: [narrow, normal, wide]}
  62. ```
  63. `kind` is `bool` or `select` (`options` required for `select`). Until a settings package exists,
  64. the value is `localStorage['studio.<key>']`, falling back to `default`.
  65. 4. **Open with a mode (optional field).** The shell accepts `{type: 'open', path, mode}` with
  66. `mode: 'here' | 'tab' | 'split'` (absent means `here`). `lens.js` sends no mode today, so a click
  67. in a table lens opens in the current tab; a modifier-click in a lens needs
  68. `shtuk.open(path, {mode})` in lens.js (proposal, not done: lens.js is not forked here).