shell: the shell frame, createShell(site) (moved from wayBetter for X)

packages/shell/src/frame (waybetter/shell/frame): the whole shell of an app. An app describes its
site (ShellSite: names and pages, account rules, search, address chips and completions, its panel
tab, the new-tab page, palette items, deck column kinds and flags and an optional compose dock, the
media panel's composer rule, a theme store, overlays, the native features it serves) and passes
its Tauri API and i18n instance; createShell returns the root component.

- Shell.tsx: dockview host (tabs in the titlebar row, splits, drag-link drops, shortcuts, context
  menu, deck back-and-forth, session restore, workspace on start, overlay raise); state.ts (pane
  placeholders, tabs_sync one-in-flight via syncGate, shell_raise layer, profiles, layout).
- WebPanel (address bar), NewTabPage, CommandPalette + paletteModel (frame groups; site items),
  DeckView + AddColumnDialog + deckStore (site column kinds), PaneTheme + themeStore
  (createThemeStore over the app's ThemeAdapter) + chromeTheme (ChromeTheme input) + themeScopes,
  Titlebar + TitlebarExtras + icons + brand (wB mark data URI), AccountSwitcher + accountModel,
  workspaces + workspaceModel, backupModel, syncHost, devHost + devModel, pluginCommandStore,
  MediaPanel + mediaModel, searchInput, hooks, bridge (installPreviewMocks), i18n, boot.ts
  (bootScript: the first-frame boot.js), CSS themed with --wb-* tokens.
- paneModel: paneVisibility, raiseSupported, cssRgb; deckModel: isSourcePage.
- Includes the live-QA titlebar fix (dock ResizeObserver + rAF titlebar marks, dock sized by its
  insets).
- tests/frame.test.ts: every frame key has English and is used, palette order with a site,
  address fallback, layout gate, boot script, chrome variables, switcher rules, workspaces,
  deck settings with site flags.
- npm package 0.4.0: exports ./shell/frame, ./shell/frame/*, ./shell/frame/*.css (copied by the
  build); dockview and acorn optional peers; root devDependencies dockview, acorn.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
CRTkafa 2026-09-29 12:47:10 +07:00
parent 37e3d8e5fc
commit 60faed66be
49 changed files with 6442 additions and 6 deletions

View file

@ -0,0 +1,55 @@
// The wayBetter shell frame: `createShell(site, options)` gives an app the whole shell (tabs in the
// titlebar row, splits, the smart address bar, the new-tab page, the command palette, the account
// switcher, decks of site columns, workspaces, developer mode and sync chips, the media panel,
// pane themes, overlays and the native layout sync). The app describes its site (`ShellSite`) and
// passes its Tauri API and i18n instance; styles come with the components (`--wb-*` tokens).
//
// const Shell = createShell(site, { native: { invoke, listen, currentWindow: getCurrentWindow }, i18n });
// createRoot(root).render(<Shell/>);
import type { ComponentType } from 'react';
import { setNative, type NativeApi } from './bridge.ts';
import { decks, defaultDeckSettings } from './deckStore.ts';
import { setShellI18n, setTextDefaults, type ShellI18n } from './i18n.ts';
import Shell, { setDevBuild } from './Shell.tsx';
import { configureSite, type ShellSite } from './site.ts';
import { probeLayer, shell } from './state.ts';
export type ShellOptions = {
/** The app's Tauri API: `invoke` and `listen` from @tauri-apps/api, and `getCurrentWindow`. */
native: NativeApi;
/** The app's i18n instance (waybetter/i18n `createI18n`, the framework catalogs merged in). */
i18n: ShellI18n;
/** A development build (keeps the devtools shortcut). */
dev?: boolean;
};
/**
* Sets the site and the app's native API and language for every frame module, and returns the
* shell's root component. Call once, before anything of the frame renders (the app's own panel
* may render the frame's pieces, e.g. in a preview, without the shell).
*/
export function createShell(site: ShellSite, options: ShellOptions): ComponentType {
setNative(options.native);
setShellI18n(options.i18n);
setTextDefaults({ site: site.name });
configureSite(site);
setDevBuild(!!options.dev);
shell.homeUrl = site.homeUrl;
decks.settings = defaultDeckSettings();
probeLayer();
return Shell;
}
export type { ShellSite, DeckSite, PaletteSite, ColumnKind, ColumnFlag, DeckPreset, Completer, Suggestion } from './site.ts';
export { site, siteChanged } from './site.ts';
export type { NativeApi, Invoke, Listen, ShellWindow, MockHandler } from './bridge.ts';
export { invoke, listen, isNative, installPreviewMocks } from './bridge.ts';
export type { ShellI18n } from './i18n.ts';
export { setShellI18n } from './i18n.ts';
export { bootScript, BOOT_CACHE_KEY } from './boot.ts';
export { createThemeStore, type ThemeAdapter, type ThemeStore, type ThemeDoc, type InstalledFont, type Weights } from './themeStore.ts';
export { chromeVars, CHROME_VAR_NAMES, SHELL_UI_FONT, SHELL_MONO_FONT, type ChromeTheme } from './chromeTheme.ts';
export { shell, setOverlay, scheduleSync, flushSync, isWeb, tabAction, setProfiles, type TabParams, type WebParams } from './state.ts';
export type { PaletteItem, PaletteAction, PaletteContext } from './paletteModel.ts';
export { Icon, Avatar, ICONS, type IconName } from './icons.tsx';