# @embedpdf/svelte — ./shell MenuClosedEvent [InterfaceDeclaration] (from packages/plugin/shell/src/contract.ts): export interface MenuClosedEvent{ readonly id: string; } MenuOpenedEvent [InterfaceDeclaration] (from packages/plugin/shell/src/contract.ts): export interface MenuOpenedEvent{ readonly id: string; } OpenSurfaceOptions [InterfaceDeclaration] (from packages/plugin/shell/src/contract.ts): export interface OpenSurfaceOptions{ readonly exclusive?: string; readonly props?: SurfaceProps; readonly focus?: boolean; } ShellCapability [InterfaceDeclaration] (from packages/plugin/shell/src/contract.ts): export interface ShellCapability{ isOpen(id: string): boolean; getSurface(id: string): SurfaceState | null; listOpenSurfaces(): readonly SurfaceState[]; open(id: string, options?: OpenSurfaceOptions): void; close(id: string): void; toggle(id: string, options?: OpenSurfaceOptions): void; updateSurfaceProps(id: string, props: SurfaceProps): void; closeAll(): void; isMenuOpen(id: string): boolean; listOpenMenus(): readonly string[]; openMenu(id: string): void; closeMenu(id: string): void; toggleMenu(id: string): void; closeAllMenus(): void; getSnapshot(): ShellSnapshot; applySnapshot(snapshot: ShellSnapshot): void; readonly onSurfaceOpened: EventHook; readonly onSurfaceClosed: EventHook; readonly onMenuOpened: EventHook; readonly onMenuClosed: EventHook; } ShellSnapshot [InterfaceDeclaration] (from packages/plugin/shell/src/contract.ts): export interface ShellSnapshot{ readonly surfaces: Readonly>>; readonly openMenus: readonly string[]; } ShellState [InterfaceDeclaration] (from packages/plugin/shell/src/state.ts): export interface ShellState{ readonly openSurfaces: readonly SurfaceState[]; readonly openMenus: readonly string[]; } ShellToken [VariableDeclaration] (from packages/plugin/shell/src/token.ts): ShellToken = createCapabilityToken('shell', { hint: `add shellPlugin() from '@embedpdf/plugin-shell' to your plugins list`, } ) SurfaceClosedEvent [InterfaceDeclaration] (from packages/plugin/shell/src/contract.ts): export interface SurfaceClosedEvent{ readonly id: string; } SurfaceFocusOptions [InterfaceDeclaration] (from packages/framework/web/src/surface-focus.ts): export interface SurfaceFocusOptions{ readonly select?: boolean; } SurfaceHandle [InterfaceDeclaration] (from packages/framework/svelte/src/shell/readers.svelte.ts): export interface SurfaceHandle{ readonly isOpen: boolean; readonly props: SurfaceProps; open(options?: OpenSurfaceOptions): void; close(): void; toggle(options?: OpenSurfaceOptions): void; } SurfaceOpenedEvent [InterfaceDeclaration] (from packages/plugin/shell/src/contract.ts): export interface SurfaceOpenedEvent{ readonly id: string; readonly props?: SurfaceProps; } SurfaceProps [TypeAliasDeclaration] (from packages/plugin/shell/src/contract.ts): export type SurfaceProps = Readonly>; SurfaceState [InterfaceDeclaration] (from packages/plugin/shell/src/contract.ts): export interface SurfaceState{ readonly id: string; readonly open: boolean; readonly exclusive?: string; readonly props?: SurfaceProps; readonly focusRequest: number; } shellPlugin [VariableDeclaration] (from packages/plugin/shell/src/shell.plugin.ts): shellPlugin = () => definePlugin({ id: 'shell', scope: 'document', token: ShellToken, state: initialShellModel, create: createShellController, } ) shellState [VariableDeclaration] (from packages/plugin/shell/src/state.ts): shellState = defineState(ShellToken, { read: (shell): ShellState => ({ openSurfaces: shell.listOpenSurfaces(), openMenus: shell.listOpenMenus(), } ), empty:{ openSurfaces: [], openMenus: []} , } ) surfaceFocus [FunctionDeclaration] (from packages/framework/svelte/src/shell/surface-focus.svelte.ts): export function surfaceFocus( id: MaybeGetter, options: SurfaceFocusOptions ={ } , ): Attachment{ const shell = useOptionalCapability(ShellToken); const request = useOptionalSelector( ShellToken, (current) => current.getSurface(valueOf(id))?.focusRequest ?? 0, 0, ); return (element) =>{ const follower = createSurfaceFocusFollower(); $effect(() =>{ const current = shell.current; const value = request.current; untrack(() => follower.follow(element, current, value, options)); } ); } ; } useShell [FunctionDeclaration] (from packages/framework/svelte/src/shell/readers.svelte.ts): export function useShell(): ShellCapability{ return useCapability(ShellToken); } useShellEvent [FunctionDeclaration] (from packages/framework/svelte/src/shell/readers.svelte.ts): export function useShellEvent( select: (shell: ShellCapability) => EventHook, handler: (event: T) => void, ): void{ useCapabilityEvent(ShellToken, select, handler); } useShellState [VariableDeclaration] (from packages/framework/svelte/src/shell/readers.svelte.ts): useShellState = stateReader(shellState) useSurface [FunctionDeclaration] (from packages/framework/svelte/src/shell/readers.svelte.ts): export function useSurface(id: MaybeGetter): SurfaceHandle{ const shell = useOptionalCapability(ShellToken); const isOpen = useOptionalSelector(ShellToken, (shell) => shell.isOpen(valueOf(id)), false); const props = useOptionalSelector( ShellToken, (shell) => shell.getSurface(valueOf(id))?.props ?? NO_PROPS, NO_PROPS, ); return{ get isOpen(){ return isOpen.current; } , get props(){ return props.current; } , open: (options) => shell.current?.open(valueOf(id), options), close: () => shell.current?.close(valueOf(id)), toggle: (options) => shell.current?.toggle(valueOf(id), options), } ; }