docs: the panel in the framework (what an app supplies, which sections it gets, words, native commands)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
CRTkafa 2026-09-30 14:03:41 +07:00
parent ad2a3ad375
commit 94ca44edad
3 changed files with 91 additions and 4 deletions

View file

@ -187,6 +187,71 @@ features an app turns on `settings_get`, `column_configure`, `workspaces_*`, `sy
listens to `tab-state`, `tab-open`, `tab-shortcut`, `link-drag`, `open-panel`, `profiles-changed`, listens to `tab-state`, `tab-open`, `tab-shortcut`, `link-drag`, `open-panel`, `profiles-changed`,
`tab-commands`, `dev-event`, `update-status`, `tab-still` and `clipboard-changed`. `tab-commands`, `dev-event`, `update-status`, `tab-still` and `clipboard-changed`.
## The panel
`packages/shell/src/panel` (`waybetter/shell/panel`) is an app's own tab in the shell: a home page,
Appearance (the theme gallery, customization, account and pane themes, downloaded fonts, theme
import/export) and the Theme Builder (undo/redo, a palette from three colors, a contrast report, a
font per role with the Google Fonts browser), plugins and custom CSS, the Store, Make (example
plugins, the plugin UI kit, the theme API, bundled docs), accounts, Power User (deck settings),
settings (language, links and session, keyword alerts, the media panel), backup and sync, developer
mode, updates, and a search across every setting. It lives in the shell package, next to the frame
it renders in: it uses the frame's stores (profiles, decks, themes, sync, developer mode), its
native bridge and its language, so `createShell` comes first.
```tsx
import { createPanel, type PanelSite } from 'waybetter/shell/panel';
const panel: PanelSite = { brand: { name: 'wayBetter', logo }, home, themes, sections, order, make,
store, languages, settings, power, backup: true, updates: true };
const Panel = createPanel(panel);
const Shell = createShell({ ...site, panel: { id: 'app', title: 'wayBetter', component: Panel } }, options);
```
What the app supplies (`panel/site.ts`, every field documented there):
- `brand` and `home`: the header and the home page's words (kicker, title, lede, chips, actions,
highlight cards, the About block), `version()` for its chip;
- `sections` and `order`: its own sections (a label, an icon path, a component that gets `notify`
and `openSection`; `searchable` ones also show in the settings search), placed among the built-in
ones. X adds Tweaks, Drafts and My Space;
- `themes`: its theme store and catalog (`createThemeStore`, `createThemeCatalog`), accent swatches,
the **preview** component (a miniature of the site drawn from a theme document, used by the gallery
and the builder), the site font's name, the palette a draft starts from, and for Make's theme view
`resolved(choice, mode)` with the site's own display modes;
- `make`: example plugins, an example theme file and bundled Markdown docs;
- `store`: the install controller (the Store section, and removing a plugin from the list);
- `languages`: the language list and state (`createLanguage`, `frame/language.ts`);
- `settings`, `power`, `cssExamples`: keyword alerts, extra settings rows, which column flags and
which memory measure Power User lists, placeholder CSS with the site's selectors.
A built-in section shows only when the app serves what it needs: Appearance, the Theme Builder and
the Store with `themes` (and `store`), Make with `make`, Power User with `site.deck`, backup with
`backup` (its sync half with the frame's `sync` feature), Developer with the frame's `developer`
feature, Updates with `updates`. An app with nothing but plugins gets Home, Plugins, Accounts and
Settings (this is what `npm create waybetter app` generates).
Building blocks for the app's own sections: the panel's controls (`Section`, `Row`, `Toggle`,
`Segmented`, `Select`, `Slider`, `ColorField`, `Button`, `Badge`, ...; `panel/controls`), the
feature toggles (`useFeatures` + `FeatureGroups` over `features_get/set`: the app names its flags
and groups, its catalog has `features.<flag>.label` and `.description`), and `compareLines`.
The panel's words are `wb.*` messages too (English source in `panel/panelMessages.ts`, translator
notes in `locales/en.meta.json`). Three families of keys stay the app's, by convention, because
they name its own things: `plugin.<file>.name|description` (its bundled plugins),
`theme.<id>.description` (its built-in themes) and `features.*` (its tweaks).
Native commands the panel calls: the host's `plugins_list`, `plugin_set_enabled`,
`plugins_open_folder`, `custom_css_get/set`, `features_get/set`, `settings_get/set`,
`profiles_*` and `open_external_url`, and for what the app turns on `alerts_get/set`,
`media_get/set`/`gallery_add_folder`/`clip_remove`, `backup_*`, `sync_*`, `dev_*`, the theme
store's commands and `gfonts_*`, `install_records`/`install_forget`/`plugin_remove`/`store_catalog`,
`app_ready`/`update_status`/`apply_update`.
The Google Fonts list the font browser shows is an offline snapshot
(`panel/fonts/googleFontsCatalog.json`; `packages/shell/scripts/google-fonts-catalog.mjs`
regenerates it). The app never fetches the list, only the font files the owner picks (natively).
## The site adapter ## The site adapter
A site adapter is three small, explicit things. A site adapter is three small, explicit things.

View file

@ -1,6 +1,14 @@
# shell (internal) # shell (internal)
Sources of `waybetter/shell/*`: the shell models, the Store screens and the shell frame Sources of `waybetter/shell/*`: the shell models, the Store screens, the shell frame (`src/frame`,
(`src/frame`, `createShell`). Published as part of the [`waybetter`](../waybetter/README.md) package; `createShell`) and the panel (`src/panel`, `createPanel`: the app's own tab). Published as part of
not published on its own. The repository README's "The shell frame" section describes what an app the [`waybetter`](../waybetter/README.md) package; not published on its own. The repository README's
supplies. "The shell frame" and "The panel" sections describe what an app supplies.
The panel is here rather than in a package of its own because it is drawn inside the frame and
shares its state: the frame's profile, deck, theme, sync and developer-mode stores, its native
bridge and its language. It imports the theme document model from `../runtime` by source path;
the package build (`packages/waybetter/scripts/build.mjs`) points those imports at `dist/runtime`.
`scripts/google-fonts-catalog.mjs` regenerates the font browser's offline Google Fonts list
(`src/panel/fonts/googleFontsCatalog.json`).

View file

@ -88,8 +88,22 @@ createRoot(document.getElementById('root')!).render(<Shell/>);
- `i18n`: the app's `createI18n` instance with `waybetter/locales/*.json` merged in; the frame's words are `wb.*` messages in 51 languages. - `i18n`: the app's `createI18n` instance with `waybetter/locales/*.json` merged in; the frame's words are `wb.*` messages in 51 languages.
- `bootScript()` (`frame/boot`): the first-frame `boot.js` (the last theme's chrome colors before the modules load). - `bootScript()` (`frame/boot`): the first-frame `boot.js` (the last theme's chrome colors before the modules load).
- `installPreviewMocks(handlers)`: native commands answered from memory, for development previews in a plain browser. - `installPreviewMocks(handlers)`: native commands answered from memory, for development previews in a plain browser.
- `createLanguage(options)` (`frame/language`): which language the app speaks (follow the site, follow the system, or one language), switched live and handed to native code and site tabs (`i18n_set`); `createAppI18n(options)` (`frame/appI18n`): the app's i18n instance with typed keys, `useT`, dates and numbers.
- Everything else is exported for apps that build their own settings on it: the shared state (`shell`, `setOverlay`, `scheduleSync`), stores (decks, workspaces, sync, developer mode), models (palette, accounts, workspaces, backup, media) and hooks. - Everything else is exported for apps that build their own settings on it: the shared state (`shell`, `setOverlay`, `scheduleSync`), stores (decks, workspaces, sync, developer mode), models (palette, accounts, workspaces, backup, media) and hooks.
**Panel** (`waybetter/shell/panel`, modules also as `waybetter/shell/panel/*`, styles as `waybetter/shell/panel/*.css`)
```tsx
import { createPanel, type PanelSite } from 'waybetter/shell/panel';
const Panel = createPanel({ brand: { name: 'wayBetter', logo }, home, themes, sections, make, languages });
const Shell = createShell({ ...site, panel: { id: 'app', title: 'wayBetter', component: Panel } }, options);
```
- The app's own tab: home, Appearance and the Theme Builder (with the Google Fonts browser), plugins and custom CSS, the Store, Make, accounts, Power User, settings, backup and sync, developer mode, updates, and a search across every setting. Each section shows only when the app serves what it needs.
- `PanelSite` (`panel/site`): the brand and the home page's words, the app's own `sections` and their `order`, `themes` (the theme store and catalog, the preview component a theme document is drawn in, the site font), `make` (example plugins, an example theme, bundled docs), `store`, `languages`, and what its native side serves (`settings.alerts`, `backup`, `updates`).
- For the app's own sections: the panel's controls (`panel/controls`: `Section`, `Row`, `Toggle`, `Segmented`, `Select`, `Slider`, `ColorField`, `Button`, ...), `useFeatures` and `FeatureGroups` (`panel/FeatureToggles`: on/off rows over the host's `features_get/set`), `compareLines`.
- The panel's words are `wb.*` messages in 51 languages (`waybetter/locales/*.json`; translator notes in `waybetter/locales/en.meta.json`).
**Command line** **Command line**
- `waybetter store build --config store.config.mjs`: builds an app's part of the shared store folder (its items only, validated with the apps' own rules). - `waybetter store build --config store.config.mjs`: builds an app's part of the shared store folder (its items only, validated with the apps' own rules).