// What the workspace gives each tile it draws: its tools, what a tile asks // of the canvas it is on, and what plays its players' tracks. import type { ActionHandler, UiToolHandler, UiUploadHandler } from '@hud/renderer'; import { createContext } from 'svelte'; import type { Interactions } from '@hud/shared/interactions'; import type { Call } from '@hud/shared/result'; import type { NowPlaying } from './nowplaying.svelte'; export type TileContext = { /** Open a call from a tile: a new column right of it, after what was opened from it already. */ open: (from: string, call: Call) => void; /** Draw another call in a tile, in its place, as a tab chosen in it, every page told; false on a canvas this person can only view, where nothing changes. */ replace: (tile: string, call: Call) => Promise; /** A view's action, as create_record, delete_record or call_procedure (`ACTION_TOOLS`). */ act: ActionHandler; /** One of HUD's tools a view's form calls (`query`, `apply_writes`, `link_card`, `find_place`): its structured answer. */ tool: UiToolHandler; /** A view's form's picture, uploaded as the account (`place.hud.uploadBlob`): the blob ref it answers. */ upload: UiUploadHandler; /** What every tile tells the feeds it shows. */ feedback: Interactions; /** The workspace's one player: a tile's players play through it, so music outlives the tile. */ player: NowPlaying; }; export const [getTileContext, setTileContext] = createContext();