/** One reason a lore view leaves an element out, as the graph section names it. */ type OwElementMark = 'room' | 'hidden' | 'proposed' | 'map_space' | 'reading_aid'; /** What a person must have before a tool's link works: signed in to the tool (`account`), or the world already in the tool on this device (`device`). */ type OwToolNeeds = 'account' | 'device'; /** A tool's `open` in the tools list: its link templates and what they need first. */ interface OwToolOpen { /** The link that opens a world, holding `{world}` (the world's id); null without one. */ world: string | null; /** The link that opens one element, holding `{id}` and, if it needs them, `{world}` and `{type}` (the type word); null without one. */ element: string | null; /** What the person needs first; null for nothing. A public page offers those rows, and an `account` row only as one that opens nothing ("Needs an account"). */ needs: OwToolNeeds | null; /** What the element door does not open, in the graph section's words; [] or absent: it opens every element (a list older than the key has none). */ element_skips?: readonly OwElementMark[]; /** The element types the element door opens, as type words (`character`); null or absent: every type (a list older than the key has none). */ element_types?: readonly string[] | null; /** True when the links open a public world for someone not signed in, though `needs` is `account` for a private one: a public page offers the row live. Only beside `needs: 'account'`; absent or false: as `needs` says. */ opens_public?: boolean; } /** The keys of one tools list row that `openersFor` reads; a row straight from `tools.json` carries more, and they are ignored. */ interface OwTool { /** The list's id for the tool, the row's `id` in the menu. */ id: string; name: string; url: string; /** The tool's client name (`X-OW-Client`), which a surface names itself by; null without one. */ client: string | null; /** `listed` rows are offered; `built` and `delisted` rows never are. */ rung: 'built' | 'listed' | 'delisted'; /** How a link opens a world or an element in the tool; null: never offered. */ open: OwToolOpen | null; } /** Who reads the fan-out: a member of the world, a guest (a seat in it, a member too), or the public (signed out). */ type OwWaymarkReader = 'member' | 'guest' | 'public'; /** How a person reaches the fan-out: `mark`, the OnlyWorlds mark beside the name, a button; `menu`, an "Open with" entry the surface puts in its own "..." menu, and no mark; `both`, the mark and the entry. */ type OwWaymarkEntry = 'mark' | 'menu' | 'both'; /** One lens the reader may read the element through: its id (an element id, as the address takes it) and its name. */ interface OwWaymarkLens { id: string; name: string; } /** What `mountWaymark` takes. Only `world` and `reader` are required. */ interface OwWaymarkOptions { /** The world: its id and name, as `GET /world` or a folder's `world.json` gives them (its `x_names`, when there, words the type). */ world: { id: string; name: string; [k: string]: unknown; }; /** The element, as the API serves it (`id`, `type`, `name`; a member's body carries `doors`); absent, the fan-out is the world's own. */ element?: { id: string; type: string; name: string; [k: string]: unknown; } | null; /** `member`, `guest` or `public`. The public face shows the name line without the last door, the rows that need nothing, those that need an account as rows that open nothing ("Needs an account"), and Copy link. */ reader: OwWaymarkReader; /** The client name of the surface's own tool; its row says "You are here". The site passes `onlyworlds`. */ tool?: string | null; /** Whether the reader is signed in; null when the surface cannot know, and then no row says so. */ signedIn?: boolean | null; /** False in a desktop app, which cannot see the browser's sign-in. Default true. */ browser?: boolean; /** True on a phone. Default false. */ phone?: boolean; /** The tools list's rows. Default `TOOLS`, the list baked into this release. */ tools?: readonly OwTool[]; /** The lenses the surface offers, for the Through row; absent or empty, no Through row. Never shown to the public. */ lenses?: readonly OwWaymarkLens[] | null; /** The ground the fan-out sits on: `dark` (the brand cyan mark) or `paper` (the mark in a dark ink). Default `dark`. */ ground?: 'dark' | 'paper'; /** The way in: `mark`, `menu` or `both`. Default `mark`. */ entry?: OwWaymarkEntry; /** With `menu` or `both`: the surface's own visible element (its "..." button) that takes focus when the fan-out, opened from the entry, closes by Escape; absent, the entry takes it. Refused with `mark`. */ returnFocus?: HTMLElement | null; } /** The disposer `mountWaymark` returns: call it to remove every node, listener and timer the fan-out added. */ interface OwWaymark { (): void; /** With `entry: 'menu'` or `'both'`, the "Open with" button for the surface to put in its own "..." menu (it opens the fan-out); with `mark`, null. */ readonly entry: HTMLButtonElement | null; } /** * Draw the Waymark into `target`, the element that holds a world's or an element's name: the OnlyWorlds * mark at its end (`entry: 'mark'`), or nothing visible there and an "Open with" entry for the surface's * own menu (`entry: 'menu'`), or both (`entry: 'both'`), each opening the same fan-out: the name line * (and, for a member or guest, "Last shaped in Atlas, 12 Oct" from `doorsOf` and `doorWhere`), the Open * with rows `openersFor` gives, each with its word, the Through row when the surface offers lenses, and * Copy link last, which copies the site's address with the world's id (`elementAddress`) and says "Link * copied" and closes; with no clipboard, or the copy refused, the fan-out stays open and the toast says * "Could not copy the link." over the address, selected in a read-only line to copy by hand, until the * fan-out closes. Focus moving out of the fan-out closes it and stays where it was moved. * * The surface's own row (the `tool` option's, "You are here") leads nowhere: a button with * `aria-current="page"` and no link, which closes the fan-out and returns focus to what opened it. * * The connection is read at each open (`navigator.onLine`; no navigator reads as online), and the rows * drawn for it: offline, every row whose link is a web address says "Needs a connection" (`openersFor` * with `online: false`) and is drawn grey (`ow-waymark__row--cannot`) as a link with no href, * `aria-disabled="true"`, still in the arrow and Tab order; pressing it (a click, Enter or Space) does * nothing and the fan-out stays open. While the fan-out is open, the window's `online` and `offline` * events redraw the rows in place, and focus on a row stays on that row. Copy link is unaffected. * * For the public reader, a tool that needs an account says "Needs an account" and is drawn the same * way: grey, a link with no href, `aria-disabled="true"`, in the arrow and Tab order, doing nothing * when pressed. A tool whose row opens a public world with nothing signed in (`open.opens_public`) is * a live row there. * * Keyboard: the mark is a button and the fan-out a menu; Tab goes from the mark through the rows in * order, the arrow keys, Home and End move within it, Escape closes it and returns focus to what opened * it: the mark, or for the entry `returnFocus` when given (the surface's "..." button, which stays * visible when its menu closes), else the entry. Every Escape the fan-out handles stops there * (`stopPropagation`), so a page's own Escape listener does not also run; an Escape while it is closed * is the page's. A click outside closes it. * * Placement: below the name at its start, unless it would cross the box that clips it (the nearest * ancestor of `target` whose overflow on that axis is not visible, within the window, else the window): * measured at each open, it then opens at the name's end (class `ow-waymark__pop--end`) or above the * name (`ow-waymark__pop--up`), where that side fits; the toast takes the same side. When neither side * of an axis fits (a mark mid-window in a narrow window, or in a narrow pane), it opens as the sheet * from the bottom (class `ow-waymark--sheet` on the wrapper). At 480 px wide and below (every portrait * phone, and a desktop window as narrow) the stylesheet draws it as that sheet, and no side is chosen. The page must load `@onlyworlds/sdk/waymark.css`; no * node carries a style attribute. * * Refuses, before anything is drawn, an unknown option key by name and a value of the wrong kind (a * TypeError), and an address `elementAddress` refuses (an `OwAddressError`: a world id that is not an * id, an unknown type, an element or lens id that is not a UUID). Returns the disposer. */ declare function mountWaymark(target: Element, options: OwWaymarkOptions): OwWaymark; export { mountWaymark }; export type { OwWaymark, OwWaymarkEntry, OwWaymarkLens, OwWaymarkOptions, OwWaymarkReader };