@n-uf/placement 26.11.29 → 26.11.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +62 -0
- package/README.md +105 -65
- package/dist/{chunk-7ASCUAGV.js → chunk-3ZICYLWL.js} +2 -2
- package/dist/{chunk-7ASCUAGV.js.map → chunk-3ZICYLWL.js.map} +1 -1
- package/dist/{chunk-3RRCKN74.js → chunk-AE3BWTAE.js} +2 -2
- package/dist/chunk-AE3BWTAE.js.map +1 -0
- package/dist/{chunk-3P6VOXA6.js → chunk-AVMZIXGO.js} +2 -2
- package/dist/{chunk-3P6VOXA6.js.map → chunk-AVMZIXGO.js.map} +1 -1
- package/dist/{chunk-PC5UHBW4.js → chunk-COK4YNMF.js} +87 -35
- package/dist/chunk-COK4YNMF.js.map +1 -0
- package/dist/{chunk-WLMJ6JGO.js → chunk-GIBUM6TB.js} +1 -1
- package/dist/chunk-GIBUM6TB.js.map +1 -0
- package/dist/{chunk-OYGOJWAX.js → chunk-JVAR67OL.js} +2 -2
- package/dist/{chunk-WM5FJ3IS.js → chunk-VLTYJHUA.js} +1 -1
- package/dist/{chunk-WM5FJ3IS.js.map → chunk-VLTYJHUA.js.map} +1 -1
- package/dist/{constructions-DSEjvWMP.d.ts → constructions-Cbz7uEAZ.d.ts} +3 -3
- package/dist/desk.d.ts +3 -3
- package/dist/desk.js +3 -3
- package/dist/dock.d.ts +4 -4
- package/dist/dock.js +2 -2
- package/dist/dock.js.map +1 -1
- package/dist/{float-fit-DRSOU_2y.d.ts → float-fit-DCYxRMru.d.ts} +1 -1
- package/dist/{geometry-CkZ6Fcfb.d.ts → geometry-Bf37LbCT.d.ts} +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/{model-lYlnfQnl.d.ts → model-DMB2ZFJ2.d.ts} +25 -6
- package/dist/{model-CPM1Lv65.d.ts → model-X7eUaKlA.d.ts} +2 -2
- package/dist/panels.d.ts +5 -5
- package/dist/panels.js +3 -3
- package/dist/scene-cases.d.ts +59 -15
- package/dist/scene-cases.js +115 -21
- package/dist/scene-cases.js.map +1 -1
- package/dist/scene.d.ts +12 -7
- package/dist/scene.js +3 -3
- package/dist/stack.d.ts +6 -6
- package/dist/stack.js +2 -2
- package/dist/{target-D9PMr9pF.d.ts → target-2RYYKkd1.d.ts} +1 -1
- package/dist/{targets-BYRTTwCP.d.ts → targets-Du5_4T1u.d.ts} +4 -4
- package/dist/targets.d.ts +14 -14
- package/dist/targets.js +4 -4
- package/dist/targets.js.map +1 -1
- package/dist/toolbar.d.ts +11 -11
- package/dist/toolbar.js +1 -1
- package/package.json +2 -2
- package/dist/chunk-3RRCKN74.js.map +0 -1
- package/dist/chunk-PC5UHBW4.js.map +0 -1
- package/dist/chunk-WLMJ6JGO.js.map +0 -1
- /package/dist/{chunk-OYGOJWAX.js.map → chunk-JVAR67OL.js.map} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/dock/model.ts","../src/dock/arrange.ts","../src/dock/parts.ts"],"sourcesContent":["/**\n * The desk's model: panels and documents, the options, the state every construction keeps, and what a layout\n * returns (a placed rect per item). The panels themselves (their titles and natural heights) come from the\n * consumer as a catalog; see `createDesk`.\n */\nimport type { Rect, Size } from \"../geometry\";\n\nexport type Side = \"left\" | \"right\";\n\n/** Gaps and sizes, in stage px. */\nexport const G = 6;\n/** A toolbar bar's height (the pill is 4 px thinner). */\nexport const BAR = 34;\n/** A rail's width. */\nexport const RAIL = 34;\n/** A folded section's (or a shaded palette's) height: its title bar. */\nexport const TITLE = 22;\n/** A tab row's height (navigator sides and drawers). */\nexport const TABS = 28;\n/** The smallest a tiled document may be where a construction promises it (the tiling tree, the strip). */\nexport const DOC_MIN: Size = { width: 240, height: 160 };\n\n/** Items are keyed \"panel:<id>\" and \"doc:<id>\". */\nexport const panelKey = (id: number): string => `panel:${id}`;\nexport const docKey = (id: number): string => `doc:${id}`;\nexport const isPanelKey = (key: string): boolean => key.startsWith(\"panel:\");\nexport const isDocKey = (key: string): boolean => key.startsWith(\"doc:\");\nexport const idOf = (key: string): number => Number(key.slice(key.indexOf(\":\") + 1));\n\n/** A tool panel: its title and the height its content needs (its natural height, title bar included). */\nexport interface PanelSpec {\n readonly id: number;\n readonly title: string;\n readonly natural: number;\n}\n\n/** Where the panels start. Unset parts follow from the sides (see `createDesk`). */\nexport interface DeskStart {\n readonly left: readonly number[];\n readonly right: readonly number[];\n readonly bottom: readonly number[];\n readonly active?: { readonly left: number | null; readonly right: number | null };\n readonly tree?: DeskState[\"tree\"];\n readonly cols?: DeskState[\"cols\"];\n readonly stacks?: DeskState[\"stacks\"];\n}\n\n/** What a desk is made of: its panels, its documents' titles and where the panels start. */\nexport interface DeskSpec {\n readonly panels: readonly PanelSpec[];\n /** A document's title (default \"Document <id>\"). */\n readonly docTitle?: (id: number) => string;\n readonly start: DeskStart;\n /** The panels in the order they were opened (default: as listed); the tiling tree floats the newest first. */\n readonly opened?: readonly number[];\n}\n\n/** The catalog every part reads: a panel's natural height, an item's title and age. */\nexport interface Catalog {\n readonly panelIds: readonly number[];\n readonly natural: (id: number) => number;\n /** An item's title by key (\"panel:<id>\", \"doc:<id>\"); any other key is its own title. */\n readonly title: (key: string) => string;\n /** An item's age: higher is newer (panels in the order they were opened, then the documents). */\n readonly born: (key: string) => number;\n readonly start: Required<DeskStart>;\n}\n\n/** The catalog for a spec (unset start parts filled in). */\nexport function catalogOf(spec: DeskSpec): Catalog {\n const byId = new Map(spec.panels.map((p) => [p.id, p]));\n const opened = spec.opened ?? spec.panels.map((p) => p.id);\n const docTitle = spec.docTitle ?? ((id: number) => `Document ${id}`);\n const { left, right, bottom } = spec.start;\n const rest = [...right, ...bottom];\n const start: Required<DeskStart> = {\n left,\n right,\n bottom,\n active: spec.start.active ?? { left: left[0] ?? null, right: right.at(-1) ?? null },\n tree: spec.start.tree ?? { L: left.map(panelKey), R: rest.map(panelKey), C: [] },\n cols: spec.start.cols ?? [left.map(panelKey), rest.map(panelKey)].filter((c) => c.length > 0),\n stacks: spec.start.stacks ?? { left, right: rest },\n };\n return {\n panelIds: spec.panels.map((p) => p.id),\n natural: (id) => byId.get(id)?.natural ?? TITLE,\n title: (key) => (isPanelKey(key) ? (byId.get(idOf(key))?.title ?? key) : isDocKey(key) ? docTitle(idOf(key)) : key),\n born: (key) => (isDocKey(key) ? 1000 + idOf(key) : opened.indexOf(idOf(key)) + 1),\n start,\n };\n}\n\n/** Where the toolbar floats (top or bottom) and whether the documents keep a band clear for it; the bottom dock's mode. */\nexport interface Options {\n readonly toolbar: \"top\" | \"bottom\";\n readonly toolbarSpace: \"reserved\" | \"overlay\";\n readonly bottom: \"reserved\" | \"overlay\" | \"off\";\n /** The pill's width when its contents need more than the default; unset: the default. */\n readonly toolbarWidth?: number;\n /** The pill holds nothing: it takes no space and isn't shown. */\n readonly toolbarHidden?: boolean;\n}\nexport const DEFAULT_OPTIONS: Options = { toolbar: \"top\", toolbarSpace: \"reserved\", bottom: \"reserved\" };\n\n/** A panel placed freely (torn off, or a palette out of its stack): its top-left corner, null for the default spot. */\nexport interface Free {\n readonly id: number;\n readonly at: { readonly x: number; readonly y: number } | null;\n}\n\n/**\n * Everything any construction keeps. Each construction has its own copy (its own arrangement) and reads only what\n * it uses; the open documents are the same in all of them.\n */\nexport interface DeskState {\n /** Open document ids, in open order. */\n readonly docs: readonly number[];\n readonly focus: number | null;\n /** Panel ids, least recently used first: what folds or shades first when height runs out. */\n readonly recent: readonly number[];\n /** Sections folded (palettes shaded) by hand. */\n readonly folded: readonly number[];\n /** Docks, navigator sides and drawers: the panels on each side, top to bottom (tabs: left to right). */\n readonly left: readonly number[];\n readonly right: readonly number[];\n /** The bottom dock's panels (edge docks only). */\n readonly bottom: readonly number[];\n /** Docks or drawers folded to their rail by hand. */\n readonly closed: readonly Side[];\n /** The side opened last by hand: when width runs out it folds last. */\n readonly opened: Side | null;\n /** The panel showing on each side (navigator, drawers). */\n readonly active: { readonly left: number | null; readonly right: number | null };\n /** Panels torn off a dock, floating (edge docks + tear-off). */\n readonly torn: readonly Free[];\n /** The tiling tree: item keys in the left column, the right column and the centre (dwindle order). */\n readonly tree: { readonly L: readonly string[]; readonly R: readonly string[]; readonly C: readonly string[] };\n /** The scrolling strip: its columns, left to right, each a list of item keys top to bottom. */\n readonly cols: readonly (readonly string[])[];\n /** The strip scrolled by hand, or null: it scrolls to the focus. */\n readonly stripScroll: number | null;\n /** Palettes: the corner stacks, top to bottom, and the ones placed anywhere. */\n readonly stacks: { readonly left: readonly number[]; readonly right: readonly number[] };\n readonly free: readonly Free[];\n}\n\n/** How an item is drawn. */\nexport type Look =\n | \"pill\" // the toolbar floating as a rounded pill\n | \"bar\" // the toolbar as a bar across the top\n | \"section\" // a panel open in a dock\n | \"header\" // a section folded (or a palette shaded) to its title bar\n | \"float\" // a panel floating over the documents\n | \"palette\" // a floating panel that reserves its footprint\n | \"tile\" // a panel tiled like a document\n | \"bare\" // a panel under a tab row: no title bar of its own\n | \"doc\"\n | \"rail\"\n | \"tabs\"\n | \"track\"\n | \"thumb\";\n\n/** Stacking layers, bottom to top. */\nexport const LAYER = { doc: 1, dock: 2, palette: 3, overlay: 4, float: 5, toolbar: 6 } as const;\n\n/** One item as a layout places it. */\nexport interface Placed {\n readonly rect: Rect;\n readonly look: Look;\n readonly layer: number;\n /** Folded away (into a rail, behind a tab): it goes to `rect`, hidden. */\n readonly hidden?: boolean;\n /** Never laid out below this (where the construction promises it). */\n readonly min?: Partial<Size>;\n /** It may lie outside the stage (the strip scrolls). */\n readonly offStage?: boolean;\n /** A rail's icons or a tab row's tabs (panel ids), and the active tab. */\n readonly icons?: readonly number[];\n readonly tabs?: readonly number[];\n readonly active?: number | null;\n /** Drawn with an accent outline (the bottom dock). */\n readonly accent?: boolean;\n /** Drawn with a shadow (it floats over something). */\n readonly shadow?: boolean;\n}\n\n/**\n * How a layout gave way (or what it is worth knowing about it):\n *\n * - `bottom-folded`: the bottom dock folded to its header; `dock-folded`: a side dock folded to its rail (`side`);\n * - `sections-folded`: sections folded to their headers by themselves, least recently used first;\n * - `torn-floating`: panels torn off a dock float (`items`); `torn-shaded`: some shade because they don't fit;\n * - `columns-railed`: the tiling tree's side columns are folded to rails (`side` when only one);\n * - `tiles-float`: tiles that broke a minimum float, newest first (`items`);\n * - `tabs-folded`: a tabbed side folded to icon tabs (`side`); `drawer-over`: a drawer slides over the\n * documents (`side`);\n * - `column-split`: a strip column split in two (`items`); `strip-scrolls`: the strip is wider than the stage;\n * - `stacks-merged`: both palette stacks share one corner; `palettes-shaded`: palettes shaded to title bars;\n * - `palettes-cover`, `docs-room`: how much of the documents palettes cover, and how much room they leave.\n */\nexport type NoteCode =\n | \"bottom-folded\"\n | \"dock-folded\"\n | \"sections-folded\"\n | \"torn-floating\"\n | \"torn-shaded\"\n | \"columns-railed\"\n | \"tiles-float\"\n | \"tabs-folded\"\n | \"drawer-over\"\n | \"column-split\"\n | \"strip-scrolls\"\n | \"stacks-merged\"\n | \"palettes-shaded\"\n | \"palettes-cover\"\n | \"docs-room\";\n\n/**\n * One note on a layout. `code` (and `side`, `items` where they apply) is the contract; `text` says it in English for\n * people, and its wording may change in any release.\n */\nexport interface Note {\n readonly code: NoteCode;\n readonly text: string;\n readonly side?: Side;\n /** The item keys it is about. */\n readonly items?: readonly string[];\n}\n\n/** Where everything is (\"toolbar\", \"panel:<id>\", \"doc:<id>\", \"rail:<side>\", \"tabs:<side>\", \"track\", \"thumb\"), and how it gave way. */\nexport interface Layout {\n readonly items: ReadonlyMap<string, Placed>;\n readonly notes: readonly Note[];\n}\n\n// --- state changes -------------------------------------------------------------------------------------------------\n\n/** The arrangement a catalog starts from, with these documents open (none by default). */\nexport function startState(cat: Catalog, docs: readonly number[] = []): DeskState {\n const st = cat.start;\n const base: DeskState = {\n docs: [],\n focus: null,\n recent: [...cat.panelIds],\n folded: [],\n left: [...st.left],\n right: [...st.right],\n bottom: [...st.bottom],\n closed: [],\n opened: null,\n active: st.active,\n torn: [],\n tree: st.tree,\n cols: st.cols,\n stripScroll: null,\n stacks: st.stacks,\n free: [],\n };\n return withDocs(base, docs, docs.at(-1) ?? null);\n}\n\n/**\n * The same state with these documents open: new ones join the tiling tree's centre (the first one at its front)\n * and get a strip column of their own after the last document column; closed ones leave both.\n */\nexport function withDocs(s: DeskState, docs: readonly number[], focus: number | null): DeskState {\n const keys = docs.map(docKey);\n const gone = (k: string): boolean => isDocKey(k) && !keys.includes(k);\n let C = s.tree.C.filter((k) => !gone(k));\n let cols = s.cols.map((c) => c.filter((k) => !gone(k))).filter((c) => c.length > 0);\n const has = (k: string): boolean => [...s.tree.L, ...s.tree.R, ...C].includes(k);\n for (const k of keys) {\n if (!has(k)) C = C.some(isDocKey) || C.length === 0 ? [...C, k] : [k, ...C];\n if (!cols.some((c) => c.includes(k))) {\n const lastDoc = cols.map((c) => c.some(isDocKey)).lastIndexOf(true);\n const at = lastDoc >= 0 ? lastDoc + 1 : Math.min(1, cols.length);\n cols = [...cols.slice(0, at), [k], ...cols.slice(at)];\n }\n }\n const L = s.tree.L.filter((k) => !gone(k));\n const R = s.tree.R.filter((k) => !gone(k));\n const f = focus !== null && docs.includes(focus) ? focus : (docs.at(-1) ?? null);\n // A new focus: the strip scrolls to it again.\n return { ...s, docs: [...docs], focus: f, tree: { L, R, C }, cols, stripScroll: f === s.focus ? s.stripScroll : null };\n}\n\n/** Panel `id` was used: it is the last to fold when height runs out. */\nexport const touch = (s: DeskState, id: number): DeskState => ({ ...s, recent: [...s.recent.filter((x) => x !== id), id] });\n\n/** Fold or unfold a section (shade or unshade a palette) by hand; unfolding is a use. */\nexport function toggleFold(s: DeskState, id: number): DeskState {\n const folded = s.folded.includes(id);\n const next = { ...s, folded: folded ? s.folded.filter((x) => x !== id) : [...s.folded, id] };\n return folded ? touch(next, id) : next;\n}\n\n/** Fold a dock (or drawer) to its rail by hand, or open it again (then it folds last when width runs out). */\nexport function toggleClosed(s: DeskState, side: Side): DeskState {\n const closed = s.closed.includes(side);\n return closed ? { ...s, closed: s.closed.filter((x) => x !== side), opened: side } : { ...s, closed: [...s.closed, side] };\n}\n\n/** Show panel `id` on its side (navigator, drawers). */\nexport const withActive = (s: DeskState, side: Side, id: number): DeskState => touch({ ...s, active: { ...s.active, [side]: id } }, id);\n\n/** The state with `key` lifted out of wherever it is (before a drop puts it somewhere). */\nexport function liftOut(s: DeskState, key: string): DeskState {\n const dropK = (l: readonly string[]): string[] => l.filter((k) => k !== key);\n const base: DeskState = { ...s, tree: { L: dropK(s.tree.L), R: dropK(s.tree.R), C: dropK(s.tree.C) }, cols: s.cols.map(dropK).filter((c) => c.length > 0) };\n if (!isPanelKey(key)) return base;\n const id = idOf(key);\n const drop = (l: readonly number[]): number[] => l.filter((x) => x !== id);\n return {\n ...base,\n left: drop(s.left),\n right: drop(s.right),\n bottom: drop(s.bottom),\n torn: s.torn.filter((f) => f.id !== id),\n free: s.free.filter((f) => f.id !== id),\n stacks: { left: drop(s.stacks.left), right: drop(s.stacks.right) },\n active: { left: s.active.left === id ? null : s.active.left, right: s.active.right === id ? null : s.active.right },\n };\n}\n","/**\n * The arrangers the desk constructions build on, internal to `./dock`: master and stack for the documents, dwindle\n * for the tiling tree's centre, stacked columns at natural heights, and the minimum-size give-way (the newest tile\n * that breaks a minimum floats). A public `./tiling` will come from a merge with a full split-tree model; these stay\n * the dock's own until then.\n */\nimport type { Rect, Size } from \"../geometry\";\n\n/**\n * Master and stack: the first id takes the left part (`ratio` of the width less the gap), the rest stack on the\n * right in equal rows. One id takes the whole area.\n */\nexport function masterStack<K>(ids: readonly K[], area: Rect, gap: number, ratio = 0.5): Map<K, Rect> {\n const out = new Map<K, Rect>();\n if (ids.length === 0) return out;\n if (ids.length === 1) {\n out.set(ids[0]!, { ...area });\n return out;\n }\n const mw = (area.width - gap) * ratio;\n out.set(ids[0]!, { x: area.x, y: area.y, width: mw, height: area.height });\n const k = ids.length - 1;\n const sh = (area.height - gap * (k - 1)) / k;\n ids.slice(1).forEach((id, i) => out.set(id, { x: area.x + mw + gap, y: area.y + i * (sh + gap), width: area.width - mw - gap, height: sh }));\n return out;\n}\n\n/** Dwindle over an order: each tile but the last splits the space left in two along its longer side. */\nexport function dwindle(area: Rect, n: number, gap: number): Rect[] {\n const out: Rect[] = [];\n let cur = { ...area };\n for (let i = 0; i < n; i++) {\n if (i === n - 1) {\n out.push(cur);\n break;\n }\n if (cur.width >= cur.height) {\n const w = (cur.width - gap) / 2;\n out.push({ x: cur.x, y: cur.y, width: w, height: cur.height });\n cur = { x: cur.x + w + gap, y: cur.y, width: w, height: cur.height };\n } else {\n const h = (cur.height - gap) / 2;\n out.push({ x: cur.x, y: cur.y, width: cur.width, height: h });\n cur = { x: cur.x, y: cur.y + h + gap, width: cur.width, height: h };\n }\n }\n return out;\n}\n\n/**\n * Heights for a column of items stacked in `avail` with gaps: each at its minimum (its natural height), the last\n * taking the rest. When the minimums don't fit, an even share instead, so the ones that break their minimum show.\n */\nexport function columnHeights(avail: number, mins: readonly number[], gap: number): number[] {\n const room = avail - gap * (mins.length - 1);\n const need = mins.reduce((a, b) => a + b, 0);\n if (need > room) return mins.map(() => room / mins.length);\n return mins.map((m, i) => (i === mins.length - 1 ? room - need + m : m));\n}\n\n/**\n * Lengths for items sharing `avail`: each gets at least its minimum, the rest of the room is shared in proportion\n * to the minimums (when the minimums don't fit, each gets its minimum).\n */\nexport function share(avail: number, mins: readonly number[]): number[] {\n const need = mins.reduce((a, b) => a + b, 0);\n const spare = Math.max(0, avail - need);\n return mins.map((m) => m + (need > 0 ? (spare * m) / need : spare / mins.length));\n}\n\n/**\n * The minimum-size give-way: while a tile is laid out below its minimum, the newest tile (highest `age`) floats and\n * the rest are laid out again. Stops when every tile keeps its minimum or one tile is left. `layout` lays out the\n * kept keys; the result says which are kept (in their order) and which float (newest first).\n */\nexport function giveWay<K>(keys: readonly K[], layout: (kept: readonly K[]) => ReadonlyMap<K, Rect>, min: (key: K) => Size, age: (key: K) => number): { kept: K[]; floats: K[] } {\n let kept = [...keys];\n const floats: K[] = [];\n for (;;) {\n const res = layout(kept);\n const broken = [...res].some(([k, r]) => r.width < min(k).width - 0.5 || r.height < min(k).height - 0.5);\n if (!broken || kept.length <= 1) return { kept, floats };\n const newest = kept.reduce((a, b) => (age(b) > age(a) ? b : a));\n kept = kept.filter((k) => k !== newest);\n floats.push(newest);\n }\n}\n","/**\n * The parts the desk constructions are built from, each pure: the toolbar pill, the documents' tiles, natural-height\n * sections (the last open one takes the rest; the least recently used fold to headers), rails, the edge docks'\n * geometry, the tiling tree's columns, the scrolling strip, tabbed sides and floating palettes.\n */\nimport { clampInto, rect, type Rect, type Size } from \"../geometry\";\nimport { columnHeights, dwindle, giveWay, masterStack } from \"./arrange\";\nimport { BAR, DOC_MIN, G, LAYER, RAIL, TABS, TITLE, docKey, idOf, isDocKey, panelKey, type Catalog, type DeskState, type Note, type Options, type Placed, type Side } from \"./model\";\n\nexport type Out = Map<string, Placed>;\n\nexport const plural = (n: number, one: string, many: string): string => `${n} ${n > 1 ? many : one}`;\n\n// --- the toolbar pill and the documents ----------------------------------------------------------------------------\n\n/** The shortest a pill gets (unless there is less room than that). */\nexport const PILL_MIN = 60;\n\n/**\n * The toolbar pill, floating at the top or the bottom of the band [y0, y1] above a region `cx`..`cx + cw`; returns\n * the pill and the band left for the documents (reserved: they keep clear of it; overlay: it floats over them).\n */\nexport function pill(opt: Options, cx: number, cw: number, y0: number, y1: number): { placed: Placed; top: number; bottom: number } {\n const pw = Math.max(PILL_MIN, Math.min(opt.toolbarWidth ?? 320, cw - 24));\n const ph = BAR - 4;\n const atTop = opt.toolbar === \"top\";\n // A hidden pill keeps no band clear, as if it floated.\n const overlay = opt.toolbarSpace === \"overlay\" || !!opt.toolbarHidden;\n return {\n placed: { rect: rect(cx + cw / 2 - pw / 2, atTop ? y0 + G : y1 - G - ph, pw, ph), look: \"pill\", layer: LAYER.toolbar, shadow: overlay, ...(opt.toolbarHidden ? { hidden: true } : {}) },\n top: atTop && !overlay ? y0 + BAR + 2 * G : y0 + G,\n bottom: !atTop && !overlay ? y1 - BAR - 2 * G : y1 - G,\n };\n}\n\n/** The toolbar as a bar across the top of the stage. */\nexport const bar = (W: number): Placed => ({ rect: rect(0, 0, W, BAR), look: \"bar\", layer: LAYER.toolbar });\n\n/** The documents in `r`, master and stack: the first takes 56 % of the width, the rest stack on the right. */\nexport function tiles(out: Out, r: Rect, ids: readonly number[], min?: Size): void {\n for (const [id, rr] of masterStack(ids, r, G, 0.56)) out.set(docKey(id), { rect: rr, look: \"doc\", layer: LAYER.doc, ...(min ? { min } : {}) });\n}\n\n// --- sections and rails --------------------------------------------------------------------------------------------\n\n/**\n * The ones of `ids` to fold, least recently used first, until what stays open fits `avail`. An accordion keeps one\n * section open whatever (`keepOne`); a palette stack shades even its last palette rather than run off the stage.\n */\nfunction lruFold(s: DeskState, ids: readonly number[], avail: number, open: (id: number) => number, closed: number, keepOne = true): number[] {\n const byHand = ids.filter((id) => s.folded.includes(id));\n const auto: number[] = [];\n const isOpen = (id: number): boolean => !byHand.includes(id) && !auto.includes(id);\n const need = (): number => ids.reduce((sum, id) => sum + (isOpen(id) ? open(id) : closed), 0) + G * (ids.length - 1);\n const order = [...s.recent].filter((id) => ids.includes(id));\n for (const id of order) {\n if (need() <= avail || (keepOne && ids.filter(isOpen).length <= 1)) break;\n if (isOpen(id)) auto.push(id);\n }\n return [...byHand, ...auto];\n}\n\n/**\n * Natural-height sections in x, y, w, h: each open section takes its natural height and the last open one takes\n * the rest; the least recently used fold to headers until the open ones fit. Returns how many folded by themselves.\n */\nexport function accordion(cat: Catalog, out: Out, s: DeskState, x: number, y: number, w: number, h: number, ids: readonly number[]): number {\n const folded = lruFold(s, ids, h, cat.natural, TITLE);\n const open = ids.filter((id) => !folded.includes(id));\n const room = h - G * (ids.length - 1) - TITLE * (ids.length - open.length);\n const last = open.at(-1);\n const rest = room - open.reduce((sum, id) => sum + (id === last ? 0 : cat.natural(id)), 0);\n let cy = y;\n for (const id of ids) {\n const i = open.indexOf(id);\n const n = cat.natural(id);\n const hh = i < 0 ? TITLE : id === last ? Math.max(n, rest) : n;\n out.set(panelKey(id), { rect: rect(x, cy, w, hh), look: i >= 0 ? \"section\" : \"header\", layer: LAYER.dock, ...(i >= 0 ? { min: { height: n } } : {}) });\n cy += hh + G;\n }\n return folded.filter((id) => !s.folded.includes(id)).length;\n}\n\n/** A rail of icons at x, y; the rect of its icon `i`. */\nconst railIcon =(x: number, y: number, i: number): Rect => rect(x + 6, y + 10 + i * 32, RAIL - 12, 24);\n\n/** A rail (a column whose panels are all folded) at x, y, h: one icon per panel. */\nexport function rail(out: Out, side: Side, x: number, y: number, h: number, ids: readonly number[], hidden = false): void {\n out.set(`rail:${side}`, { rect: rect(x, y, RAIL, h), look: \"rail\", layer: LAYER.dock, icons: ids, ...(hidden ? { hidden } : {}) });\n}\n\n/** Panels folded into a rail: hidden, each at its icon at `w` × its natural height. */\nexport function intoRail(cat: Catalog, out: Out, x: number, y: number, w: number, ids: readonly number[], side: Side): void {\n ids.forEach((id, i) => {\n const icon = railIcon(x, y, i);\n out.set(panelKey(id), { rect: rect(side === \"left\" ? icon.x : icon.x + icon.width - w, icon.y, w, cat.natural(id)), look: \"section\", layer: LAYER.dock, hidden: true });\n });\n}\n\n// --- edge docks ----------------------------------------------------------------------------------------------------\n\n/**\n * The dock width (rail excluded, its sections 240 px wide after the gap) and the narrowest the documents may get\n * before a dock folds.\n */\nexport const DOCK = 246;\nconst WORK_MIN = 380;\n/** The bottom dock's height when open, and the most of the stage's height it takes. */\nconst BOTTOM = 190;\nconst BOTTOM_SHARE = 0.36;\n\n/** What the edge docks put where: shared by their layouts and their drop targets. */\nexport interface DockGeometry {\n /** The side docks' height (less the bottom dock's in full-width mode). */\n readonly h: number;\n /** The bottom dock's height (its header's when folded; 0 when off). */\n readonly bh: number;\n readonly lOpen: boolean;\n readonly rOpen: boolean;\n /** The right dock's panels (the bottom dock's join them when it is off). */\n readonly right: readonly number[];\n readonly bottomOn: boolean;\n readonly bottomRect: Rect | null;\n /** The documents' band, left to right. */\n readonly x0: number;\n readonly x1: number;\n}\n\n/**\n * The edge docks' give-way: the bottom dock folds to its header when the stage is short, and a whole side dock\n * folds to its rail when the documents would get narrower than WORK_MIN (the right one first, unless it was opened\n * last by hand). `mode`: the bottom dock between the side docks, or across the full width under them.\n */\nexport function dockGeometry(cat: Catalog, s: DeskState, size: Size, opt: Options, mode: \"between\" | \"full\", notes: Note[] = []): DockGeometry {\n const { width: W, height: H } = size;\n const bottomOn = opt.bottom !== \"off\" && s.bottom.length > 0;\n const right = bottomOn ? s.right : [...s.right, ...s.bottom];\n const bottomFolded = bottomOn && (H < 480 || s.bottom.every((id) => s.folded.includes(id)));\n // Open, it is BOTTOM tall, never more than BOTTOM_SHARE of the stage (but never below what its panels need).\n const bh = !bottomOn ? 0 : bottomFolded ? TITLE : Math.max(...s.bottom.map(cat.natural), Math.min(BOTTOM, BOTTOM_SHARE * H));\n if (bottomOn && H < 480) notes.push({ code: \"bottom-folded\", text: \"bottom dock folded to its header\" });\n const full = mode === \"full\";\n const h = full && bottomOn ? H - bh - G : H;\n let lOpen = s.left.length > 0 && !s.closed.includes(\"left\");\n let rOpen = right.length > 0 && !s.closed.includes(\"right\");\n const work = (): number => W - 2 * RAIL - (lOpen ? DOCK : 0) - (rOpen ? DOCK : 0) - 2 * G;\n for (const side of s.opened === \"right\" ? ([\"left\", \"right\"] as const) : ([\"right\", \"left\"] as const)) {\n if (work() >= WORK_MIN) break;\n if (side === \"right\" && rOpen) {\n rOpen = false;\n notes.push({ code: \"dock-folded\", side: \"right\", text: \"right dock folded to its rail\" });\n } else if (side === \"left\" && lOpen) {\n lOpen = false;\n notes.push({ code: \"dock-folded\", side: \"left\", text: \"left dock folded to its rail\" });\n }\n }\n const x0 = RAIL + (lOpen ? DOCK : 0) + G;\n const x1 = W - RAIL - (rOpen ? DOCK : 0) - G;\n const bottomRect = bottomOn ? (full ? rect(G, H - G - bh, W - 2 * G, bh) : rect(x0, H - G - bh, x1 - x0, bh)) : null;\n return { h, bh, lOpen, rOpen, right, bottomOn, bottomRect, x0, x1 };\n}\n\n/** The width of a torn-off panel (its height is its natural height). */\nexport const TORN_W = 200;\n\n// --- the tiling tree -----------------------------------------------------------------------------------------------\n\n/** The smallest a tile may be: a document's minimum, or a panel at its natural height. */\nexport const tileMin = (cat: Catalog, key: string): Size => (isDocKey(key) ? DOC_MIN : { width: 150, height: cat.natural(idOf(key)) });\n/** A side column's width. */\nexport const TREE_COLUMN = 180;\n\n/** The tree's tiles laid out (no floating): the left and right columns, the centre by dwindle. */\nexport function treeTiles(cat: Catalog, tree: DeskState[\"tree\"], area: Rect): Map<string, Rect> {\n const res = new Map<string, Rect>();\n let x0 = area.x;\n let x1 = area.x + area.width;\n // A side column's tiles take their natural height, the last one the rest.\n const column = (list: readonly string[], x: number): void => {\n const heights = columnHeights(area.height, list.map((k) => tileMin(cat, k).height), G);\n let y = area.y;\n list.forEach((k, i) => {\n res.set(k, rect(x, y, TREE_COLUMN, heights[i]!));\n y += heights[i]! + G;\n });\n };\n if (tree.L.length) {\n column(tree.L, x0);\n x0 += TREE_COLUMN + G;\n }\n if (tree.R.length) {\n column(tree.R, x1 - TREE_COLUMN);\n x1 -= TREE_COLUMN + G;\n }\n dwindle(rect(x0, area.y, x1 - x0, area.height), tree.C.length, G).forEach((r, i) => res.set(tree.C[i]!, r));\n return res;\n}\n\n/** The sides of the tree whose column is folded to a rail at the stage's edge (closed by hand, or at a narrow start). */\nexport const treeRails = (s: DeskState): { readonly left: boolean; readonly right: boolean } => ({\n left: s.closed.includes(\"left\") && s.tree.L.length > 0,\n right: s.closed.includes(\"right\") && s.tree.R.length > 0,\n});\n\n/** The area the tree tiles: the stage under the bar, less the rails of folded columns. */\nexport const treeArea = (size: Size, s?: DeskState): Rect => {\n const r = s ? treeRails(s) : { left: false, right: false };\n const x0 = r.left ? RAIL + G : G;\n const x1 = size.width - (r.right ? RAIL + G : G);\n return rect(x0, BAR + G, x1 - x0, size.height - BAR - 2 * G);\n};\n\n/** The tree as tiled: a column folded to its rail tiles nothing. */\nexport const treeShown = (s: DeskState): DeskState[\"tree\"] => {\n const r = treeRails(s);\n return { L: r.left ? [] : s.tree.L, R: r.right ? [] : s.tree.R, C: s.tree.C };\n};\n\n/** Which tiles float: the newest tile that breaks a minimum floats, then the tree is laid out again. */\nexport function treeFloats(cat: Catalog, tree: DeskState[\"tree\"], area: Rect): { tree: DeskState[\"tree\"]; floats: string[] } {\n const only = (kept: readonly string[]): DeskState[\"tree\"] => ({ L: tree.L.filter((k) => kept.includes(k)), R: tree.R.filter((k) => kept.includes(k)), C: tree.C.filter((k) => kept.includes(k)) });\n const { kept, floats } = giveWay(\n [...tree.L, ...tree.R, ...tree.C],\n (k) => treeTiles(cat, only(k), area),\n (k) => tileMin(cat, k),\n cat.born,\n );\n return { tree: only(kept), floats };\n}\n\n// --- tabbed sides --------------------------------------------------------------------------------------------------\n\n/**\n * One side with tabs: the tab row on top, the active panel under it, the others hidden behind it. `float` puts\n * them over the documents (a drawer that slides over).\n */\nexport function tabbed(out: Out, side: Side, ids: readonly number[], active: number | null, x: number, y: number, w: number, h: number, float: boolean): void {\n const shown = active !== null && ids.includes(active) ? active : (ids[0] ?? null);\n out.set(`tabs:${side}`, { rect: rect(x, y, w, TABS), look: \"tabs\", layer: float ? LAYER.float : LAYER.dock, tabs: ids, active: shown, ...(float ? { shadow: true } : {}) });\n for (const id of ids) {\n const r = rect(x, y + TABS, w, h - TABS);\n out.set(panelKey(id), { rect: r, look: \"bare\", layer: float ? LAYER.float : LAYER.dock, ...(id === shown ? {} : { hidden: true }), ...(float ? { shadow: true } : {}) });\n }\n}\n\n/** A side folded to its rail: the tab row and the panels hidden into it. */\nexport function tabbedIntoRail(cat: Catalog, out: Out, side: Side, ids: readonly number[], x: number, y: number, w: number): void {\n out.set(`tabs:${side}`, { rect: rect(side === \"left\" ? x : x + RAIL - w, y, w, TABS), look: \"tabs\", layer: LAYER.dock, tabs: ids, active: null, hidden: true });\n intoRail(cat, out, x, y, w, ids, side);\n}\n\n/** Below these widths a drawer slides over the documents instead of pushing them. */\nexport const DRAWER_DOCK = { left: 760, right: 1040 } as const;\n\n// --- the scrolling strip -------------------------------------------------------------------------------------------\n\nconst STRIP_PANEL_W = 180;\nconst stripDocW =(W: number): number => Math.max(360, Math.min(520, W * 0.5));\nexport const stripMin = (cat: Catalog, k: string): number => (isDocKey(k) ? DOC_MIN.height : cat.natural(idOf(k)));\n\n/** The strip's columns as laid out: a column whose minimums don't fit the height splits in two, recursively. */\nexport function stripColumns(cat: Catalog, cols: readonly (readonly string[])[], h: number, notes: Note[] = []): string[][] {\n const split = (keys: readonly string[]): string[][] => {\n const need = keys.reduce((sum, k) => sum + stripMin(cat, k), 0) + G * (keys.length - 1);\n if (need <= h || keys.length === 1) return [[...keys]];\n const half = Math.ceil(keys.length / 2);\n notes.push({ code: \"column-split\", items: [...keys], text: `${keys.map(cat.title).join(\" + \")} split into two columns` });\n return [...split(keys.slice(0, half)), ...split(keys.slice(half))];\n };\n return cols.flatMap(split);\n}\n\nexport interface StripGeometry {\n readonly cols: string[][];\n /** Each column's left edge on the stage (scroll applied) and width. */\n readonly xs: number[];\n readonly widths: number[];\n readonly y: number;\n readonly h: number;\n /** The whole strip's width, and how far it is scrolled. */\n readonly total: number;\n readonly scroll: number;\n}\n\n/** The strip's columns and scroll: scrolled by hand, else to centre the focused document's column. */\nexport function stripGeometry(cat: Catalog, s: DeskState, size: Size, notes: Note[] = []): StripGeometry {\n const { width: W, height: H } = size;\n const y = BAR + G;\n const h = H - BAR - 2 * G;\n const cols = stripColumns(cat, s.cols, h, notes);\n const widths = cols.map((c) => (c.some(isDocKey) ? stripDocW(W) : STRIP_PANEL_W));\n const total = widths.reduce((a, b) => a + b, 0) + G * (cols.length + 1);\n const want = s.focus !== null ? docKey(s.focus) : null;\n let fi = cols.findIndex((c) => want !== null && c.includes(want));\n if (fi < 0) fi = cols.findIndex((c) => c.some(isDocKey));\n const xsAbs: number[] = [];\n let x = G;\n for (const w of widths) {\n xsAbs.push(x);\n x += w + G;\n }\n const focusX = fi >= 0 ? xsAbs[fi]! + widths[fi]! / 2 : 0;\n const scroll = Math.max(0, Math.min(total - W, s.stripScroll ?? focusX - W / 2));\n return { cols, xs: xsAbs.map((v) => v - scroll), widths, y, h, total, scroll };\n}\n\n// --- floating palettes ---------------------------------------------------------------------------------------------\n\nexport const paletteWidth = (W: number): number => Math.min(200, Math.max(140, W * 0.22));\n/** Narrower than this, both stacks share the right corner. */\nexport const PALETTE_NARROW = 640;\n/** The margin palettes keep from the area's edges when they float over the documents. */\nexport const OVER_MARGIN = 14;\n\n/**\n * Palettes at their natural size, stacked in the top corners of `area` (`m` in from its edges), and the free ones\n * where they were put; a stack too tall for the area shades its least recently used palettes to their title bars.\n */\nexport function palettes(cat: Catalog, s: DeskState, area: Rect, W: number, m: number, notes: Note[] = []): Map<number, { rect: Rect; shaded: boolean }> {\n const pw = paletteWidth(W);\n const avail = area.height - 2 * m;\n const narrow = W < PALETTE_NARROW;\n const stacks = narrow ? [[...s.stacks.left, ...s.stacks.right]] : [s.stacks.left, s.stacks.right];\n if (narrow && s.stacks.left.length && s.stacks.right.length) notes.push({ code: \"stacks-merged\", text: \"both stacks share the right corner\" });\n const out = new Map<number, { rect: Rect; shaded: boolean }>();\n let shaded = 0;\n stacks.forEach((ids, si) => {\n const folded = lruFold(s, ids, avail, cat.natural, TITLE, false);\n shaded += folded.filter((id) => !s.folded.includes(id)).length;\n const x = narrow || si === 1 ? area.x + area.width - m - pw : area.x + m;\n let y = area.y + m;\n for (const id of ids) {\n const h = folded.includes(id) ? TITLE : cat.natural(id);\n out.set(id, { rect: rect(x, y, pw, h), shaded: folded.includes(id) });\n y += h + G;\n }\n });\n for (const f of s.free) {\n const shade = s.folded.includes(f.id);\n const at = f.at ?? { x: area.x + m, y: area.y + m };\n out.set(f.id, { rect: clampInto(rect(at.x, at.y, pw, shade ? TITLE : cat.natural(f.id)), area), shaded: shade });\n }\n if (shaded) notes.push({ code: \"palettes-shaded\", text: `${plural(shaded, \"palette\", \"palettes\")} shaded to ${shaded > 1 ? \"title bars\" : \"a title bar\"}` });\n return out;\n}\n\n/** The stage area palettes and documents share (below or above the pill when it keeps its band). */\nexport function paletteArea(size: Size, opt: Options): { area: Rect } {\n const p = pill(opt, G, size.width - 2 * G, 0, size.height);\n return { area: rect(G, p.top, size.width - 2 * G, p.bottom - p.top) };\n}\n\n/**\n * A floating pill among palettes: in a stretch of its band that no palette crosses, so it never covers one. Of the\n * stretches wide enough for a full-width pill (its minimum plus margins), the one nearest the centre; with none, the\n * widest, the pill shrunk to fit it.\n */\nexport function pillBetween(opt: Options, size: Size, blocks: readonly Rect[]): Placed {\n const band = pill(opt, G, size.width - 2 * G, 0, size.height).placed.rect;\n const spans = blocks\n .filter((r) => r.y < band.y + band.height && r.y + r.height > band.y)\n .map((r) => [r.x - G, r.x + r.width + G] as const)\n .sort((a, b) => a[0] - b[0]);\n const stretches: [number, number][] = [];\n let x = G;\n for (const [b0, b1] of spans) {\n if (b0 > x) stretches.push([x, b0]);\n x = Math.max(x, b1);\n }\n if (size.width - G > x) stretches.push([x, size.width - G]);\n const roomy = stretches.filter(([a, b]) => b - a >= PILL_MIN + 24);\n const mid = size.width / 2;\n const pick =\n roomy.sort((p, q) => Math.abs((p[0] + p[1]) / 2 - mid) - Math.abs((q[0] + q[1]) / 2 - mid))[0] ??\n stretches.sort((p, q) => q[1] - q[0] - (p[1] - p[0]))[0] ??\n ([G, G] as [number, number]);\n const placed = pill(opt, pick[0], pick[1] - pick[0], 0, size.height).placed;\n const room = pick[1] - pick[0];\n // Too little room for even the shortest pill: it shrinks to the room rather than cover a palette.\n return placed.rect.width <= room ? placed : { ...placed, rect: { ...placed.rect, x: pick[0], width: Math.max(0, room) } };\n}\n\n/** The documents' band between the palettes on the left half and those on the right half. */\nexport function aroundDocs(pals: ReadonlyMap<number, { rect: Rect }>, area: Rect): Rect {\n const mid = area.x + area.width / 2;\n const rects = [...pals.values()].map((p) => p.rect);\n const left = rects.filter((r) => r.x + r.width / 2 < mid);\n const right = rects.filter((r) => r.x + r.width / 2 >= mid);\n const x0 = left.length ? Math.max(...left.map((r) => r.x + r.width)) + G : area.x;\n const x1 = right.length ? Math.min(...right.map((r) => r.x)) - G : area.x + area.width;\n return rect(x0, area.y, Math.max(0, x1 - x0), area.height);\n}\n"],"mappings":";;;;;;AAUO,IAAM,IAAI;AAEV,IAAM,MAAM;AAEZ,IAAM,OAAO;AAEb,IAAM,QAAQ;AAEd,IAAM,OAAO;AAEb,IAAM,UAAgB,EAAE,OAAO,KAAK,QAAQ,IAAI;AAGhD,IAAM,WAAW,CAAC,OAAuB,SAAS,EAAE;AACpD,IAAM,SAAS,CAAC,OAAuB,OAAO,EAAE;AAChD,IAAM,aAAa,CAAC,QAAyB,IAAI,WAAW,QAAQ;AACpE,IAAM,WAAW,CAAC,QAAyB,IAAI,WAAW,MAAM;AAChE,IAAM,OAAO,CAAC,QAAwB,OAAO,IAAI,MAAM,IAAI,QAAQ,GAAG,IAAI,CAAC,CAAC;AA0C5E,SAAS,UAAU,MAAyB;AACjD,QAAM,OAAO,IAAI,IAAI,KAAK,OAAO,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC;AACtD,QAAM,SAAS,KAAK,UAAU,KAAK,OAAO,IAAI,CAAC,MAAM,EAAE,EAAE;AACzD,QAAM,WAAW,KAAK,aAAa,CAAC,OAAe,YAAY,EAAE;AACjE,QAAM,EAAE,MAAM,OAAO,OAAO,IAAI,KAAK;AACrC,QAAM,OAAO,CAAC,GAAG,OAAO,GAAG,MAAM;AACjC,QAAM,QAA6B;AAAA,IACjC;AAAA,IACA;AAAA,IACA;AAAA,IACA,QAAQ,KAAK,MAAM,UAAU,EAAE,MAAM,KAAK,CAAC,KAAK,MAAM,OAAO,MAAM,GAAG,EAAE,KAAK,KAAK;AAAA,IAClF,MAAM,K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C,MAAkB;AACtF,QAAM,MAAM,KAAK,IAAI,KAAK,QAAQ;AAClC,QAAM,QAAQ,CAAC,GAAG,KAAK,OAAO,CAAC,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI;AAClD,QAAM,OAAO,MAAM,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,QAAQ,IAAI,GAAG;AACxD,QAAM,QAAQ,MAAM,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,QAAQ,KAAK,GAAG;AAC1D,QAAM,KAAK,KAAK,SAAS,KAAK,IAAI,GAAG,KAAK,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,IAAI,KAAK;AAChF,QAAM,KAAK,MAAM,SAAS,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,IAAI,KAAK,IAAI,KAAK;AACjF,SAAO,KAAK,IAAI,KAAK,GAAG,KAAK,IAAI,GAAG,KAAK,EAAE,GAAG,KAAK,MAAM;AAC3D;","names":["kept"]}
|
|
1
|
+
{"version":3,"sources":["../src/dock/model.ts","../src/dock/arrange.ts","../src/dock/parts.ts"],"sourcesContent":["/**\n * The desk's model: panels and documents, the options, the state every construction keeps, and what a layout\n * returns (a placed rect per item). The panels themselves (their titles and natural heights) come from the\n * consumer as a catalog; see `createDesk`.\n */\nimport type { Rect, Size } from \"../geometry\";\n\nexport type Side = \"left\" | \"right\";\n\n/** Gaps and sizes, in stage px. */\nexport const G = 6;\n/** A toolbar bar's height (the pill is 4 px thinner). */\nexport const BAR = 34;\n/** A rail's width. */\nexport const RAIL = 34;\n/** A folded section's (or a shaded palette's) height: its title bar. */\nexport const TITLE = 22;\n/** A tab row's height (navigator sides and drawers). */\nexport const TABS = 28;\n/** The smallest a tiled document may be where a construction promises it (the tiling tree, the strip). */\nexport const DOC_MIN: Size = { width: 240, height: 160 };\n\n/** Items are keyed \"panel:<id>\" and \"doc:<id>\". */\nexport const panelKey = (id: number): string => `panel:${id}`;\nexport const docKey = (id: number): string => `doc:${id}`;\nexport const isPanelKey = (key: string): boolean => key.startsWith(\"panel:\");\nexport const isDocKey = (key: string): boolean => key.startsWith(\"doc:\");\nexport const idOf = (key: string): number => Number(key.slice(key.indexOf(\":\") + 1));\n\n/** A tool panel: its title and the height its content needs (its natural height, title bar included). */\nexport interface PanelSpec {\n readonly id: number;\n readonly title: string;\n readonly natural: number;\n}\n\n/** Where the panels start. Unset parts follow from the sides (see `createDesk`). */\nexport interface DeskStart {\n readonly left: readonly number[];\n readonly right: readonly number[];\n readonly bottom: readonly number[];\n readonly active?: { readonly left: number | null; readonly right: number | null };\n readonly tree?: DeskState[\"tree\"];\n readonly cols?: DeskState[\"cols\"];\n readonly stacks?: DeskState[\"stacks\"];\n}\n\n/** What a desk is made of: its panels, its documents' titles and where the panels start. */\nexport interface DeskSpec {\n readonly panels: readonly PanelSpec[];\n /** A document's title (default \"Document <id>\"). */\n readonly docTitle?: (id: number) => string;\n readonly start: DeskStart;\n /** The panels in the order they were opened (default: as listed); the tiling tree floats the newest first. */\n readonly opened?: readonly number[];\n}\n\n/** The catalog every part reads: a panel's natural height, an item's title and age. */\nexport interface Catalog {\n readonly panelIds: readonly number[];\n readonly natural: (id: number) => number;\n /** An item's title by key (\"panel:<id>\", \"doc:<id>\"); any other key is its own title. */\n readonly title: (key: string) => string;\n /** An item's age: higher is newer (panels in the order they were opened, then the documents). */\n readonly born: (key: string) => number;\n readonly start: Required<DeskStart>;\n}\n\n/** The catalog for a spec (unset start parts filled in). */\nexport function catalogOf(spec: DeskSpec): Catalog {\n const byId = new Map(spec.panels.map((p) => [p.id, p]));\n const opened = spec.opened ?? spec.panels.map((p) => p.id);\n const docTitle = spec.docTitle ?? ((id: number) => `Document ${id}`);\n const { left, right, bottom } = spec.start;\n const rest = [...right, ...bottom];\n const start: Required<DeskStart> = {\n left,\n right,\n bottom,\n active: spec.start.active ?? { left: left[0] ?? null, right: right.at(-1) ?? null },\n tree: spec.start.tree ?? { L: left.map(panelKey), R: rest.map(panelKey), C: [] },\n cols: spec.start.cols ?? [left.map(panelKey), rest.map(panelKey)].filter((c) => c.length > 0),\n stacks: spec.start.stacks ?? { left, right: rest },\n };\n return {\n panelIds: spec.panels.map((p) => p.id),\n natural: (id) => byId.get(id)?.natural ?? TITLE,\n title: (key) => (isPanelKey(key) ? (byId.get(idOf(key))?.title ?? key) : isDocKey(key) ? docTitle(idOf(key)) : key),\n born: (key) => (isDocKey(key) ? 1000 + idOf(key) : opened.indexOf(idOf(key)) + 1),\n start,\n };\n}\n\n/** Where the toolbar floats (top or bottom) and whether the documents keep a band clear for it; the bottom dock's mode. */\nexport interface Options {\n readonly toolbar: \"top\" | \"bottom\";\n readonly toolbarSpace: \"reserved\" | \"overlay\";\n readonly bottom: \"reserved\" | \"overlay\" | \"off\";\n /** The pill's width when its contents need more than the default; unset: the default. */\n readonly toolbarWidth?: number;\n /** The pill holds nothing: it takes no space and isn't shown. */\n readonly toolbarHidden?: boolean;\n}\nexport const DEFAULT_OPTIONS: Options = { toolbar: \"top\", toolbarSpace: \"reserved\", bottom: \"reserved\" };\n\n/** A panel placed freely (torn off, or a palette out of its stack): its top-left corner, null for the default spot. */\nexport interface Free {\n readonly id: number;\n readonly at: { readonly x: number; readonly y: number } | null;\n}\n\n/**\n * Everything any construction keeps. Each construction has its own copy (its own arrangement) and reads only what\n * it uses; the open documents are the same in all of them.\n */\nexport interface DeskState {\n /** Open document ids, in open order. */\n readonly docs: readonly number[];\n readonly focus: number | null;\n /** Panel ids, least recently used first: what folds or shades first when height runs out. */\n readonly recent: readonly number[];\n /** Sections folded (palettes shaded) by hand. */\n readonly folded: readonly number[];\n /** Docks, navigator sides and drawers: the panels on each side, top to bottom (tabs: left to right). */\n readonly left: readonly number[];\n readonly right: readonly number[];\n /** The bottom dock's panels (edge docks only). */\n readonly bottom: readonly number[];\n /** Docks or drawers folded to their rail by hand. */\n readonly closed: readonly Side[];\n /** The side opened last by hand: when width runs out it folds last. */\n readonly opened: Side | null;\n /** The panel showing on each side (navigator, drawers). */\n readonly active: { readonly left: number | null; readonly right: number | null };\n /** Panels torn off a dock, floating (edge docks + tear-off). */\n readonly torn: readonly Free[];\n /** The tiling tree: item keys in the left column, the right column and the center (dwindle order). */\n readonly tree: { readonly L: readonly string[]; readonly R: readonly string[]; readonly C: readonly string[] };\n /** The scrolling strip: its columns, left to right, each a list of item keys top to bottom. */\n readonly cols: readonly (readonly string[])[];\n /** The strip scrolled by hand, or null: it scrolls to the focus. */\n readonly stripScroll: number | null;\n /** Palettes: the corner stacks, top to bottom, and the ones placed anywhere. */\n readonly stacks: { readonly left: readonly number[]; readonly right: readonly number[] };\n readonly free: readonly Free[];\n}\n\n/** How an item is drawn. */\nexport type Look =\n | \"pill\" // the toolbar floating as a rounded pill\n | \"bar\" // the toolbar as a bar across the top\n | \"section\" // a panel open in a dock\n | \"header\" // a section folded (or a palette shaded) to its title bar\n | \"float\" // a panel floating over the documents\n | \"palette\" // a floating panel that reserves its footprint\n | \"tile\" // a panel tiled like a document\n | \"bare\" // a panel under a tab row: no title bar of its own\n | \"doc\"\n | \"rail\"\n | \"tabs\"\n | \"track\"\n | \"thumb\";\n\n/** Stacking layers, bottom to top. */\nexport const LAYER = { doc: 1, dock: 2, palette: 3, overlay: 4, float: 5, toolbar: 6 } as const;\n\n/** One item as a layout places it. */\nexport interface Placed {\n readonly rect: Rect;\n readonly look: Look;\n readonly layer: number;\n /** Folded away (into a rail, behind a tab): it goes to `rect`, hidden. */\n readonly hidden?: boolean;\n /** Never laid out below this (where the construction promises it). */\n readonly min?: Partial<Size>;\n /** It may lie outside the stage (the strip scrolls). */\n readonly offStage?: boolean;\n /** A rail's icons or a tab row's tabs (panel ids), and the active tab. */\n readonly icons?: readonly number[];\n readonly tabs?: readonly number[];\n readonly active?: number | null;\n /** Drawn with an accent outline (the bottom dock). */\n readonly accent?: boolean;\n /** Drawn with a shadow (it floats over something). */\n readonly shadow?: boolean;\n}\n\n/**\n * How a layout gave way (or what it is worth knowing about it):\n *\n * - `bottom-folded`: the bottom dock folded to its header; `dock-folded`: a side dock folded to its rail (`side`);\n * - `sections-folded`: sections folded to their headers by themselves, least recently used first;\n * - `torn-floating`: panels torn off a dock float (`items`); `torn-shaded`: some shade because they don't fit;\n * - `columns-railed`: the tiling tree's side columns are folded to rails (`side` when only one);\n * - `tiles-float`: tiles that broke a minimum float, newest first (`items`);\n * - `tabs-folded`: a tabbed side folded to icon tabs (`side`); `drawer-over`: a drawer slides over the\n * documents (`side`);\n * - `column-split`: a strip column split in two (`items`); `strip-scrolls`: the strip is wider than the stage;\n * - `stacks-merged`: both palette stacks share one corner; `palettes-shaded`: palettes shaded to title bars;\n * - `palettes-cover`, `docs-room`: how much of the documents palettes cover, and how much room they leave.\n */\nexport type NoteCode =\n | \"bottom-folded\"\n | \"dock-folded\"\n | \"sections-folded\"\n | \"torn-floating\"\n | \"torn-shaded\"\n | \"columns-railed\"\n | \"tiles-float\"\n | \"tabs-folded\"\n | \"drawer-over\"\n | \"column-split\"\n | \"strip-scrolls\"\n | \"stacks-merged\"\n | \"palettes-shaded\"\n | \"palettes-cover\"\n | \"docs-room\";\n\n/**\n * One note on a layout. `code` (and `side`, `items` where they apply) is the contract; `text` says it in English for\n * people, and its wording may change in any release.\n */\nexport interface Note {\n readonly code: NoteCode;\n readonly text: string;\n readonly side?: Side;\n /** The item keys it is about. */\n readonly items?: readonly string[];\n}\n\n/** Where everything is (\"toolbar\", \"panel:<id>\", \"doc:<id>\", \"rail:<side>\", \"tabs:<side>\", \"track\", \"thumb\"), and how it gave way. */\nexport interface Layout {\n readonly items: ReadonlyMap<string, Placed>;\n readonly notes: readonly Note[];\n}\n\n// --- state changes -------------------------------------------------------------------------------------------------\n\n/** The arrangement a catalog starts from, with these documents open (none by default). */\nexport function startState(cat: Catalog, docs: readonly number[] = []): DeskState {\n const st = cat.start;\n const base: DeskState = {\n docs: [],\n focus: null,\n recent: [...cat.panelIds],\n folded: [],\n left: [...st.left],\n right: [...st.right],\n bottom: [...st.bottom],\n closed: [],\n opened: null,\n active: st.active,\n torn: [],\n tree: st.tree,\n cols: st.cols,\n stripScroll: null,\n stacks: st.stacks,\n free: [],\n };\n return withDocs(base, docs, docs.at(-1) ?? null);\n}\n\n/**\n * The same state with these documents open: new ones join the tiling tree's center (the first one at its front)\n * and get a strip column of their own after the last document column; closed ones leave both.\n */\nexport function withDocs(s: DeskState, docs: readonly number[], focus: number | null): DeskState {\n const keys = docs.map(docKey);\n const gone = (k: string): boolean => isDocKey(k) && !keys.includes(k);\n let C = s.tree.C.filter((k) => !gone(k));\n let cols = s.cols.map((c) => c.filter((k) => !gone(k))).filter((c) => c.length > 0);\n const has = (k: string): boolean => [...s.tree.L, ...s.tree.R, ...C].includes(k);\n for (const k of keys) {\n if (!has(k)) C = C.some(isDocKey) || C.length === 0 ? [...C, k] : [k, ...C];\n if (!cols.some((c) => c.includes(k))) {\n const lastDoc = cols.map((c) => c.some(isDocKey)).lastIndexOf(true);\n const at = lastDoc >= 0 ? lastDoc + 1 : Math.min(1, cols.length);\n cols = [...cols.slice(0, at), [k], ...cols.slice(at)];\n }\n }\n const L = s.tree.L.filter((k) => !gone(k));\n const R = s.tree.R.filter((k) => !gone(k));\n const f = focus !== null && docs.includes(focus) ? focus : (docs.at(-1) ?? null);\n // A new focus: the strip scrolls to it again.\n return { ...s, docs: [...docs], focus: f, tree: { L, R, C }, cols, stripScroll: f === s.focus ? s.stripScroll : null };\n}\n\n/** Panel `id` was used: it is the last to fold when height runs out. */\nexport const touch = (s: DeskState, id: number): DeskState => ({ ...s, recent: [...s.recent.filter((x) => x !== id), id] });\n\n/** Fold or unfold a section (shade or unshade a palette) by hand; unfolding is a use. */\nexport function toggleFold(s: DeskState, id: number): DeskState {\n const folded = s.folded.includes(id);\n const next = { ...s, folded: folded ? s.folded.filter((x) => x !== id) : [...s.folded, id] };\n return folded ? touch(next, id) : next;\n}\n\n/** Fold a dock (or drawer) to its rail by hand, or open it again (then it folds last when width runs out). */\nexport function toggleClosed(s: DeskState, side: Side): DeskState {\n const closed = s.closed.includes(side);\n return closed ? { ...s, closed: s.closed.filter((x) => x !== side), opened: side } : { ...s, closed: [...s.closed, side] };\n}\n\n/** Show panel `id` on its side (navigator, drawers). */\nexport const withActive = (s: DeskState, side: Side, id: number): DeskState => touch({ ...s, active: { ...s.active, [side]: id } }, id);\n\n/** The state with `key` lifted out of wherever it is (before a drop puts it somewhere). */\nexport function liftOut(s: DeskState, key: string): DeskState {\n const dropK = (l: readonly string[]): string[] => l.filter((k) => k !== key);\n const base: DeskState = { ...s, tree: { L: dropK(s.tree.L), R: dropK(s.tree.R), C: dropK(s.tree.C) }, cols: s.cols.map(dropK).filter((c) => c.length > 0) };\n if (!isPanelKey(key)) return base;\n const id = idOf(key);\n const drop = (l: readonly number[]): number[] => l.filter((x) => x !== id);\n return {\n ...base,\n left: drop(s.left),\n right: drop(s.right),\n bottom: drop(s.bottom),\n torn: s.torn.filter((f) => f.id !== id),\n free: s.free.filter((f) => f.id !== id),\n stacks: { left: drop(s.stacks.left), right: drop(s.stacks.right) },\n active: { left: s.active.left === id ? null : s.active.left, right: s.active.right === id ? null : s.active.right },\n };\n}\n","/**\n * The arrangers the desk constructions build on, internal to `./dock`: master and stack for the documents, dwindle\n * for the tiling tree's center, stacked columns at natural heights, and the minimum-size give-way (the newest tile\n * that breaks a minimum floats). A public `./tiling` will come from a merge with a full split-tree model; these stay\n * the dock's own until then.\n */\nimport type { Rect, Size } from \"../geometry\";\n\n/**\n * Master and stack: the first id takes the left part (`ratio` of the width less the gap), the rest stack on the\n * right in equal rows. One id takes the whole area.\n */\nexport function masterStack<K>(ids: readonly K[], area: Rect, gap: number, ratio = 0.5): Map<K, Rect> {\n const out = new Map<K, Rect>();\n if (ids.length === 0) return out;\n if (ids.length === 1) {\n out.set(ids[0]!, { ...area });\n return out;\n }\n const mw = (area.width - gap) * ratio;\n out.set(ids[0]!, { x: area.x, y: area.y, width: mw, height: area.height });\n const k = ids.length - 1;\n const sh = (area.height - gap * (k - 1)) / k;\n ids.slice(1).forEach((id, i) => out.set(id, { x: area.x + mw + gap, y: area.y + i * (sh + gap), width: area.width - mw - gap, height: sh }));\n return out;\n}\n\n/** Dwindle over an order: each tile but the last splits the space left in two along its longer side. */\nexport function dwindle(area: Rect, n: number, gap: number): Rect[] {\n const out: Rect[] = [];\n let cur = { ...area };\n for (let i = 0; i < n; i++) {\n if (i === n - 1) {\n out.push(cur);\n break;\n }\n if (cur.width >= cur.height) {\n const w = (cur.width - gap) / 2;\n out.push({ x: cur.x, y: cur.y, width: w, height: cur.height });\n cur = { x: cur.x + w + gap, y: cur.y, width: w, height: cur.height };\n } else {\n const h = (cur.height - gap) / 2;\n out.push({ x: cur.x, y: cur.y, width: cur.width, height: h });\n cur = { x: cur.x, y: cur.y + h + gap, width: cur.width, height: h };\n }\n }\n return out;\n}\n\n/**\n * Heights for a column of items stacked in `avail` with gaps: each at its minimum (its natural height), the last\n * taking the rest. When the minimums don't fit, an even share instead, so the ones that break their minimum show.\n */\nexport function columnHeights(avail: number, mins: readonly number[], gap: number): number[] {\n const room = avail - gap * (mins.length - 1);\n const need = mins.reduce((a, b) => a + b, 0);\n if (need > room) return mins.map(() => room / mins.length);\n return mins.map((m, i) => (i === mins.length - 1 ? room - need + m : m));\n}\n\n/**\n * Lengths for items sharing `avail`: each gets at least its minimum, the rest of the room is shared in proportion\n * to the minimums (when the minimums don't fit, each gets its minimum).\n */\nexport function share(avail: number, mins: readonly number[]): number[] {\n const need = mins.reduce((a, b) => a + b, 0);\n const spare = Math.max(0, avail - need);\n return mins.map((m) => m + (need > 0 ? (spare * m) / need : spare / mins.length));\n}\n\n/**\n * The minimum-size give-way: while a tile is laid out below its minimum, the newest tile (highest `age`) floats and\n * the rest are laid out again. Stops when every tile keeps its minimum or one tile is left. `layout` lays out the\n * kept keys; the result says which are kept (in their order) and which float (newest first).\n */\nexport function giveWay<K>(keys: readonly K[], layout: (kept: readonly K[]) => ReadonlyMap<K, Rect>, min: (key: K) => Size, age: (key: K) => number): { kept: K[]; floats: K[] } {\n let kept = [...keys];\n const floats: K[] = [];\n for (;;) {\n const res = layout(kept);\n const broken = [...res].some(([k, r]) => r.width < min(k).width - 0.5 || r.height < min(k).height - 0.5);\n if (!broken || kept.length <= 1) return { kept, floats };\n const newest = kept.reduce((a, b) => (age(b) > age(a) ? b : a));\n kept = kept.filter((k) => k !== newest);\n floats.push(newest);\n }\n}\n","/**\n * The parts the desk constructions are built from, each pure: the toolbar pill, the documents' tiles, natural-height\n * sections (the last open one takes the rest; the least recently used fold to headers), rails, the edge docks'\n * geometry, the tiling tree's columns, the scrolling strip, tabbed sides and floating palettes.\n */\nimport { clampInto, rect, type Rect, type Size } from \"../geometry\";\nimport { columnHeights, dwindle, giveWay, masterStack } from \"./arrange\";\nimport { BAR, DOC_MIN, G, LAYER, RAIL, TABS, TITLE, docKey, idOf, isDocKey, panelKey, type Catalog, type DeskState, type Note, type Options, type Placed, type Side } from \"./model\";\n\nexport type Out = Map<string, Placed>;\n\nexport const plural = (n: number, one: string, many: string): string => `${n} ${n > 1 ? many : one}`;\n\n// --- the toolbar pill and the documents ----------------------------------------------------------------------------\n\n/** The shortest a pill gets (unless there is less room than that). */\nexport const PILL_MIN = 60;\n\n/**\n * The toolbar pill, floating at the top or the bottom of the band [y0, y1] above a region `cx`..`cx + cw`; returns\n * the pill and the band left for the documents (reserved: they keep clear of it; overlay: it floats over them).\n */\nexport function pill(opt: Options, cx: number, cw: number, y0: number, y1: number): { placed: Placed; top: number; bottom: number } {\n const pw = Math.max(PILL_MIN, Math.min(opt.toolbarWidth ?? 320, cw - 24));\n const ph = BAR - 4;\n const atTop = opt.toolbar === \"top\";\n // A hidden pill keeps no band clear, as if it floated.\n const overlay = opt.toolbarSpace === \"overlay\" || !!opt.toolbarHidden;\n return {\n placed: { rect: rect(cx + cw / 2 - pw / 2, atTop ? y0 + G : y1 - G - ph, pw, ph), look: \"pill\", layer: LAYER.toolbar, shadow: overlay, ...(opt.toolbarHidden ? { hidden: true } : {}) },\n top: atTop && !overlay ? y0 + BAR + 2 * G : y0 + G,\n bottom: !atTop && !overlay ? y1 - BAR - 2 * G : y1 - G,\n };\n}\n\n/** The toolbar as a bar across the top of the stage. */\nexport const bar = (W: number): Placed => ({ rect: rect(0, 0, W, BAR), look: \"bar\", layer: LAYER.toolbar });\n\n/** The documents in `r`, master and stack: the first takes 56 % of the width, the rest stack on the right. */\nexport function tiles(out: Out, r: Rect, ids: readonly number[], min?: Size): void {\n for (const [id, rr] of masterStack(ids, r, G, 0.56)) out.set(docKey(id), { rect: rr, look: \"doc\", layer: LAYER.doc, ...(min ? { min } : {}) });\n}\n\n// --- sections and rails --------------------------------------------------------------------------------------------\n\n/**\n * The ones of `ids` to fold, least recently used first, until what stays open fits `avail`. An accordion keeps one\n * section open whatever (`keepOne`); a palette stack shades even its last palette rather than run off the stage.\n */\nfunction lruFold(s: DeskState, ids: readonly number[], avail: number, open: (id: number) => number, closed: number, keepOne = true): number[] {\n const byHand = ids.filter((id) => s.folded.includes(id));\n const auto: number[] = [];\n const isOpen = (id: number): boolean => !byHand.includes(id) && !auto.includes(id);\n const need = (): number => ids.reduce((sum, id) => sum + (isOpen(id) ? open(id) : closed), 0) + G * (ids.length - 1);\n const order = [...s.recent].filter((id) => ids.includes(id));\n for (const id of order) {\n if (need() <= avail || (keepOne && ids.filter(isOpen).length <= 1)) break;\n if (isOpen(id)) auto.push(id);\n }\n return [...byHand, ...auto];\n}\n\n/**\n * Natural-height sections in x, y, w, h: each open section takes its natural height and the last open one takes\n * the rest; the least recently used fold to headers until the open ones fit. Returns how many folded by themselves.\n */\nexport function accordion(cat: Catalog, out: Out, s: DeskState, x: number, y: number, w: number, h: number, ids: readonly number[]): number {\n const folded = lruFold(s, ids, h, cat.natural, TITLE);\n const open = ids.filter((id) => !folded.includes(id));\n const room = h - G * (ids.length - 1) - TITLE * (ids.length - open.length);\n const last = open.at(-1);\n const rest = room - open.reduce((sum, id) => sum + (id === last ? 0 : cat.natural(id)), 0);\n let cy = y;\n for (const id of ids) {\n const i = open.indexOf(id);\n const n = cat.natural(id);\n const hh = i < 0 ? TITLE : id === last ? Math.max(n, rest) : n;\n out.set(panelKey(id), { rect: rect(x, cy, w, hh), look: i >= 0 ? \"section\" : \"header\", layer: LAYER.dock, ...(i >= 0 ? { min: { height: n } } : {}) });\n cy += hh + G;\n }\n return folded.filter((id) => !s.folded.includes(id)).length;\n}\n\n/** A rail of icons at x, y; the rect of its icon `i`. */\nconst railIcon =(x: number, y: number, i: number): Rect => rect(x + 6, y + 10 + i * 32, RAIL - 12, 24);\n\n/** A rail (a column whose panels are all folded) at x, y, h: one icon per panel. */\nexport function rail(out: Out, side: Side, x: number, y: number, h: number, ids: readonly number[], hidden = false): void {\n out.set(`rail:${side}`, { rect: rect(x, y, RAIL, h), look: \"rail\", layer: LAYER.dock, icons: ids, ...(hidden ? { hidden } : {}) });\n}\n\n/** Panels folded into a rail: hidden, each at its icon at `w` × its natural height. */\nexport function intoRail(cat: Catalog, out: Out, x: number, y: number, w: number, ids: readonly number[], side: Side): void {\n ids.forEach((id, i) => {\n const icon = railIcon(x, y, i);\n out.set(panelKey(id), { rect: rect(side === \"left\" ? icon.x : icon.x + icon.width - w, icon.y, w, cat.natural(id)), look: \"section\", layer: LAYER.dock, hidden: true });\n });\n}\n\n// --- edge docks ----------------------------------------------------------------------------------------------------\n\n/**\n * The dock width (rail excluded, its sections 240 px wide after the gap) and the narrowest the documents may get\n * before a dock folds.\n */\nexport const DOCK = 246;\nconst WORK_MIN = 380;\n/** The bottom dock's height when open, and the most of the stage's height it takes. */\nconst BOTTOM = 190;\nconst BOTTOM_SHARE = 0.36;\n\n/** What the edge docks put where: shared by their layouts and their drop targets. */\nexport interface DockGeometry {\n /** The side docks' height (less the bottom dock's in full-width mode). */\n readonly h: number;\n /** The bottom dock's height (its header's when folded; 0 when off). */\n readonly bh: number;\n readonly lOpen: boolean;\n readonly rOpen: boolean;\n /** The right dock's panels (the bottom dock's join them when it is off). */\n readonly right: readonly number[];\n readonly bottomOn: boolean;\n readonly bottomRect: Rect | null;\n /** The documents' band, left to right. */\n readonly x0: number;\n readonly x1: number;\n}\n\n/**\n * The edge docks' give-way: the bottom dock folds to its header when the stage is short, and a whole side dock\n * folds to its rail when the documents would get narrower than WORK_MIN (the right one first, unless it was opened\n * last by hand). `mode`: the bottom dock between the side docks, or across the full width under them.\n */\nexport function dockGeometry(cat: Catalog, s: DeskState, size: Size, opt: Options, mode: \"between\" | \"full\", notes: Note[] = []): DockGeometry {\n const { width: W, height: H } = size;\n const bottomOn = opt.bottom !== \"off\" && s.bottom.length > 0;\n const right = bottomOn ? s.right : [...s.right, ...s.bottom];\n const bottomFolded = bottomOn && (H < 480 || s.bottom.every((id) => s.folded.includes(id)));\n // Open, it is BOTTOM tall, never more than BOTTOM_SHARE of the stage (but never below what its panels need).\n const bh = !bottomOn ? 0 : bottomFolded ? TITLE : Math.max(...s.bottom.map(cat.natural), Math.min(BOTTOM, BOTTOM_SHARE * H));\n if (bottomOn && H < 480) notes.push({ code: \"bottom-folded\", text: \"bottom dock folded to its header\" });\n const full = mode === \"full\";\n const h = full && bottomOn ? H - bh - G : H;\n let lOpen = s.left.length > 0 && !s.closed.includes(\"left\");\n let rOpen = right.length > 0 && !s.closed.includes(\"right\");\n const work = (): number => W - 2 * RAIL - (lOpen ? DOCK : 0) - (rOpen ? DOCK : 0) - 2 * G;\n for (const side of s.opened === \"right\" ? ([\"left\", \"right\"] as const) : ([\"right\", \"left\"] as const)) {\n if (work() >= WORK_MIN) break;\n if (side === \"right\" && rOpen) {\n rOpen = false;\n notes.push({ code: \"dock-folded\", side: \"right\", text: \"right dock folded to its rail\" });\n } else if (side === \"left\" && lOpen) {\n lOpen = false;\n notes.push({ code: \"dock-folded\", side: \"left\", text: \"left dock folded to its rail\" });\n }\n }\n const x0 = RAIL + (lOpen ? DOCK : 0) + G;\n const x1 = W - RAIL - (rOpen ? DOCK : 0) - G;\n const bottomRect = bottomOn ? (full ? rect(G, H - G - bh, W - 2 * G, bh) : rect(x0, H - G - bh, x1 - x0, bh)) : null;\n return { h, bh, lOpen, rOpen, right, bottomOn, bottomRect, x0, x1 };\n}\n\n/** The width of a torn-off panel (its height is its natural height). */\nexport const TORN_W = 200;\n\n// --- the tiling tree -----------------------------------------------------------------------------------------------\n\n/** The smallest a tile may be: a document's minimum, or a panel at its natural height. */\nexport const tileMin = (cat: Catalog, key: string): Size => (isDocKey(key) ? DOC_MIN : { width: 150, height: cat.natural(idOf(key)) });\n/** A side column's width. */\nexport const TREE_COLUMN = 180;\n\n/** The tree's tiles laid out (no floating): the left and right columns, the center by dwindle. */\nexport function treeTiles(cat: Catalog, tree: DeskState[\"tree\"], area: Rect): Map<string, Rect> {\n const res = new Map<string, Rect>();\n let x0 = area.x;\n let x1 = area.x + area.width;\n // A side column's tiles take their natural height, the last one the rest.\n const column = (list: readonly string[], x: number): void => {\n const heights = columnHeights(area.height, list.map((k) => tileMin(cat, k).height), G);\n let y = area.y;\n list.forEach((k, i) => {\n res.set(k, rect(x, y, TREE_COLUMN, heights[i]!));\n y += heights[i]! + G;\n });\n };\n if (tree.L.length) {\n column(tree.L, x0);\n x0 += TREE_COLUMN + G;\n }\n if (tree.R.length) {\n column(tree.R, x1 - TREE_COLUMN);\n x1 -= TREE_COLUMN + G;\n }\n dwindle(rect(x0, area.y, x1 - x0, area.height), tree.C.length, G).forEach((r, i) => res.set(tree.C[i]!, r));\n return res;\n}\n\n/** The sides of the tree whose column is folded to a rail at the stage's edge (closed by hand, or at a narrow start). */\nexport const treeRails = (s: DeskState): { readonly left: boolean; readonly right: boolean } => ({\n left: s.closed.includes(\"left\") && s.tree.L.length > 0,\n right: s.closed.includes(\"right\") && s.tree.R.length > 0,\n});\n\n/** The area the tree tiles: the stage under the bar, less the rails of folded columns. */\nexport const treeArea = (size: Size, s?: DeskState): Rect => {\n const r = s ? treeRails(s) : { left: false, right: false };\n const x0 = r.left ? RAIL + G : G;\n const x1 = size.width - (r.right ? RAIL + G : G);\n return rect(x0, BAR + G, x1 - x0, size.height - BAR - 2 * G);\n};\n\n/** The tree as tiled: a column folded to its rail tiles nothing. */\nexport const treeShown = (s: DeskState): DeskState[\"tree\"] => {\n const r = treeRails(s);\n return { L: r.left ? [] : s.tree.L, R: r.right ? [] : s.tree.R, C: s.tree.C };\n};\n\n/** Which tiles float: the newest tile that breaks a minimum floats, then the tree is laid out again. */\nexport function treeFloats(cat: Catalog, tree: DeskState[\"tree\"], area: Rect): { tree: DeskState[\"tree\"]; floats: string[] } {\n const only = (kept: readonly string[]): DeskState[\"tree\"] => ({ L: tree.L.filter((k) => kept.includes(k)), R: tree.R.filter((k) => kept.includes(k)), C: tree.C.filter((k) => kept.includes(k)) });\n const { kept, floats } = giveWay(\n [...tree.L, ...tree.R, ...tree.C],\n (k) => treeTiles(cat, only(k), area),\n (k) => tileMin(cat, k),\n cat.born,\n );\n return { tree: only(kept), floats };\n}\n\n// --- tabbed sides --------------------------------------------------------------------------------------------------\n\n/**\n * One side with tabs: the tab row on top, the active panel under it, the others hidden behind it. `float` puts\n * them over the documents (a drawer that slides over).\n */\nexport function tabbed(out: Out, side: Side, ids: readonly number[], active: number | null, x: number, y: number, w: number, h: number, float: boolean): void {\n const shown = active !== null && ids.includes(active) ? active : (ids[0] ?? null);\n out.set(`tabs:${side}`, { rect: rect(x, y, w, TABS), look: \"tabs\", layer: float ? LAYER.float : LAYER.dock, tabs: ids, active: shown, ...(float ? { shadow: true } : {}) });\n for (const id of ids) {\n const r = rect(x, y + TABS, w, h - TABS);\n out.set(panelKey(id), { rect: r, look: \"bare\", layer: float ? LAYER.float : LAYER.dock, ...(id === shown ? {} : { hidden: true }), ...(float ? { shadow: true } : {}) });\n }\n}\n\n/** A side folded to its rail: the tab row and the panels hidden into it. */\nexport function tabbedIntoRail(cat: Catalog, out: Out, side: Side, ids: readonly number[], x: number, y: number, w: number): void {\n out.set(`tabs:${side}`, { rect: rect(side === \"left\" ? x : x + RAIL - w, y, w, TABS), look: \"tabs\", layer: LAYER.dock, tabs: ids, active: null, hidden: true });\n intoRail(cat, out, x, y, w, ids, side);\n}\n\n/** Below these widths a drawer slides over the documents instead of pushing them. */\nexport const DRAWER_DOCK = { left: 760, right: 1040 } as const;\n\n// --- the scrolling strip -------------------------------------------------------------------------------------------\n\nconst STRIP_PANEL_W = 180;\nconst stripDocW =(W: number): number => Math.max(360, Math.min(520, W * 0.5));\nexport const stripMin = (cat: Catalog, k: string): number => (isDocKey(k) ? DOC_MIN.height : cat.natural(idOf(k)));\n\n/** The strip's columns as laid out: a column whose minimums don't fit the height splits in two, recursively. */\nexport function stripColumns(cat: Catalog, cols: readonly (readonly string[])[], h: number, notes: Note[] = []): string[][] {\n const split = (keys: readonly string[]): string[][] => {\n const need = keys.reduce((sum, k) => sum + stripMin(cat, k), 0) + G * (keys.length - 1);\n if (need <= h || keys.length === 1) return [[...keys]];\n const half = Math.ceil(keys.length / 2);\n notes.push({ code: \"column-split\", items: [...keys], text: `${keys.map(cat.title).join(\" + \")} split into two columns` });\n return [...split(keys.slice(0, half)), ...split(keys.slice(half))];\n };\n return cols.flatMap(split);\n}\n\nexport interface StripGeometry {\n readonly cols: string[][];\n /** Each column's left edge on the stage (scroll applied) and width. */\n readonly xs: number[];\n readonly widths: number[];\n readonly y: number;\n readonly h: number;\n /** The whole strip's width, and how far it is scrolled. */\n readonly total: number;\n readonly scroll: number;\n}\n\n/** The strip's columns and scroll: scrolled by hand, else to center the focused document's column. */\nexport function stripGeometry(cat: Catalog, s: DeskState, size: Size, notes: Note[] = []): StripGeometry {\n const { width: W, height: H } = size;\n const y = BAR + G;\n const h = H - BAR - 2 * G;\n const cols = stripColumns(cat, s.cols, h, notes);\n const widths = cols.map((c) => (c.some(isDocKey) ? stripDocW(W) : STRIP_PANEL_W));\n const total = widths.reduce((a, b) => a + b, 0) + G * (cols.length + 1);\n const want = s.focus !== null ? docKey(s.focus) : null;\n let fi = cols.findIndex((c) => want !== null && c.includes(want));\n if (fi < 0) fi = cols.findIndex((c) => c.some(isDocKey));\n const xsAbs: number[] = [];\n let x = G;\n for (const w of widths) {\n xsAbs.push(x);\n x += w + G;\n }\n const focusX = fi >= 0 ? xsAbs[fi]! + widths[fi]! / 2 : 0;\n const scroll = Math.max(0, Math.min(total - W, s.stripScroll ?? focusX - W / 2));\n return { cols, xs: xsAbs.map((v) => v - scroll), widths, y, h, total, scroll };\n}\n\n// --- floating palettes ---------------------------------------------------------------------------------------------\n\nexport const paletteWidth = (W: number): number => Math.min(200, Math.max(140, W * 0.22));\n/** Narrower than this, both stacks share the right corner. */\nexport const PALETTE_NARROW = 640;\n/** The margin palettes keep from the area's edges when they float over the documents. */\nexport const OVER_MARGIN = 14;\n\n/**\n * Palettes at their natural size, stacked in the top corners of `area` (`m` in from its edges), and the free ones\n * where they were put; a stack too tall for the area shades its least recently used palettes to their title bars.\n */\nexport function palettes(cat: Catalog, s: DeskState, area: Rect, W: number, m: number, notes: Note[] = []): Map<number, { rect: Rect; shaded: boolean }> {\n const pw = paletteWidth(W);\n const avail = area.height - 2 * m;\n const narrow = W < PALETTE_NARROW;\n const stacks = narrow ? [[...s.stacks.left, ...s.stacks.right]] : [s.stacks.left, s.stacks.right];\n if (narrow && s.stacks.left.length && s.stacks.right.length) notes.push({ code: \"stacks-merged\", text: \"both stacks share the right corner\" });\n const out = new Map<number, { rect: Rect; shaded: boolean }>();\n let shaded = 0;\n stacks.forEach((ids, si) => {\n const folded = lruFold(s, ids, avail, cat.natural, TITLE, false);\n shaded += folded.filter((id) => !s.folded.includes(id)).length;\n const x = narrow || si === 1 ? area.x + area.width - m - pw : area.x + m;\n let y = area.y + m;\n for (const id of ids) {\n const h = folded.includes(id) ? TITLE : cat.natural(id);\n out.set(id, { rect: rect(x, y, pw, h), shaded: folded.includes(id) });\n y += h + G;\n }\n });\n for (const f of s.free) {\n const shade = s.folded.includes(f.id);\n const at = f.at ?? { x: area.x + m, y: area.y + m };\n out.set(f.id, { rect: clampInto(rect(at.x, at.y, pw, shade ? TITLE : cat.natural(f.id)), area), shaded: shade });\n }\n if (shaded) notes.push({ code: \"palettes-shaded\", text: `${plural(shaded, \"palette\", \"palettes\")} shaded to ${shaded > 1 ? \"title bars\" : \"a title bar\"}` });\n return out;\n}\n\n/** The stage area palettes and documents share (below or above the pill when it keeps its band). */\nexport function paletteArea(size: Size, opt: Options): { area: Rect } {\n const p = pill(opt, G, size.width - 2 * G, 0, size.height);\n return { area: rect(G, p.top, size.width - 2 * G, p.bottom - p.top) };\n}\n\n/**\n * A floating pill among palettes: in a stretch of its band that no palette crosses, so it never covers one. Of the\n * stretches wide enough for a full-width pill (its minimum plus margins), the one nearest the center; with none, the\n * widest, the pill shrunk to fit it.\n */\nexport function pillBetween(opt: Options, size: Size, blocks: readonly Rect[]): Placed {\n const band = pill(opt, G, size.width - 2 * G, 0, size.height).placed.rect;\n const spans = blocks\n .filter((r) => r.y < band.y + band.height && r.y + r.height > band.y)\n .map((r) => [r.x - G, r.x + r.width + G] as const)\n .sort((a, b) => a[0] - b[0]);\n const stretches: [number, number][] = [];\n let x = G;\n for (const [b0, b1] of spans) {\n if (b0 > x) stretches.push([x, b0]);\n x = Math.max(x, b1);\n }\n if (size.width - G > x) stretches.push([x, size.width - G]);\n const roomy = stretches.filter(([a, b]) => b - a >= PILL_MIN + 24);\n const mid = size.width / 2;\n const pick =\n roomy.sort((p, q) => Math.abs((p[0] + p[1]) / 2 - mid) - Math.abs((q[0] + q[1]) / 2 - mid))[0] ??\n stretches.sort((p, q) => q[1] - q[0] - (p[1] - p[0]))[0] ??\n ([G, G] as [number, number]);\n const placed = pill(opt, pick[0], pick[1] - pick[0], 0, size.height).placed;\n const room = pick[1] - pick[0];\n // Too little room for even the shortest pill: it shrinks to the room rather than cover a palette.\n return placed.rect.width <= room ? placed : { ...placed, rect: { ...placed.rect, x: pick[0], width: Math.max(0, room) } };\n}\n\n/** The documents' band between the palettes on the left half and those on the right half. */\nexport function aroundDocs(pals: ReadonlyMap<number, { rect: Rect }>, area: Rect): Rect {\n const mid = area.x + area.width / 2;\n const rects = [...pals.values()].map((p) => p.rect);\n const left = rects.filter((r) => r.x + r.width / 2 < mid);\n const right = rects.filter((r) => r.x + r.width / 2 >= mid);\n const x0 = left.length ? Math.max(...left.map((r) => r.x + r.width)) + G : area.x;\n const x1 = right.length ? Math.min(...right.map((r) => r.x)) - G : area.x + area.width;\n return rect(x0, area.y, Math.max(0, x1 - x0), area.height);\n}\n"],"mappings":";;;;;;AAUO,IAAM,IAAI;AAEV,IAAM,MAAM;AAEZ,IAAM,OAAO;AAEb,IAAM,QAAQ;AAEd,IAAM,OAAO;AAEb,IAAM,UAAgB,EAAE,OAAO,KAAK,QAAQ,IAAI;AAGhD,IAAM,WAAW,CAAC,OAAuB,SAAS,EAAE;AACpD,IAAM,SAAS,CAAC,OAAuB,OAAO,EAAE;AAChD,IAAM,aAAa,CAAC,QAAyB,IAAI,WAAW,QAAQ;AACpE,IAAM,WAAW,CAAC,QAAyB,IAAI,WAAW,MAAM;AAChE,IAAM,OAAO,CAAC,QAAwB,OAAO,IAAI,MAAM,IAAI,QAAQ,GAAG,IAAI,CAAC,CAAC;AA0C5E,SAAS,UAAU,MAAyB;AACjD,QAAM,OAAO,IAAI,IAAI,KAAK,OAAO,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC;AACtD,QAAM,SAAS,KAAK,UAAU,KAAK,OAAO,IAAI,CAAC,MAAM,EAAE,EAAE;AACzD,QAAM,WAAW,KAAK,aAAa,CAAC,OAAe,YAAY,EAAE;AACjE,QAAM,EAAE,MAAM,OAAO,OAAO,IAAI,KAAK;AACrC,QAAM,OAAO,CAAC,GAAG,OAAO,GAAG,MAAM;AACjC,QAAM,QAA6B;AAAA,IACjC;AAAA,IACA;AAAA,IACA;AAAA,IACA,QAAQ,KAAK,MAAM,UAAU,EAAE,MAAM,KAAK,CAAC,KAAK,MAAM,OAAO,MAAM,GAAG,EAAE,KAAK,KAAK;AA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SAAS,WAAW,MAA2C,MAAkB;AACtF,QAAM,MAAM,KAAK,IAAI,KAAK,QAAQ;AAClC,QAAM,QAAQ,CAAC,GAAG,KAAK,OAAO,CAAC,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI;AAClD,QAAM,OAAO,MAAM,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,QAAQ,IAAI,GAAG;AACxD,QAAM,QAAQ,MAAM,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,QAAQ,KAAK,GAAG;AAC1D,QAAM,KAAK,KAAK,SAAS,KAAK,IAAI,GAAG,KAAK,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,IAAI,KAAK;AAChF,QAAM,KAAK,MAAM,SAAS,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,IAAI,KAAK,IAAI,KAAK;AACjF,SAAO,KAAK,IAAI,KAAK,GAAG,KAAK,IAAI,GAAG,KAAK,EAAE,GAAG,KAAK,MAAM;AAC3D;","names":["kept"]}
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
formMain,
|
|
6
6
|
formSetsCross,
|
|
7
7
|
wrapLines
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-AE3BWTAE.js";
|
|
9
9
|
import {
|
|
10
10
|
COLUMN_REACH,
|
|
11
11
|
EPS,
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
overlaps,
|
|
18
18
|
rect,
|
|
19
19
|
subtract
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-VLTYJHUA.js";
|
|
21
21
|
|
|
22
22
|
// src/scene/model.ts
|
|
23
23
|
var SIDES = ["top", "right", "bottom", "left"];
|
|
@@ -96,6 +96,12 @@ function floatSizeOf(item, orient2 = floatOrientOf(item)) {
|
|
|
96
96
|
if (main <= 0 || cross <= 0) return DEFAULT_FLOAT_SIZE;
|
|
97
97
|
return orient2 === "row" ? { width: main, height: cross } : { width: cross, height: main };
|
|
98
98
|
}
|
|
99
|
+
function foldedByOf(item, form, start) {
|
|
100
|
+
if (item.closed || form < 1) return void 0;
|
|
101
|
+
if (foldedByHand(item)) return "hand";
|
|
102
|
+
return start !== void 0 && form > start ? "auto" : void 0;
|
|
103
|
+
}
|
|
104
|
+
var foldedByHand = (item) => Number.isFinite(item.from) && Math.floor(item.from) >= 1;
|
|
99
105
|
function pastWrap(forms, from) {
|
|
100
106
|
for (let j = Math.max(0, Math.floor(from)); j < forms.length; j++) if (forms[j].kind !== "wrap" && !forms[j].wrap) return j;
|
|
101
107
|
return void 0;
|
|
@@ -329,6 +335,7 @@ function emit(d, edge, r, solved, extra = {}) {
|
|
|
329
335
|
const drawnRect = toStage(p.rect, inMenu ? void 0 : p.id);
|
|
330
336
|
const f = formsOf(it, column ? "column" : "row")[p.form];
|
|
331
337
|
const shape = inMenu ? {} : shapeOf(f, drawnRect, column ? "column" : "row", stack.cross);
|
|
338
|
+
const foldedBy = foldedByOf(it, p.form, solved.starts.get(p.id));
|
|
332
339
|
items[p.id] = {
|
|
333
340
|
...shape,
|
|
334
341
|
hidden: inMenu ? [] : f?.hides ?? [],
|
|
@@ -342,6 +349,7 @@ function emit(d, edge, r, solved, extra = {}) {
|
|
|
342
349
|
...tabs.has(p.id) ? { tab: true } : {},
|
|
343
350
|
...tabs.has(p.id) && f?.title === true && (edge.side === "left" || edge.side === "right") ? { railTitle: edge.side } : {},
|
|
344
351
|
...solved.closedTabs.has(p.id) ? { closed: true } : {},
|
|
352
|
+
...foldedBy ? { foldedBy } : {},
|
|
345
353
|
...it.fixed ? { fixed: true } : {}
|
|
346
354
|
};
|
|
347
355
|
}
|
|
@@ -352,6 +360,8 @@ function emit(d, edge, r, solved, extra = {}) {
|
|
|
352
360
|
rect: r,
|
|
353
361
|
cross: thick,
|
|
354
362
|
menu: stack.menu ? { rect: toStage(stack.menu.rect), items: stack.menu.items } : null,
|
|
363
|
+
// The stack's items are in zone order, the order `emit` drew them in.
|
|
364
|
+
items: stack.items.map((p) => p.id),
|
|
355
365
|
tabs: solved.tabs,
|
|
356
366
|
stack,
|
|
357
367
|
free: solved.free,
|
|
@@ -372,6 +382,7 @@ function hasSetter(fit, forms) {
|
|
|
372
382
|
return fit.items.some((p) => p.kind !== "menu" && formSetsCross(forms(p.id)[p.form]));
|
|
373
383
|
}
|
|
374
384
|
var TRAY_RANK = 100;
|
|
385
|
+
var startsOf = (input) => new Map(input.items.map((i) => [i.id, i.from ?? 0]));
|
|
375
386
|
function compactEdge(f) {
|
|
376
387
|
const { scene, formsById } = f;
|
|
377
388
|
const iconsAt = (id) => {
|
|
@@ -383,9 +394,9 @@ function compactEdge(f) {
|
|
|
383
394
|
const leftOutIcons = f.ordered.filter((id) => !scene.items[id].closed && iconsAt(id) < 0);
|
|
384
395
|
const compactInput = { ...f.base, ownCross: false, items: shown.map((id) => stackItemOf(scene.items[id], formsById(id), iconsAt(id))) };
|
|
385
396
|
const stack = fitStack(compactInput, f.previous ? { previous: f.previous.free } : {});
|
|
386
|
-
return { stack, free: stack, tabs: [], closedTabs: /* @__PURE__ */ new Set(), input: compactInput, leftOutIcons };
|
|
397
|
+
return { stack, free: stack, tabs: [], closedTabs: /* @__PURE__ */ new Set(), input: compactInput, starts: startsOf(compactInput), leftOutIcons };
|
|
387
398
|
}
|
|
388
|
-
function railEdge(f, free, asStackItem) {
|
|
399
|
+
function railEdge(f, free, asStackItem, starts) {
|
|
389
400
|
const { scene, edge, formsById } = f;
|
|
390
401
|
const railIndex = (item, forms) => {
|
|
391
402
|
if (item.fixed) return -1;
|
|
@@ -415,7 +426,7 @@ function railEdge(f, free, asStackItem) {
|
|
|
415
426
|
const stack = fitStack(railInput, f.previous ? { previous: f.previous.stack } : {});
|
|
416
427
|
const tabs = stack.items.filter((p) => p.kind === "rail").map((p) => p.id);
|
|
417
428
|
const closedTabs = new Set(shown.filter((id) => scene.items[id].closed));
|
|
418
|
-
return { stack, free, tabs, closedTabs, input: railInput, leftOut };
|
|
429
|
+
return { stack, free, tabs, closedTabs, input: railInput, starts, leftOut };
|
|
419
430
|
}
|
|
420
431
|
function solveEdge(scene, edge, ids, length, room, previous) {
|
|
421
432
|
const axis = axisOf(edge.side);
|
|
@@ -458,8 +469,9 @@ function solveEdge(scene, edge, ids, length, room, previous) {
|
|
|
458
469
|
const input = { ...base, items: open2.map(asStackItem) };
|
|
459
470
|
const free = fitStack(input, previous ? { previous: previous.free } : {});
|
|
460
471
|
const none = /* @__PURE__ */ new Set();
|
|
472
|
+
const starts = startsOf(input);
|
|
461
473
|
if (column && !hasSetter(free, formsById)) {
|
|
462
|
-
const rail = railEdge(frame, free, asStackItem);
|
|
474
|
+
const rail = railEdge(frame, free, asStackItem, starts);
|
|
463
475
|
if (rail) return rail;
|
|
464
476
|
}
|
|
465
477
|
const size = edge.size;
|
|
@@ -470,10 +482,10 @@ function solveEdge(scene, edge, ids, length, room, previous) {
|
|
|
470
482
|
if (Math.abs(s - free.cross) > EPS) {
|
|
471
483
|
const sized = { ...input, cross: { ...cross, min: s, max: s } };
|
|
472
484
|
const stack = fitStack(sized, previous ? { previous: previous.stack } : {});
|
|
473
|
-
return { stack, free, tabs: [], closedTabs: none, input: sized };
|
|
485
|
+
return { stack, free, tabs: [], closedTabs: none, input: sized, starts };
|
|
474
486
|
}
|
|
475
487
|
}
|
|
476
|
-
return { stack: free, free, tabs: [], closedTabs: none, input };
|
|
488
|
+
return { stack: free, free, tabs: [], closedTabs: none, input, starts };
|
|
477
489
|
}
|
|
478
490
|
|
|
479
491
|
// src/scene/solve/bars.ts
|
|
@@ -556,7 +568,8 @@ function layFloats(d, stage, content, inset) {
|
|
|
556
568
|
if (fit.clamped) notes.push({ code: "float-clamped", id: f.id });
|
|
557
569
|
if (fit.snapped) notes.push({ code: "float-moved", id: f.id });
|
|
558
570
|
if (fit.covers.length > 0) notes.push({ code: "float-covers", id: f.id });
|
|
559
|
-
|
|
571
|
+
const foldedBy = foldedByOf(it, from);
|
|
572
|
+
items[f.id] = { ...shapeOf(form, fit.rect, fo, fit.rect.width), hidden: form?.hides ?? [], rect: fit.rect, kind: it.kind, form: from, formKind: form?.kind ?? "open", floating: true, ...foldedBy ? { foldedBy } : {} };
|
|
560
573
|
floats.push(f.id);
|
|
561
574
|
}
|
|
562
575
|
return floats;
|
|
@@ -749,10 +762,10 @@ function layRiders(d, host, riders, top) {
|
|
|
749
762
|
for (const b of bars) {
|
|
750
763
|
const at = rect(hr.x, y, hr.width, b.h);
|
|
751
764
|
const it = scene.items[b.id];
|
|
752
|
-
items[b.id] = { rect: at, hidden: b.f?.hides ?? [], kind: it.kind, form: b.form, formKind: b.f?.kind ?? "header", edge: c.edge.id, zone: zoneOf(it), rides: host.edge.id, folded: "hand" };
|
|
765
|
+
items[b.id] = { rect: at, hidden: b.f?.hides ?? [], kind: it.kind, form: b.form, formKind: b.f?.kind ?? "header", edge: c.edge.id, zone: zoneOf(it), rides: host.edge.id, folded: "hand", foldedBy: "hand" };
|
|
753
766
|
y += b.h;
|
|
754
767
|
}
|
|
755
|
-
edges[c.edge.id] = { side: c.edge.side, ring: finite(c.edge.ring, 0), rect: rect(hr.x, y0, hr.width, y - y0), cross: 0, menu: null, tabs: [], stack: c.solved.stack, free: c.solved.free, rides: host.edge.id, folded: "hand" };
|
|
768
|
+
edges[c.edge.id] = { side: c.edge.side, ring: finite(c.edge.ring, 0), rect: rect(hr.x, y0, hr.width, y - y0), cross: 0, menu: null, items: bars.map((b) => b.id), tabs: [], stack: c.solved.stack, free: c.solved.free, rides: host.edge.id, folded: "hand" };
|
|
756
769
|
}
|
|
757
770
|
}
|
|
758
771
|
function layRail(d, side, railRect, railed, g) {
|
|
@@ -794,7 +807,7 @@ function layRail(d, side, railRect, railed, g) {
|
|
|
794
807
|
const form = p ? p.form : ri >= 0 ? ri : Math.min(Math.max(0, Math.floor(finite(it.from, 0))), Math.max(0, forms.length - 1));
|
|
795
808
|
const at = p ? rect(railRect.x, railRect.y + p.rect.y, railRect.width, p.rect.height) : rect(railRect.x, y, railRect.width, ri >= 0 ? px(forms[ri].main.natural) : railRect.width);
|
|
796
809
|
const title = forms[form]?.title === true;
|
|
797
|
-
items[id] = { rect: at, hidden: forms[form]?.hides ?? [], kind: it.kind, form, formKind: "rail", edge: c.edge.id, zone: zoneOf(it), rail: side, ...title ? { railTitle: side } : {}, folded: g.auto.has(c) ? "auto" : "hand" };
|
|
810
|
+
items[id] = { rect: at, hidden: forms[form]?.hides ?? [], kind: it.kind, form, formKind: "rail", edge: c.edge.id, zone: zoneOf(it), rail: side, ...title ? { railTitle: side } : {}, folded: g.auto.has(c) ? "auto" : "hand", foldedBy: foldedByHand(it) ? "hand" : "auto" };
|
|
798
811
|
segments.push({ id, edge: c.edge.id, rect: at });
|
|
799
812
|
y += at.height;
|
|
800
813
|
}
|
|
@@ -851,7 +864,7 @@ function laySide(d, side, cols, g, area2, f, walk, upInset, tall) {
|
|
|
851
864
|
}
|
|
852
865
|
}
|
|
853
866
|
if (outsideSideBar(c)) barLaid = true;
|
|
854
|
-
const base = { side: c.edge.side, ring: finite(c.edge.ring, 0), cross: 0, menu: null, tabs: [], stack: c.solved.stack, free: c.solved.free };
|
|
867
|
+
const base = { side: c.edge.side, ring: finite(c.edge.ring, 0), cross: 0, menu: null, items: zoneSorted(scene, c.visible), tabs: [], stack: c.solved.stack, free: c.solved.free };
|
|
855
868
|
if (g.railed(c)) {
|
|
856
869
|
edges[c.edge.id] = { ...base, rect: rect(railRect.x, area2.y, 0, H), folded: g.auto.has(c) ? "auto" : "hand" };
|
|
857
870
|
continue;
|
|
@@ -946,8 +959,16 @@ function obstacleStop(drawn, obstacles, axis, drag, span) {
|
|
|
946
959
|
for (const o of obstacles) {
|
|
947
960
|
const [c0, c1] = across2(o);
|
|
948
961
|
if (c0 >= span[1] - TOUCH || c1 <= span[0] + TOUCH) continue;
|
|
949
|
-
|
|
950
|
-
|
|
962
|
+
const begin = lo(o);
|
|
963
|
+
const finish = begin + len(o);
|
|
964
|
+
const edge = drag === "start" ? lo(drawn) : lo(drawn) + len(drawn);
|
|
965
|
+
if (drag === "start") {
|
|
966
|
+
if (finish <= edge + EPS2) at = Math.max(at, finish);
|
|
967
|
+
else if (begin < edge - TOUCH) at = edge;
|
|
968
|
+
} else {
|
|
969
|
+
if (begin >= edge - EPS2) at = Math.min(at, begin);
|
|
970
|
+
else if (finish > edge + TOUCH) at = edge;
|
|
971
|
+
}
|
|
951
972
|
}
|
|
952
973
|
return drag === "start" ? Math.min(at, lo(drawn)) : Math.max(at, lo(drawn) + len(drawn));
|
|
953
974
|
}
|
|
@@ -1511,10 +1532,10 @@ function reservedRect(scene, l, id) {
|
|
|
1511
1532
|
const shift = it.zone === "end" ? len - keep2 : it.zone === "center" ? (len - keep2) / 2 : 0;
|
|
1512
1533
|
return column ? rect(it.rect.x, it.rect.y + shift, it.rect.width, keep2) : rect(it.rect.x + shift, it.rect.y, keep2, it.rect.height);
|
|
1513
1534
|
}
|
|
1514
|
-
function slotAt(c, zone, line, id, place,
|
|
1535
|
+
function slotAt(c, zone, line, id, place, lands, home = false) {
|
|
1515
1536
|
const result = c.settle(use(moveTo(c.scene, c.dragged, place), c.dragged));
|
|
1516
1537
|
const isHome = home || c.isHome(result);
|
|
1517
|
-
return { zone, line, id, place, result, home: isHome, ok: isHome || !!result.layout.items[c.dragged] &&
|
|
1538
|
+
return { zone, line, id, place, result, home: isHome, ok: isHome || !!result.layout.items[c.dragged] && lands(result) && c.sound(result.layout) };
|
|
1518
1539
|
}
|
|
1519
1540
|
function distinctSlots(c, slots) {
|
|
1520
1541
|
const landing = (s) => s.result.layout.items[c.dragged]?.rect;
|
|
@@ -1522,7 +1543,8 @@ function distinctSlots(c, slots) {
|
|
|
1522
1543
|
if (a.zone !== b.zone) return false;
|
|
1523
1544
|
if (a.home && b.home) return true;
|
|
1524
1545
|
const [p, q] = [landing(a), landing(b)];
|
|
1525
|
-
|
|
1546
|
+
const sameLine = a.place.kind === "rail" && b.place.kind === "rail" || Math.abs(a.line - b.line) < EPS;
|
|
1547
|
+
return sameLine && (!p || !q ? p === q : Math.abs(p.x - q.x) + Math.abs(p.y - q.y) + Math.abs(p.width - q.width) + Math.abs(p.height - q.height) < 0.01);
|
|
1526
1548
|
};
|
|
1527
1549
|
const wins = (o, j, s, i) => o.home !== s.home ? o.home : j < i;
|
|
1528
1550
|
return slots.filter((s, i) => !slots.some((o, j) => j !== i && sameMove(o, s) && wins(o, j, s, i)));
|
|
@@ -1575,7 +1597,7 @@ function edgeSlots(c, edge, accepts) {
|
|
|
1575
1597
|
const slotId = (zone, k) => targetId(members0.length === 0 ? { kind: "strip", edge: edge.id, zone } : { kind: "gap", edge: edge.id, zone, at: k });
|
|
1576
1598
|
const firstKind = formsOf(scene.items[dragged], axisOf(edge.side))[0]?.kind;
|
|
1577
1599
|
const titles = edge.items.filter((id) => base.items[id]?.edge === edge.id && base.items[id].fixed && !!formsOf(scene.items[id], axisOf(edge.side))[base.items[id].form]?.main.grows);
|
|
1578
|
-
const
|
|
1600
|
+
const lands = ({ layout: after }) => {
|
|
1579
1601
|
const me = after.items[dragged];
|
|
1580
1602
|
if (me.edge !== edge.id || me.inMenu) return false;
|
|
1581
1603
|
if (titles.length === 0) return true;
|
|
@@ -1615,7 +1637,7 @@ function edgeSlots(c, edge, accepts) {
|
|
|
1615
1637
|
const next = members.slice(k).find(shown);
|
|
1616
1638
|
const before = members.slice(0, k).reverse().find(shown);
|
|
1617
1639
|
const line = next ? at(occupied(next)) : before ? at(occupied(before)) + len(occupied(before)) : anchorLine[zone];
|
|
1618
|
-
const s = { ...slotAt(c, zone, line, slotId(zone, k), { kind: "gap", edge: edge.id, zone, at: k },
|
|
1640
|
+
const s = { ...slotAt(c, zone, line, slotId(zone, k), { kind: "gap", edge: edge.id, zone, at: k }, lands), order: before0 + members.slice(0, k).filter(aimed).length };
|
|
1619
1641
|
const movesFixed = members0.some((id) => {
|
|
1620
1642
|
const b = base.items[id];
|
|
1621
1643
|
const a = s.result.layout.items[id];
|
|
@@ -2124,6 +2146,12 @@ function railOuter(c, side) {
|
|
|
2124
2146
|
const barOutside = Object.values(now.edges).some((e) => e.side === side && e.rect.width > 0 && e.rect.height > 0 && (side === "left" ? e.rect.x + e.rect.width <= placeOuter + EPS : e.rect.x >= placeOuter - EPS));
|
|
2125
2147
|
return barOutside ? placeOuter : windowEdge;
|
|
2126
2148
|
}
|
|
2149
|
+
function collapsesAt(c, result, side) {
|
|
2150
|
+
const me = result.layout.items[c.dragged];
|
|
2151
|
+
if (!me || me.floating || me.inMenu || (result.scene.items[c.dragged]?.from ?? 0) < 1 || c.isHome(result) || !c.sound(result.layout)) return false;
|
|
2152
|
+
const sideOf = (edgeId) => edgeId ? result.layout.edges[edgeId]?.side : void 0;
|
|
2153
|
+
return me.rail === side || sideOf(me.rides) === side || sideOf(me.edge) === side;
|
|
2154
|
+
}
|
|
2127
2155
|
function columnLines(c, side, railLands) {
|
|
2128
2156
|
const { scene, now, dragged } = c;
|
|
2129
2157
|
const cols = scene.edges.filter((e) => e.side === side && e.column === true).map((edge) => ({ edge, l: now.edges[edge.id] })).filter((x) => x.l && !x.l.folded && !x.l.rides && x.l.cross > 0).sort((a, b) => a.edge.ring - b.edge.ring).map((x) => ({ edge: x.edge, r: x.l.rect }));
|
|
@@ -2137,7 +2165,7 @@ function columnLines(c, side, railLands) {
|
|
|
2137
2165
|
cols.forEach((x) => lines.push({ x: outerX(x.r), ring: rings.before(x.edge), at: atOf(x.edge) - 0.5 }));
|
|
2138
2166
|
if (cols.length > 0) lines.push({ x: innerX(cols[cols.length - 1].r), ring: rings.after(cols[cols.length - 1].edge), at: atOf(cols[cols.length - 1].edge) + 0.5 });
|
|
2139
2167
|
else lines.push({ x: side === "left" ? now.content.x : now.content.x + now.content.width, ring: rings.count, at: Math.max(-1, ...scene.edges.filter((e) => e.side === side).map(atOf)) + 0.5 });
|
|
2140
|
-
const
|
|
2168
|
+
const lands = (r) => {
|
|
2141
2169
|
const me = r.layout.items[dragged];
|
|
2142
2170
|
const el = me.edge ? r.layout.edges[me.edge] : void 0;
|
|
2143
2171
|
return !!el && !me.inMenu && !el.folded && !el.rides && r.scene !== c.scene;
|
|
@@ -2166,7 +2194,7 @@ function columnLines(c, side, railLands) {
|
|
|
2166
2194
|
lay: { phase: EDGE_KINDS.columnLine.phase, side, at: l.at },
|
|
2167
2195
|
vertical: false,
|
|
2168
2196
|
zones: [{ zone: "start", a: Math.max(p.zone[0], stage.x), b: Math.min(p.zone[1], stage.x + stage.width) }],
|
|
2169
|
-
slots: [slotAt(c, "start", p.line, targetId({ kind: "column", side, ring: l.ring }), { kind: "column", side, ring: l.ring },
|
|
2197
|
+
slots: [slotAt(c, "start", p.line, targetId({ kind: "column", side, ring: l.ring }), { kind: "column", side, ring: l.ring }, lands)],
|
|
2170
2198
|
refuse: () => "no-room",
|
|
2171
2199
|
own: null,
|
|
2172
2200
|
holds: false,
|
|
@@ -2218,7 +2246,8 @@ function railStops(c, side) {
|
|
|
2218
2246
|
stops2.push({ y: placeRect.y, ring: firstCol ? rings.before(firstCol) : rings.count });
|
|
2219
2247
|
}
|
|
2220
2248
|
const ownRail = now.items[dragged]?.rail === side;
|
|
2221
|
-
const
|
|
2249
|
+
const shown = !!rail && rail.segments.length > 0;
|
|
2250
|
+
const lands = (r) => shown ? collapsesAt(c, r, side) : r.layout.items[dragged].rail === side && r.scene !== c.scene;
|
|
2222
2251
|
const at = zone;
|
|
2223
2252
|
return {
|
|
2224
2253
|
id: virtualEdgeId("rail", side),
|
|
@@ -2228,7 +2257,7 @@ function railStops(c, side) {
|
|
|
2228
2257
|
lay: { phase: EDGE_KINDS.railStop.phase, side, at: -1 },
|
|
2229
2258
|
vertical: true,
|
|
2230
2259
|
zones: [{ zone: "start", a: at.y, b: at.y + at.height }],
|
|
2231
|
-
slots: stops2.map((s) => slotAt(c, "start", s.y, targetId({ kind: "rail", side, ring: s.ring }), { kind: "rail", side, ring: s.ring },
|
|
2260
|
+
slots: stops2.map((s) => slotAt(c, "start", s.y, targetId({ kind: "rail", side, ring: s.ring }), { kind: "rail", side, ring: s.ring }, lands, ownRail)),
|
|
2232
2261
|
refuse: () => "no-room",
|
|
2233
2262
|
own: null,
|
|
2234
2263
|
holds: false,
|
|
@@ -2245,12 +2274,6 @@ function railStops(c, side) {
|
|
|
2245
2274
|
|
|
2246
2275
|
// src/scene/targets/rail-strip.ts
|
|
2247
2276
|
var across = (side, outer, width) => side === "left" ? [outer, width] : [outer - width, width];
|
|
2248
|
-
function lands(c, result, side) {
|
|
2249
|
-
const me = result.layout.items[c.dragged];
|
|
2250
|
-
if (!me || me.floating || me.inMenu || (result.scene.items[c.dragged]?.from ?? 0) < 1 || c.isHome(result) || !c.sound(result.layout)) return false;
|
|
2251
|
-
const sideOf = (edgeId) => edgeId ? result.layout.edges[edgeId]?.side : void 0;
|
|
2252
|
-
return me.rail === side || sideOf(me.rides) === side || sideOf(me.edge) === side;
|
|
2253
|
-
}
|
|
2254
2277
|
function columnStrip(c, side, policy) {
|
|
2255
2278
|
const edge = railColumnOf(c.scene, side, c.kind);
|
|
2256
2279
|
if (!edge) return null;
|
|
@@ -2261,7 +2284,7 @@ function columnStrip(c, side, policy) {
|
|
|
2261
2284
|
if (moved === c.scene) return null;
|
|
2262
2285
|
const result = c.settle(use(moved, c.dragged));
|
|
2263
2286
|
const el = result.layout.edges[edge.id];
|
|
2264
|
-
if (!el || el.rect.width <= EPS || !
|
|
2287
|
+
if (!el || el.rect.width <= EPS || !collapsesAt(c, result, side)) return null;
|
|
2265
2288
|
const r = el.rect;
|
|
2266
2289
|
const railWidth = result.layout.items[c.dragged].tab ? r.width : edge.cross.rail ?? 30;
|
|
2267
2290
|
const [x, w] = across(side, side === "left" ? r.x : r.x + r.width, policy.railStripWidth ?? Math.max(RAIL_STRIP_MIN, railWidth));
|
|
@@ -2272,7 +2295,7 @@ function declaredStrip(c, side, policy) {
|
|
|
2272
2295
|
const spec = c.scene.rails?.[side];
|
|
2273
2296
|
if (!template || !spec || !zoneTakes(template, "start", c.kind) || !spec.accepts.includes(c.kind)) return null;
|
|
2274
2297
|
const stops2 = railStops(c, side);
|
|
2275
|
-
const slots = (stops2?.slots ?? []).filter((s) => !s.home && s.place.kind === "rail" &&
|
|
2298
|
+
const slots = (stops2?.slots ?? []).filter((s) => !s.home && s.place.kind === "rail" && collapsesAt(c, s.result, side)).sort((a2, b2) => a2.line - b2.line);
|
|
2276
2299
|
if (!stops2 || slots.length === 0) return null;
|
|
2277
2300
|
const a = Math.min(...stops2.zones.map((z) => z.a));
|
|
2278
2301
|
const b = Math.max(...stops2.zones.map((z) => z.b));
|
|
@@ -2305,8 +2328,14 @@ function withRailStrips(c, targets2, refusals2) {
|
|
|
2305
2328
|
const was = t.hits ?? [t.hit];
|
|
2306
2329
|
const pieces = outside(was, rects);
|
|
2307
2330
|
if (pieces.length === 0) {
|
|
2308
|
-
|
|
2309
|
-
|
|
2331
|
+
let moved = t.id.startsWith("strip:") || t.place.kind === "column" ? insideStrips(t.hit, strips) : null;
|
|
2332
|
+
let movedPieces = moved ? [moved] : [];
|
|
2333
|
+
if (moved && t.place.kind === "column") {
|
|
2334
|
+
const others = [...targets2.filter((x) => x !== t && !x.free && x.place.kind !== "none" && !(x.place.kind === "rail" && sides.has(x.place.side))).flatMap((x) => x.hits ?? [x.hit]), ...refusals2.map((x) => x.hit)];
|
|
2335
|
+
movedPieces = outside([moved], others);
|
|
2336
|
+
moved = movedPieces.length ? largest2(movedPieces) : null;
|
|
2337
|
+
}
|
|
2338
|
+
if (moved) out.push({ ...withoutHits(t), hit: moved, ...movedPieces.length > 1 ? { hits: movedPieces } : {} });
|
|
2310
2339
|
continue;
|
|
2311
2340
|
}
|
|
2312
2341
|
if (sameRects(pieces, was)) {
|
|
@@ -2518,6 +2547,29 @@ function refusals(scene, dragged, options = {}) {
|
|
|
2518
2547
|
}
|
|
2519
2548
|
var SIDE_RANK = { left: 0, top: 1, bottom: 2, right: 3 };
|
|
2520
2549
|
function stops(scene, dragged, options = {}) {
|
|
2550
|
+
const key = stopsKey(dragged, options);
|
|
2551
|
+
let memo = stopsMemo.get(scene);
|
|
2552
|
+
if (!memo) stopsMemo.set(scene, memo = /* @__PURE__ */ new Map());
|
|
2553
|
+
let list = memo.get(key);
|
|
2554
|
+
if (!list) {
|
|
2555
|
+
if (memo.size >= STOPS_PER_SCENE) memo.clear();
|
|
2556
|
+
memo.set(key, list = orderedStops(scene, dragged, options));
|
|
2557
|
+
}
|
|
2558
|
+
return [...list];
|
|
2559
|
+
}
|
|
2560
|
+
var stopsMemo = /* @__PURE__ */ new WeakMap();
|
|
2561
|
+
var STOPS_PER_SCENE = 512;
|
|
2562
|
+
var layoutIds = /* @__PURE__ */ new WeakMap();
|
|
2563
|
+
var nextLayoutId = 0;
|
|
2564
|
+
function stopsKey(dragged, o) {
|
|
2565
|
+
let prev = null;
|
|
2566
|
+
if (o.previous) {
|
|
2567
|
+
prev = layoutIds.get(o.previous) ?? nextLayoutId++;
|
|
2568
|
+
layoutIds.set(o.previous, prev);
|
|
2569
|
+
}
|
|
2570
|
+
return JSON.stringify([dragged, prev, o.endReach ?? null, o.floatOrient ?? null, o.floatSize ? [o.floatSize.width, o.floatSize.height] : null, o.fresh ?? null]);
|
|
2571
|
+
}
|
|
2572
|
+
function orderedStops(scene, dragged, options) {
|
|
2521
2573
|
const list = targets(scene, dragged, options).filter((t) => t.place.kind !== "home" && t.place.kind !== "none");
|
|
2522
2574
|
const sideOf = (t) => {
|
|
2523
2575
|
const p = t.place;
|
|
@@ -2582,4 +2634,4 @@ export {
|
|
|
2582
2634
|
refusals,
|
|
2583
2635
|
stops
|
|
2584
2636
|
};
|
|
2585
|
-
//# sourceMappingURL=chunk-
|
|
2637
|
+
//# sourceMappingURL=chunk-COK4YNMF.js.map
|