# @embedpdf/core-ui — . AddItemOptions [InterfaceDeclaration] (from packages/core/ui/src/layout.ts): export interface AddItemOptions{ readonly to: string; readonly section?: SectionName; readonly group?: string; readonly before?: string; readonly after?: string; } BarChild [TypeAliasDeclaration] (from packages/core/ui/src/schema.ts): export type BarChild = BarItem | CustomItem | string; BarEdge [TypeAliasDeclaration] (from packages/core/ui/src/layout.ts): export type BarEdge = 'top' | 'bottom' | 'start' | 'end'; BarGroup [InterfaceDeclaration] (from packages/core/ui/src/schema.ts): export interface BarGroup{ readonly id: string; readonly labelKey?: string; readonly role?: 'buttons' | 'tabs'; readonly shed?: boolean; readonly collapse?: 'menu' | 'select'; readonly importance?: Importance; readonly dependent?: boolean; readonly items: readonly BarChild[]; } BarItem [InterfaceDeclaration] (from packages/core/ui/src/schema.ts): export interface BarItem{ readonly command: string; readonly variants?: readonly Variant[]; readonly importance?: Importance; readonly emphasis?: Emphasis; } BarPlace [TypeAliasDeclaration] (from packages/core/ui/src/layout.ts): export type BarPlace = | BarEdge |{ readonly edge: BarEdge; readonly before?: string; readonly after?: string} | FloatPlace |{ readonly with: string} |{ readonly at: SelectionTarget} |{ readonly panel: string} ; BarSchema [InterfaceDeclaration] (from packages/core/ui/src/schema.ts): export interface BarSchema{ readonly id: string; readonly sections: BarSections; } BarSections [InterfaceDeclaration] (from packages/core/ui/src/schema.ts): export interface BarSections{ readonly start?: readonly BarGroup[]; readonly center?: readonly BarGroup[]; readonly end?: readonly BarGroup[]; } CollapsedGroupView [InterfaceDeclaration] (from packages/core/ui/src/toolbar-layout.ts): export interface CollapsedGroupView{ readonly id: string; readonly labelKey?: string; readonly collapse: 'menu' | 'select'; readonly role: 'buttons' | 'tabs'; readonly commands: readonly Command[]; execute(id: string): void; } CompileBarOptions [InterfaceDeclaration] (from packages/core/ui/src/layout-compile.ts): export interface CompileBarOptions{ readonly omit?: ReadonlySet; } CustomItem [InterfaceDeclaration] (from packages/core/ui/src/schema.ts): export interface CustomItem{ readonly slot: string; readonly variants?: readonly string[]; readonly terminal?: string; readonly importance?: Importance; readonly grow?: boolean; } CustomSlotContext [InterfaceDeclaration] (from packages/core/ui/src/toolbar-layout.ts): export interface CustomSlotContext{ layer: 'live' | 'measure'; measure: (length: number) => void; } DEFAULT_IMPORTANCE [VariableDeclaration] (from packages/core/ui/src/schema.ts): DEFAULT_IMPORTANCE: Importance = 3 EXPANDED_MIN_WIDTH_PX [VariableDeclaration] (from packages/core/ui/src/layout.ts): EXPANDED_MIN_WIDTH_PX = 1024 Emphasis [TypeAliasDeclaration] (from packages/core/ui/src/schema.ts): export type Emphasis = 'primary'; FLOAT_POSITIONS [VariableDeclaration] (from packages/core/ui/src/layout-compile.ts): FLOAT_POSITIONS: readonly FloatPosition[] = [ 'top-start', 'top', 'top-end', 'start', 'end', 'bottom-start', 'bottom', 'bottom-end', ] FitMetrics [InterfaceDeclaration] (from packages/core/ui/src/solver.ts): export interface FitMetrics{ unit(key: string, variant: string): number | undefined; groupCollapsed(groupId: string): number | undefined; groupTrigger(groupId: string): number | undefined; readonly overflowTrigger: number; readonly gap: number; readonly separator: number; } FitResult [InterfaceDeclaration] (from packages/core/ui/src/solver.ts): export interface FitResult{ readonly units: ReadonlyMap; readonly groups: ReadonlyMap; readonly hasOverflow: boolean; readonly length: number; readonly complete: boolean; } FloatPlace [InterfaceDeclaration] (from packages/core/ui/src/layout.ts): export interface FloatPlace{ readonly float: FloatPosition; readonly hideWhenIdle?: boolean; } FloatPosition [TypeAliasDeclaration] (from packages/core/ui/src/layout.ts): export type FloatPosition = | 'top-start' | 'top' | 'top-end' | 'start' | 'end' | 'bottom-start' | 'bottom' | 'bottom-end'; GroupAssignment [InterfaceDeclaration] (from packages/core/ui/src/solver.ts): export interface GroupAssignment{ readonly shedCount: number; readonly collapsed: boolean; readonly overflowed: boolean; } GroupDisclosureView [InterfaceDeclaration] (from packages/core/ui/src/toolbar-layout.ts): export interface GroupDisclosureView{ readonly id: string; readonly labelKey?: string; readonly role: 'buttons' | 'tabs'; readonly commands: readonly Command[]; execute(id: string): void; } Importance [TypeAliasDeclaration] (from packages/core/ui/src/schema.ts): export type Importance = 1 | 2 | 3 | 4 | 5; KeyStroke [InterfaceDeclaration] (from packages/core/ui/src/shortcuts.ts): export interface KeyStroke{ readonly key: string; readonly code?: string; readonly ctrlKey: boolean; readonly metaKey: boolean; readonly altKey: boolean; readonly shiftKey: boolean; } Layout [InterfaceDeclaration] (from packages/core/ui/src/layout.ts): export interface Layout{ place(bar: string, place: BarPlace): Layout; addBar(id: string, bar: LayoutBar): Layout; removeBar(ids: string | readonly string[]): Layout; add(item: LayoutItem, options: AddItemOptions): Layout; remove(ids: string | readonly string[], options: RemoveItemOptions): Layout; replace(id: string, item: LayoutItem): Layout; addMenu(id: string, sections: LayoutMenu): Layout; addPanel(id: string, panel: LayoutPanel): Layout; panel(id: string, changes: LayoutPanelPatch): Layout; panels(changes: LayoutPanelPatch): Layout; removePanel(id: string): Layout; tabs(visibility: TabsVisibility): Layout; toJSON(): LayoutData; } LayoutBar [InterfaceDeclaration] (from packages/core/ui/src/layout.ts): export interface LayoutBar{ readonly place: BarPlace; readonly mode?: string; readonly title?: string; readonly titleKey?: string; readonly start?: LayoutSection; readonly center?: LayoutSection; readonly end?: LayoutSection; } LayoutCommandItem [InterfaceDeclaration] (from packages/core/ui/src/layout.ts): export interface LayoutCommandItem{ readonly command: string; readonly variants?: readonly Variant[]; readonly importance?: Importance; readonly emphasis?: Emphasis; } LayoutCustomItem [InterfaceDeclaration] (from packages/core/ui/src/layout.ts): export interface LayoutCustomItem{ readonly custom: string; readonly command?: string; readonly variants?: readonly string[]; readonly importance?: Importance; readonly grow?: boolean; } LayoutData [InterfaceDeclaration] (from packages/core/ui/src/layout.ts): export interface LayoutData{ readonly bars?: Readonly>; readonly menus?: Readonly>; readonly panels?: Readonly>; readonly tabs?: TabsVisibility; } LayoutEnv [InterfaceDeclaration] (from packages/core/ui/src/layout.ts): export interface LayoutEnv{ readonly size: ViewerSize; readonly width: number; readonly touch: boolean; readonly dir: 'ltr' | 'rtl'; } LayoutFunction [TypeAliasDeclaration] (from packages/core/ui/src/layout.ts): export type LayoutFunction = (layout: Layout, env: LayoutEnv) => Layout | LayoutData; LayoutGroup [TypeAliasDeclaration] (from packages/core/ui/src/layout.ts): export type LayoutGroup = readonly LayoutItem[] | LayoutGroupObject; LayoutGroupObject [InterfaceDeclaration] (from packages/core/ui/src/layout.ts): export interface LayoutGroupObject{ readonly id?: string; readonly items: readonly LayoutItem[]; readonly collapse?: 'menu' | 'select'; readonly shed?: boolean; readonly importance?: Importance; readonly titleKey?: string; readonly dependent?: boolean; } LayoutItem [TypeAliasDeclaration] (from packages/core/ui/src/layout.ts): export type LayoutItem = string | LayoutCommandItem | LayoutCustomItem; LayoutKnownIds [InterfaceDeclaration] (from packages/core/ui/src/layout-validate.ts): export interface LayoutKnownIds{ readonly commands: Iterable; readonly hasCommand?: (id: string) => boolean; } LayoutMenu [TypeAliasDeclaration] (from packages/core/ui/src/layout.ts): export type LayoutMenu = readonly LayoutMenuSection[]; LayoutMenuSection [TypeAliasDeclaration] (from packages/core/ui/src/layout.ts): export type LayoutMenuSection = | readonly string[] |{ readonly title?: string; readonly titleKey?: string; readonly items: readonly string[]; } ; LayoutOption [TypeAliasDeclaration] (from packages/core/ui/src/layout.ts): export type LayoutOption = Layout | LayoutData | LayoutFunction; LayoutPanel [InterfaceDeclaration] (from packages/core/ui/src/layout.ts): export interface LayoutPanel{ readonly side?: 'start' | 'end'; readonly title?: string; readonly titleKey?: string; readonly icon?: string; readonly present?: PanelPresentation | PanelPresentationBySize; readonly width?: number | PanelWidth; readonly resizable?: boolean; readonly open?: boolean; readonly closable?: boolean; } LayoutPanelPatch [TypeAliasDeclaration] (from packages/core/ui/src/layout.ts): export type LayoutPanelPatch = Partial; LayoutSection [TypeAliasDeclaration] (from packages/core/ui/src/layout.ts): export type LayoutSection = readonly (LayoutGroup | LayoutItem)[]; LiveGroup [InterfaceDeclaration] (from packages/core/ui/src/toolbar-layout.ts): export interface LiveGroup{ readonly id: string; readonly parts: readonly ToolbarPart[]; } LiveSection [InterfaceDeclaration] (from packages/core/ui/src/toolbar-layout.ts): export interface LiveSection{ readonly name: 'start' | 'center' | 'end'; readonly groups: readonly LiveGroup[]; readonly grows: boolean; readonly spacing: SectionSpacing; } MEDIUM_MIN_WIDTH_PX [VariableDeclaration] (from packages/core/ui/src/layout.ts): MEDIUM_MIN_WIDTH_PX = 600 MODES_GROUP [VariableDeclaration] (from packages/core/ui/src/layout-compile.ts): MODES_GROUP = 'modes' MenuSection [InterfaceDeclaration] (from packages/core/ui/src/layout-compile.ts): export interface MenuSection{ readonly title?: string; readonly titleKey?: string; readonly items: readonly string[]; } NormalizedBar [InterfaceDeclaration] (from packages/core/ui/src/schema.ts): export interface NormalizedBar{ readonly id: string; readonly sections: readonly NormalizedSection[]; } NormalizedGroup [InterfaceDeclaration] (from packages/core/ui/src/schema.ts): export interface NormalizedGroup{ readonly id: string; readonly labelKey?: string; readonly role: 'buttons' | 'tabs'; readonly shed: boolean; readonly collapse?: 'menu' | 'select'; readonly importance: Importance; readonly dependent: boolean; readonly units: readonly NormalizedUnit[]; } NormalizedSection [InterfaceDeclaration] (from packages/core/ui/src/schema.ts): export interface NormalizedSection{ readonly name: 'start' | 'center' | 'end'; readonly groups: readonly NormalizedGroup[]; } NormalizedUnit [TypeAliasDeclaration] (from packages/core/ui/src/schema.ts): export type NormalizedUnit = |{ readonly kind: 'command'; readonly key: string; readonly command: string; readonly variants: readonly string[]; readonly importance: Importance; } |{ readonly kind: 'custom'; readonly key: string; readonly slot: string; readonly variants: readonly string[]; readonly terminal: string | null; readonly importance: Importance; readonly grow: boolean; } ; OmissionCommand [InterfaceDeclaration] (from packages/core/ui/src/layout-compile.ts): export interface OmissionCommand{ readonly visible: boolean; readonly menu?: string; } OverflowMenuView [InterfaceDeclaration] (from packages/core/ui/src/toolbar-layout.ts): export interface OverflowMenuView{ readonly sections: readonly OverflowSection[]; readonly isOpen: boolean; close(): void; resolve(id: string): Command | null; execute(id: string): void; } OverflowRow [TypeAliasDeclaration] (from packages/core/ui/src/projection.ts): export type OverflowRow = |{ readonly kind: 'command'; readonly command: string} |{ readonly kind: 'submenu'; readonly command: string; readonly menu: string} ; OverflowSection [InterfaceDeclaration] (from packages/core/ui/src/projection.ts): export interface OverflowSection{ readonly labelKey?: string; readonly role?: 'radio'; readonly rows: readonly OverflowRow[]; } PINNED [VariableDeclaration] (from packages/core/ui/src/schema.ts): PINNED: Importance = 5 PanelPresentation [TypeAliasDeclaration] (from packages/core/ui/src/layout.ts): export type PanelPresentation = 'dock' | 'overlay' | 'sheet'; PanelPresentationBySize [InterfaceDeclaration] (from packages/core/ui/src/layout.ts): export interface PanelPresentationBySize{ readonly compact?: PanelPresentation; readonly medium?: PanelPresentation; readonly expanded?: PanelPresentation; } PanelWidth [InterfaceDeclaration] (from packages/core/ui/src/layout.ts): export interface PanelWidth{ readonly initial?: number; readonly min?: number; readonly max?: number; } ParsedShortcut [InterfaceDeclaration] (from packages/core/ui/src/shortcuts.ts): export interface ParsedShortcut{ readonly key: string; readonly mod: boolean; readonly ctrl: boolean; readonly meta: boolean; readonly alt: boolean; readonly shift: boolean; } RemoveItemOptions [InterfaceDeclaration] (from packages/core/ui/src/layout.ts): export interface RemoveItemOptions{ readonly from: string; } ResolveMenuTarget [TypeAliasDeclaration] (from packages/core/ui/src/projection.ts): export type ResolveMenuTarget = (commandId: string) =>{ menu?: string} | null; SectionName [TypeAliasDeclaration] (from packages/core/ui/src/layout.ts): export type SectionName = 'start' | 'center' | 'end'; SectionSpacing [TypeAliasDeclaration] (from packages/core/ui/src/toolbar-layout.ts): export type SectionSpacing = 'balance' | 'gap' | 'none'; SelectionTarget [TypeAliasDeclaration] (from packages/core/ui/src/layout.ts): export type SelectionTarget = 'selection' | 'annotation' | 'snapshot'; StripGroup [InterfaceDeclaration] (from packages/core/ui/src/projection.ts): export interface StripGroup{ readonly id: string; readonly labelKey?: string; readonly commands: readonly string[]; } StripView [InterfaceDeclaration] (from packages/core/ui/src/toolbar-layout.ts): export interface StripView{ readonly groups: readonly StripViewGroup[]; execute(id: string): void; } StripViewGroup [InterfaceDeclaration] (from packages/core/ui/src/toolbar-layout.ts): export interface StripViewGroup{ readonly id: string; readonly labelKey?: string; readonly commands: readonly Command[]; } TabsVisibility [TypeAliasDeclaration] (from packages/core/ui/src/layout.ts): export type TabsVisibility = 'always' | 'multiple' | 'never'; ToolbarCommand [InterfaceDeclaration] (from packages/core/ui/src/toolbar-layout.ts): export interface ToolbarCommand{ readonly id: string; readonly visible: boolean; } ToolbarLayout [InterfaceDeclaration] (from packages/core/ui/src/toolbar-layout.ts): export interface ToolbarLayout{ readonly sections: readonly LiveSection[]; readonly measured: readonly ToolbarPart[]; readonly hasOverflow: boolean; readonly overflow: readonly OverflowSection[]; } ToolbarLayoutInput [InterfaceDeclaration] (from packages/core/ui/src/toolbar-layout.ts): export interface ToolbarLayoutInput{ readonly bar: NormalizedBar; readonly resolve: (id: string) => Command | null; readonly unregistered: (id: string) => Command; readonly execute: (id: string) => void; readonly menuTarget: ResolveMenuTarget; readonly metrics: FitMetrics; readonly measureKey: ToolbarMeasureKeys; readonly containerLength: number; readonly orientation?: 'horizontal' | 'vertical'; } ToolbarMeasureKeys [InterfaceDeclaration] (from packages/core/ui/src/toolbar-layout.ts): export interface ToolbarMeasureKeys{ unit(unitKey: string, variant: string): string; group(groupId: string): string; groupTrigger(groupId: string): string; } ToolbarPart [TypeAliasDeclaration] (from packages/core/ui/src/toolbar-layout.ts): export type ToolbarPart = |{ readonly kind: 'command'; readonly key: string; readonly measureKey: string; readonly command: Command; readonly variant: string; readonly run: () => void; } |{ readonly kind: 'custom'; readonly key: string; readonly measureKey: string; readonly name: string; readonly variant: string; readonly terminal: Command | null; readonly runTerminal: () => void; readonly grow: boolean; } |{ readonly kind: 'collapsed'; readonly key: string; readonly measureKey: string; readonly view: CollapsedGroupView; } |{ readonly kind: 'disclosure'; readonly key: string; readonly measureKey: string; readonly view: GroupDisclosureView; } ; TreeKeyAction [TypeAliasDeclaration] (from packages/core/ui/src/tree-keys.ts): export type TreeKeyAction = |{ readonly type: 'focus'; readonly row: number} |{ readonly type: 'expand'; readonly rows: readonly number[]} |{ readonly type: 'collapse'; readonly row: number} |{ readonly type: 'activate'; readonly row: number} |{ readonly type: 'rename'; readonly row: number} |{ readonly type: 'delete'; readonly row: number} ; TreeKeyOptions [InterfaceDeclaration] (from packages/core/ui/src/tree-keys.ts): export interface TreeKeyOptions{ readonly editable?: boolean; } TreeKeyRow [InterfaceDeclaration] (from packages/core/ui/src/tree-keys.ts): export interface TreeKeyRow{ readonly depth: number; readonly hasChildren: boolean; readonly expanded: boolean; } UnitAssignment [TypeAliasDeclaration] (from packages/core/ui/src/solver.ts): export type UnitAssignment = |{ readonly kind: 'variant'; readonly variant: string} |{ readonly kind: 'shed'} |{ readonly kind: 'collapsed'} |{ readonly kind: 'overflow'} ; VIEW_MODE_COMMAND [VariableDeclaration] (from packages/core/ui/src/layout-compile.ts): VIEW_MODE_COMMAND = 'mode:view' Variant [TypeAliasDeclaration] (from packages/core/ui/src/schema.ts): export type Variant = 'icon+label' | 'icon' | 'label'; ViewerSize [TypeAliasDeclaration] (from packages/core/ui/src/layout.ts): export type ViewerSize = 'compact' | 'medium' | 'expanded'; barsAt [FunctionDeclaration] (from packages/core/ui/src/layout-compile.ts): export function barsAt(data: LayoutData, target: SelectionTarget): string[]{ return barsOf(data) .filter(([, bar]) => selectionOf(bar.place) === target) .map(([id]) => id); } barsFloating [FunctionDeclaration] (from packages/core/ui/src/layout-compile.ts): export function barsFloating(data: LayoutData, position: FloatPosition): string[]{ return barsOf(data) .filter(([, bar]) => floatOf(bar.place) === position) .map(([id]) => id); } barsInMode [FunctionDeclaration] (from packages/core/ui/src/layout-compile.ts): export function barsInMode(data: LayoutData, mode: string): string[]{ return barsOf(data) .filter(([, bar]) => bar.mode === mode) .map(([id]) => id); } barsInPanel [FunctionDeclaration] (from packages/core/ui/src/layout-compile.ts): export function barsInPanel(data: LayoutData, panel: string): string[]{ return barsOf(data) .filter(([, bar]) => panelOf(bar.place) === panel) .map(([id]) => id); } barsOnEdge [FunctionDeclaration] (from packages/core/ui/src/layout-compile.ts): export function barsOnEdge(data: LayoutData, edge: BarEdge): string[]{ const placed = barsOf(data).filter(([, bar]) => edgeOf(bar.place) === edge); const anchorOf = (place: BarPlace) => typeof place === 'object' && place !== null && 'edge' in place ? place.before !== undefined ?{ id: place.before, after: false} : place.after !== undefined ?{ id: place.after, after: true} : null : null; const stack = placed.filter(([, bar]) => anchorOf(bar.place) === null).map(([id]) => id); let pending = placed.filter(([, bar]) => anchorOf(bar.place) !== null); for (let placedOne = true; placedOne && pending.length > 0; ){ placedOne = false; pending = pending.filter(([id, bar]) =>{ const anchor = anchorOf(bar.place)!; const index = stack.indexOf(anchor.id); if (index === -1) return true; stack.splice(anchor.after ? index + 1 : index, 0, id); placedOne = true; return false; } ); } return [...stack, ...pending.map(([id]) => id)]; } barsWith [FunctionDeclaration] (from packages/core/ui/src/layout-compile.ts): export function barsWith(data: LayoutData, host: string): string[]{ return barsOf(data) .filter(([, bar]) => hostOf(bar.place) === host) .map(([id]) => id); } closestMatch [FunctionDeclaration] (from packages/core/ui/src/suggestions.ts): export function closestMatch(id: string, candidates: Iterable): string | null{ const reach = Math.min(3, Math.max(1, Math.floor(id.length / 3))); let best: string | null = null; let bestDistance = reach + 1; for (const candidate of candidates){ if (candidate === id) continue; const distance = editDistance(id, candidate); if (distance < bestDistance){ best = candidate; bestDistance = distance; } } return best; } commandOfUnit [VariableDeclaration] (from packages/core/ui/src/schema.ts): commandOfUnit = (unit: NormalizedUnit): string | null => unit.kind === 'command' ? unit.command : unit.terminal compileBar [FunctionDeclaration] (from packages/core/ui/src/layout-compile.ts): export function compileBar( data: LayoutData, id: string, options: CompileBarOptions ={ } , ): BarSchema | null{ const bar = data.bars?.[id]; if (typeof bar !== 'object' || bar === null) return null; const omit = options.omit ?? NOTHING; const used = new Set(); const uniqueId = (wanted: string): string =>{ let groupId = wanted; for (let count = 2; used.has(groupId); count++) groupId = `${ wanted} -${ count} `; used.add(groupId); return groupId; } ; const sections:{ -readonly [Name in SectionName]?: readonly BarGroup[]} ={ } ; for (const name of SECTION_NAMES){ const groups: BarGroup[] = []; entriesOf(bar, name).forEach((entry, index) =>{ const object = isGroupObject(entry) ? entry : null; const seen = new Set(); let items: LayoutItem[] = itemsOfEntry(entry).filter((item) =>{ if (!isLayoutItem(item)) return false; const itemId = itemIdOf(item); if (seen.has(itemId)) return false; seen.add(itemId); return typeof item === 'object' && 'custom' in item ? true : !omit.has(itemId); } ); const isModes = object?.id === MODES_GROUP; if (isModes) items = [...modeTabsOf(data, omit).filter((tab) => !seen.has(tab.command)), ...items]; if (items.length === 0) return; const group:{ -readonly [Key in keyof BarGroup]: BarGroup[Key]} ={ id: uniqueId(object?.id ?? `${ name} -${ index} `), items: items.map(toBarChild), } ; if (isModes) group.role = 'tabs'; if (object?.titleKey !== undefined) group.labelKey = object.titleKey; if (object?.shed !== undefined) group.shed = object.shed; if (object?.collapse !== undefined) group.collapse = object.collapse; if (object?.importance !== undefined) group.importance = object.importance; if (object?.dependent === true) group.dependent = true; groups.push(group); } ); if (groups.length > 0) sections[name] = groups; } return{ id, sections: sections as BarSections} ; } createLayout [FunctionDeclaration] (from packages/core/ui/src/layout.ts): export function createLayout(data: LayoutData ={ } ): Layout{ return layoutOf(data, []); } custom [FunctionDeclaration] (from packages/core/ui/src/schema.ts): export function custom( slot: string, terminal?: string, options?: Omit, ): CustomItem{ return terminal === undefined ?{ slot, ...options} :{ slot, terminal, ...options} ; } didYouMean [FunctionDeclaration] (from packages/core/ui/src/suggestions.ts): export function didYouMean(id: string, candidates: Iterable): string{ const match = closestMatch(id, candidates); return match === null ? '' : ` (did you mean "${ match} "?)`; } edgeOf [FunctionDeclaration] (from packages/core/ui/src/layout-compile.ts): export function edgeOf(place: BarPlace | undefined): BarEdge | null{ if (typeof place === 'string') return EDGES.includes(place) ? place : null; if (typeof place === 'object' && place !== null && 'edge' in place) return EDGES.includes(place.edge) ? place.edge : null; return null; } edgeStackOf [FunctionDeclaration] (from packages/core/ui/src/layout-compile.ts): export function edgeStackOf(data: LayoutData, edge: BarEdge): string[]{ return withRiders(data, barsOnEdge(data, edge)); } editDistance [FunctionDeclaration] (from packages/core/ui/src/suggestions.ts): export function editDistance(left: string, right: string): number{ if (left === right) return 0; let beforePrevious: number[] = []; let previous = Array.from({ length: right.length + 1} , (_, j) => j); for (let i = 1; i <= left.length; i++){ const current = [i]; for (let j = 1; j <= right.length; j++){ const cost = left[i - 1] === right[j - 1] ? 0 : 1; let distance = Math.min(previous[j]! + 1, current[j - 1]! + 1, previous[j - 1]! + cost); if (i > 1 && j > 1 && left[i - 1] === right[j - 2] && left[i - 2] === right[j - 1]){ distance = Math.min(distance, beforePrevious[j - 2]! + 1); } current.push(distance); } beforePrevious = previous; previous = current; } return previous[right.length]!; } filterBar [FunctionDeclaration] (from packages/core/ui/src/schema.ts): export function filterBar( bar: NormalizedBar, keep: (unit: NormalizedUnit) => boolean, ): NormalizedBar{ const shows = hasVisibleUnits(bar, keep); return{ id: bar.id, sections: bar.sections.map((section) => ({ name: section.name, groups: section.groups.map((group) => ({ ...group, units: shows ? group.units.filter((unit) => isStandaloneUnit(unit) || keep(unit)) : [], } )), } )), } ; } floatOf [FunctionDeclaration] (from packages/core/ui/src/layout-compile.ts): export function floatOf(place: BarPlace | undefined): FloatPosition | null{ return typeof place === 'object' && place !== null && 'float' in place && FLOAT_POSITIONS.includes(place.float) ? place.float : null; } floatStackOf [FunctionDeclaration] (from packages/core/ui/src/layout-compile.ts): export function floatStackOf(data: LayoutData, position: FloatPosition): string[]{ return withRiders(data, barsFloating(data, position)); } formatShortcut [FunctionDeclaration] (from packages/core/ui/src/shortcuts.ts): export function formatShortcut(shortcut: string, options:{ isMac: boolean} ): string{ const parsed = parseShortcut(shortcut); const named = KEY_NAMES[parsed.key]; const key = named ? named[options.isMac ? 0 : 1] : parsed.key.length === 1 ? parsed.key.toUpperCase() : capitalize(parsed.key); if (options.isMac){ const mods = [ parsed.ctrl ? '⌃' : '', parsed.alt ? '⌥' : '', parsed.shift ? '⇧' : '', parsed.meta || parsed.mod ? '⌘' : '', ].join(''); return `${ mods} ${ key} `; } const mods = [ parsed.ctrl || parsed.mod ? 'Ctrl' : '', parsed.meta ? 'Meta' : '', parsed.alt ? 'Alt' : '', parsed.shift ? 'Shift' : '', ].filter(Boolean); return [...mods, key].join('+'); } group [FunctionDeclaration] (from packages/core/ui/src/schema.ts): export function group( id: string, items: readonly BarChild[], options?: Omit, ): BarGroup{ return{ id, ...options, items} ; } groupMenuView [FunctionDeclaration] (from packages/core/ui/src/toolbar-layout.ts): export function groupMenuView( view: CollapsedGroupView | GroupDisclosureView, isOpen: boolean, close: () => void, ): OverflowMenuView{ return{ sections: [{ labelKey: view.labelKey, role: view.role === 'tabs' ? 'radio' : undefined, rows: view.commands.map((command) => ({ kind: 'command' as const, command: command.id} )), } , ], isOpen, close, resolve: (id) => view.commands.find((command) => command.id === id) ?? null, execute: (id) => view.execute(id), } ; } hasVisibleUnits [FunctionDeclaration] (from packages/core/ui/src/schema.ts): export function hasVisibleUnits( bar: NormalizedBar, keep: (unit: NormalizedUnit) => boolean, ): boolean{ return bar.sections.some((section) => section.groups.some( (group) => !group.dependent && group.units.some((unit) => isStandaloneUnit(unit) || keep(unit)), ), ); } hideWhenIdleOf [FunctionDeclaration] (from packages/core/ui/src/layout-compile.ts): export function hideWhenIdleOf(data: LayoutData, id: string): boolean | undefined{ const seen = new Set(); for (let current: string | null = id; current !== null && !seen.has(current); ){ seen.add(current); const place = data.bars?.[current]?.place; if (floatOf(place) !== null){ const hide: unknown = (place as FloatPlace).hideWhenIdle; return typeof hide === 'boolean' ? hide : undefined; } current = hostOf(place); } return undefined; } hostOf [FunctionDeclaration] (from packages/core/ui/src/layout.ts): export function hostOf(place: BarPlace | undefined): string | null{ return typeof place === 'object' && place !== null && 'with' in place ? place.with : null; } isLayout [FunctionDeclaration] (from packages/core/ui/src/layout.ts): export function isLayout(value: unknown): value is Layout{ return typeof value === 'object' && value !== null && states.has(value as Layout); } isStandaloneUnit [VariableDeclaration] (from packages/core/ui/src/schema.ts): isStandaloneUnit = (unit: NormalizedUnit): boolean => unit.kind === 'custom' && unit.terminal === null item [FunctionDeclaration] (from packages/core/ui/src/schema.ts): export function item(command: string, options?: Omit): BarItem{ return{ command, ...options} ; } itemCommandOf [FunctionDeclaration] (from packages/core/ui/src/layout.ts): export function itemCommandOf(item: LayoutItem): string | null{ if (typeof item === 'string') return item; if (typeof item !== 'object' || item === null) return null; return 'custom' in item ? (item.command ?? null) : item.command; } itemIdOf [FunctionDeclaration] (from packages/core/ui/src/layout.ts): export function itemIdOf(item: LayoutItem): string{ if (typeof item === 'string') return item; if (typeof item !== 'object' || item === null) return ''; return 'custom' in item ? item.custom : item.command; } layoutToolbar [FunctionDeclaration] (from packages/core/ui/src/toolbar-layout.ts): export function layoutToolbar( input: ToolbarLayoutInput, ): ToolbarLayout{ const{ resolve, execute, measureKey} = input; const resolveUnit = (unit: NormalizedUnit): Command | null =>{ const command = commandOfUnit(unit); return command === null ? null : resolve(command); } ; const visible = filterBar(input.bar, (unit) => resolveUnit(unit)?.visible === true); const bar = input.orientation === 'vertical' ? iconsOnly(visible) : visible; const fit = solve(bar, input.metrics, input.containerLength); const visibleCommands = (units: readonly NormalizedUnit[]): Command[] => units .map(resolveUnit) .filter((command): command is Command => command !== null && command.visible); const parts: PartBuilders ={ unit: (unit, variant) =>{ if (unit.kind === 'custom'){ return{ kind: 'custom', key: unit.key, measureKey: measureKey.unit(unit.key, variant), name: unit.slot, variant, terminal: resolveUnit(unit), runTerminal: () =>{ if (unit.terminal !== null) execute(unit.terminal); } , grow: unit.grow, } ; } const command = resolve(unit.command); return{ kind: 'command', key: unit.key, measureKey: measureKey.unit(unit.key, variant), command: command ?? input.unregistered(unit.command), variant, run: command ? () => execute(unit.command) : () =>{ } , } ; } , collapsed: (group) => ({ kind: 'collapsed', key: group.id, measureKey: measureKey.group(group.id), view:{ id: group.id, labelKey: group.labelKey, collapse: group.collapse ?? 'menu', role: group.role, commands: visibleCommands(group.units), execute, } , } ), disclosure: (group, allChildren) => ({ kind: 'disclosure', key: `${ group.id} ::trigger`, measureKey: measureKey.groupTrigger(group.id), view:{ id: group.id, labelKey: group.labelKey, role: group.role, commands: visibleCommands( group.units.filter((unit) => allChildren || fit.units.get(unit.key)?.kind === 'shed'), ), execute, } , } ), } ; return{ sections: spacedSections( SECTIONS.map((name) => liveSection(name, bar, fit, parts)), fit.hasOverflow, ), measured: measuredParts(bar, parts), hasOverflow: fit.hasOverflow, overflow: projectOverflow(bar, fit, input.menuTarget), } ; } matchShortcut [FunctionDeclaration] (from packages/core/ui/src/shortcuts.ts): export function matchShortcut( parsed: ParsedShortcut, stroke: KeyStroke, options:{ isMac: boolean} , ): boolean{ const wantCtrl = parsed.ctrl || (parsed.mod && !options.isMac); const wantMeta = parsed.meta || (parsed.mod && options.isMac); if (stroke.ctrlKey !== wantCtrl) return false; if (stroke.metaKey !== wantMeta) return false; if (stroke.altKey !== parsed.alt) return false; if (parsed.shift && !stroke.shiftKey) return false; const hasCase = parsed.key !== parsed.key.toUpperCase(); if (!parsed.shift && stroke.shiftKey && (parsed.key.length > 1 || hasCase)) return false; const key = stroke.key.toLowerCase(); if (key === parsed.key) return true; return ( parsed.key.length > 1 && stroke.code !== undefined && stroke.code.toLowerCase() === parsed.key ); } menuOf [FunctionDeclaration] (from packages/core/ui/src/layout-compile.ts): export function menuOf(data: LayoutData, id: string): readonly MenuSection[] | null{ const menu = data.menus?.[id]; if (!menu) return null; const commandsOf = (section: LayoutMenuSection) => [ ...new Set(itemsOfMenuSection(section).filter((item) => typeof item === 'string')), ]; return sectionsOfMenu(menu) .map((section: LayoutMenuSection): MenuSection =>{ if (Array.isArray(section) || typeof section !== 'object' || section === null) return{ items: commandsOf(section)} ; const titled = section as Exclude; const read:{ -readonly [Key in keyof MenuSection]: MenuSection[Key]} ={ items: commandsOf(section), } ; if (titled.title !== undefined) read.title = titled.title; if (titled.titleKey !== undefined) read.titleKey = titled.titleKey; return read; } ) .filter((section) => section.items.length > 0); } modeCommandOf [VariableDeclaration] (from packages/core/ui/src/layout-compile.ts): modeCommandOf = (mode: string): string => `mode:${ mode} ` modesOf [FunctionDeclaration] (from packages/core/ui/src/layout-compile.ts): export function modesOf(data: LayoutData): string[]{ const modes = new Set(); for (const [, bar] of barsOf(data)) if (typeof bar.mode === 'string' && bar.mode.length > 0) modes.add(bar.mode); return [...modes]; } normalizeBar [FunctionDeclaration] (from packages/core/ui/src/schema.ts): export function normalizeBar(bar: BarSchema): NormalizedBar{ const seen = new Set(); const groupIds = new Set(); const sections: NormalizedSection[] = []; for (const name of ['start', 'center', 'end'] as const){ const groups = bar.sections[name]; if (!groups || groups.length === 0) continue; sections.push({ name, groups: groups.map((group) =>{ if (groupIds.has(group.id)) throw new Error(`[ui-core] duplicate group in bar: ${ group.id} `); groupIds.add(group.id); const units = group.items.map((child) => normalizeChild(group, child, seen)); return{ id: group.id, labelKey: group.labelKey, role: group.role ?? 'buttons', shed: group.shed ?? false, collapse: group.collapse, importance: units.some(isStandaloneUnit) ? PINNED : (group.importance ?? DEFAULT_IMPORTANCE), dependent: group.dependent === true, units, } ; } ), } ); } return{ id: bar.id, sections} ; } omittedCommandsOf [FunctionDeclaration] (from packages/core/ui/src/layout-compile.ts): export function omittedCommandsOf( data: LayoutData, resolve: (id: string) => OmissionCommand | null, menuTarget: ResolveMenuTarget = resolve, ): string[]{ const reach = reachOf(data); const isVisible = (id: string) => resolve(id)?.visible === true; const omitted: string[] = []; for (const [mode, bars] of reach.modes){ const shows = bars.some((bar) => hasVisibleUnits(bar, (unit) =>{ const command = commandOfUnit(unit); return command !== null && isVisible(command); } ), ); if (!shows) omitted.push(modeCommandOf(mode)); } for (const button of reach.buttons){ const menu = menuTarget(button)?.menu; if (menu !== undefined && !(reach.menus.get(menu) ?? []).some(isVisible)) omitted.push(button); } return omitted.sort(); } panelCommandOf [VariableDeclaration] (from packages/core/ui/src/layout-compile.ts): panelCommandOf = (panel: string): string => `panel:${ panel} ` panelOf [FunctionDeclaration] (from packages/core/ui/src/layout.ts): export function panelOf(place: BarPlace | undefined): string | null{ return typeof place === 'object' && place !== null && 'panel' in place ? place.panel : null; } panelPresentationsOf [VariableDeclaration] (from packages/core/ui/src/layout.ts): panelPresentationsOf = ( present: PanelPresentation | PanelPresentationBySize, ): PanelPresentationBySize => typeof present === 'string' ?{ compact: present, medium: present, expanded: present} : present panelWidthFieldsOf [VariableDeclaration] (from packages/core/ui/src/layout.ts): panelWidthFieldsOf = (width: number | PanelWidth): PanelWidth => typeof width === 'number' ?{ initial: width} : width parseShortcut [FunctionDeclaration] (from packages/core/ui/src/shortcuts.ts): export function parseShortcut(shortcut: string): ParsedShortcut{ const tokens = shortcut.split('+').map((token) => token.trim()); const keyToken = tokens[tokens.length - 1] === '' ? '+' : tokens[tokens.length - 1]; const parsed ={ key: keyToken.toLowerCase(), mod: false, ctrl: false, meta: false, alt: false, shift: false, } ; for (const token of tokens.slice(0, -1)){ const modifier = token.toLowerCase(); if (modifier === '') continue; if (!MODIFIERS.has(modifier)) throw new Error(`[ui-core] unknown modifier "${ token} " in "${ shortcut} "`); if (modifier === 'mod') parsed.mod = true; else if (modifier === 'ctrl' || modifier === 'control') parsed.ctrl = true; else if (modifier === 'meta' || modifier === 'cmd' || modifier === 'command') parsed.meta = true; else if (modifier === 'alt' || modifier === 'option') parsed.alt = true; else parsed.shift = true; } if (parsed.key === '') throw new Error(`[ui-core] empty key in shortcut "${ shortcut} "`); return parsed; } projectOverflow [FunctionDeclaration] (from packages/core/ui/src/projection.ts): export function projectOverflow( bar: NormalizedBar, fit: FitResult, resolve: ResolveMenuTarget, ): OverflowSection[]{ const sections: OverflowSection[] = []; for (const section of bar.sections){ for (const group of section.groups){ const rows = group.units .filter((unit) => fit.units.get(unit.key)?.kind === 'overflow') .flatMap((unit) => projectUnit(unit, resolve)); if (rows.length === 0) continue; sections.push({ labelKey: group.labelKey, role: group.role === 'tabs' ? 'radio' : undefined, rows, } ); } } return sections; } projectShed [FunctionDeclaration] (from packages/core/ui/src/projection.ts): export function projectShed( group: NormalizedGroup, fit: FitResult, resolve: ResolveMenuTarget, ): OverflowRow[]{ return group.units .filter((unit) => fit.units.get(unit.key)?.kind === 'shed') .flatMap((unit) => projectUnit(unit, resolve)); } projectStrip [FunctionDeclaration] (from packages/core/ui/src/projection.ts): export function projectStrip( bar: NormalizedBar, visible: (command: string) => boolean, ): StripGroup[]{ const shown = filterBar(bar, (unit) =>{ const command = commandOfUnit(unit); return command !== null && visible(command); } ); const groups: StripGroup[] = []; for (const section of shown.sections){ for (const group of section.groups){ const commands = group.units .map(commandOfUnit) .filter((command): command is string => command !== null); if (commands.length === 0) continue; groups.push({ id: group.id, labelKey: group.labelKey, commands} ); } } return groups; } resolveLayout [FunctionDeclaration] (from packages/core/ui/src/layout.ts): export function resolveLayout( option: LayoutOption | undefined, defaults: Layout, env: LayoutEnv, ): Layout{ if (option === undefined) return defaults; if (typeof option === 'function'){ let result: unknown; try{ result = option(defaults, env); } catch (error){ const message = error instanceof Error ? error.message : String(error); return withLayoutWarning( defaults, `the layout function threw (${ message} ); showing the default layout`, ); } return toLayout(result, defaults, 'the layout function returned'); } return toLayout(option, defaults, 'layout is'); } sameLayoutEnv [VariableDeclaration] (from packages/core/ui/src/layout.ts): sameLayoutEnv = (left: LayoutEnv, right: LayoutEnv): boolean => left.size === right.size && left.width === right.width && left.touch === right.touch && left.dir === right.dir sameShortcut [FunctionDeclaration] (from packages/core/ui/src/shortcuts.ts): export function sameShortcut(left: string, right: string, options:{ isMac: boolean} ): boolean{ const keysOf = (shortcut: string) =>{ const parsed = parseShortcut(shortcut); return [ parsed.key, parsed.ctrl || (parsed.mod && !options.isMac), parsed.meta || (parsed.mod && options.isMac), parsed.alt, parsed.shift, ].join(' '); } ; return keysOf(left) === keysOf(right); } sameStripGroups [FunctionDeclaration] (from packages/core/ui/src/toolbar-layout.ts): export function sameStripGroups( left: readonly StripViewGroup[], right: readonly StripViewGroup[], sameCommand: (left: Command, right: Command) => boolean, ): boolean{ return ( left.length === right.length && left.every( (group, i) => group.id === right[i]!.id && group.commands.length === right[i]!.commands.length && group.commands.every((command, j) => sameCommand(command, right[i]!.commands[j]!)), ) ); } selectionOf [FunctionDeclaration] (from packages/core/ui/src/layout-compile.ts): export function selectionOf(place: BarPlace | undefined): SelectionTarget | null{ return typeof place === 'object' && place !== null && 'at' in place ? place.at : null; } sizeOf [FunctionDeclaration] (from packages/core/ui/src/layout.ts): export function sizeOf(widthPx: number): ViewerSize{ if (widthPx < MEDIUM_MIN_WIDTH_PX) return 'compact'; return widthPx < EXPANDED_MIN_WIDTH_PX ? 'medium' : 'expanded'; } solve [FunctionDeclaration] (from packages/core/ui/src/solver.ts): export function solve(bar: NormalizedBar, metrics: FitMetrics, containerLength: number): FitResult{ let pass = solvePass(bar, metrics, containerLength, false); if (anyOverflow(pass.groups)){ pass = solvePass(bar, metrics, containerLength, true); } const units = new Map(); const groupAssignments = new Map(); for (const gs of pass.groups){ const shedCount = gs.units.filter( (unit) => unit.shed && !unit.overflowed && !gs.collapsed, ).length; groupAssignments.set(gs.group.id, { shedCount, collapsed: gs.collapsed, overflowed: gs.overflowed, } ); for (const us of gs.units){ units.set( us.unit.key, us.overflowed ?{ kind: 'overflow'} : gs.collapsed ?{ kind: 'collapsed'} : us.shed ?{ kind: 'shed'} :{ kind: 'variant', variant: us.unit.variants[us.variantIndex]} , ); } } return{ units, groups: groupAssignments, hasOverflow: anyOverflow(pass.groups), length: pass.measured.length, complete: pass.measured.complete, } ; } stripGroupsOf [FunctionDeclaration] (from packages/core/ui/src/toolbar-layout.ts): export function stripGroupsOf( bar: NormalizedBar, resolve: (id: string) => Command | null, ): StripViewGroup[]{ const resolved = new Map(); const visible = (id: string) =>{ const command = resolve(id); if (command) resolved.set(id, command); return command?.visible === true; } ; return projectStrip(bar, visible).map((group) => ({ id: group.id, labelKey: group.labelKey, commands: group.commands.map((id) => resolved.get(id)!), } )); } tabsOf [FunctionDeclaration] (from packages/core/ui/src/layout-compile.ts): export function tabsOf(data: LayoutData): TabsVisibility{ return data.tabs ?? 'multiple'; } treeKeyAction [FunctionDeclaration] (from packages/core/ui/src/tree-keys.ts): export function treeKeyAction( rows: readonly TreeKeyRow[], focused: number, key: string, options: TreeKeyOptions ={ } , ): TreeKeyAction | null{ if (rows.length === 0) return null; const last = rows.length - 1; if (focused < 0 || focused > last){ if (key === 'ArrowDown' || key === 'Home') return{ type: 'focus', row: 0} ; if (key === 'ArrowUp' || key === 'End') return{ type: 'focus', row: last} ; return null; } const current = rows[focused]!; const focus = (row: number): TreeKeyAction | null => row === focused ? null :{ type: 'focus', row} ; switch (key){ case 'ArrowDown': return focus(Math.min(focused + 1, last)); case 'ArrowUp': return focus(Math.max(focused - 1, 0)); case 'Home': return focus(0); case 'End': return focus(last); case 'ArrowRight': if (!current.hasChildren) return null; return current.expanded ? focus(focused + 1) :{ type: 'expand', rows: [focused]} ; case 'ArrowLeft':{ if (current.hasChildren && current.expanded) return{ type: 'collapse', row: focused} ; const parent = parentOf(rows, focused); return parent < 0 ? null : focus(parent); } case '*':{ const collapsed = siblingsOf(rows, focused).filter( (row) => rows[row]!.hasChildren && !rows[row]!.expanded, ); return collapsed.length > 0 ?{ type: 'expand', rows: collapsed} : null; } case 'Enter': return{ type: 'activate', row: focused} ; case 'F2': return options.editable ?{ type: 'rename', row: focused} : null; case 'Delete': return options.editable ?{ type: 'delete', row: focused} : null; default: return null; } } validateLayout [FunctionDeclaration] (from packages/core/ui/src/layout-validate.ts): export function validateLayout(layout: Layout | LayoutData, known: LayoutKnownIds): string[]{ const problems: string[] = isLayout(layout) ? [...layoutWarningsOf(layout)] : []; const data = isLayout(layout) ? layout.toJSON() : layout; if (typeof data !== 'object' || data === null) return [...problems, 'the layout is not an object']; const bars = data.bars ??{ } ; const knownCommands = new Set(known.commands); const commands = new Set(knownCommands); for (const mode of modesOf(data)) commands.add(modeCommandOf(mode)); if (modesOf(data).length > 0) commands.add(VIEW_MODE_COMMAND); for (const panel of Object.keys(data.panels ??{ } )) commands.add(panelCommandOf(panel)); const checkCommand = (where: string, command: string) =>{ if (!commands.has(command) && known.hasCommand?.(command) !== true) problems.push(`${ where} : no command "${ command} "${ didYouMean(command, commands)} `); } ; for (const [id, bar] of Object.entries(bars)){ const where = `bar "${ id} "`; if (typeof bar !== 'object' || bar === null){ problems.push(`${ where} is not a bar`); continue; } problems.push(...placeProblems(where, id, bar.place, data)); if (bar.mode !== undefined && bar.title === undefined && bar.titleKey === undefined){ if (!knownCommands.has(modeCommandOf(bar.mode))) problems.push( `${ where} : its mode "${ bar.mode} " has no title, so its tab reads "${ bar.mode} "`, ); } problems.push(...itemProblems(where, bar, checkCommand)); } for (const [id, menu] of Object.entries(data.menus ??{ } )) problems.push(...menuProblems(`menu "${ id} "`, menu, checkCommand)); for (const [id, panel] of Object.entries(data.panels ??{ } )) problems.push(...panelProblems(`panel "${ id} "`, panel)); if (data.tabs !== undefined && !TABS.includes(data.tabs)) problems.push(`tabs: "${ data.tabs} " is not one of always, multiple or never`); return problems; }