@n-uf/placement 26.11.28 → 26.11.30

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.
Files changed (49) hide show
  1. package/CHANGELOG.md +55 -0
  2. package/README.md +110 -61
  3. package/dist/{chunk-7ASCUAGV.js → chunk-3ZICYLWL.js} +2 -2
  4. package/dist/{chunk-7ASCUAGV.js.map → chunk-3ZICYLWL.js.map} +1 -1
  5. package/dist/{chunk-6GQ3PEZA.js → chunk-5CSWQSH7.js} +197 -18
  6. package/dist/chunk-5CSWQSH7.js.map +1 -0
  7. package/dist/{chunk-3RRCKN74.js → chunk-AE3BWTAE.js} +2 -2
  8. package/dist/chunk-AE3BWTAE.js.map +1 -0
  9. package/dist/{chunk-3P6VOXA6.js → chunk-AVMZIXGO.js} +2 -2
  10. package/dist/{chunk-3P6VOXA6.js.map → chunk-AVMZIXGO.js.map} +1 -1
  11. package/dist/{chunk-WLMJ6JGO.js → chunk-GIBUM6TB.js} +1 -1
  12. package/dist/chunk-GIBUM6TB.js.map +1 -0
  13. package/dist/{chunk-OYGOJWAX.js → chunk-JVAR67OL.js} +2 -2
  14. package/dist/{chunk-WM5FJ3IS.js → chunk-VLTYJHUA.js} +1 -1
  15. package/dist/{chunk-WM5FJ3IS.js.map → chunk-VLTYJHUA.js.map} +1 -1
  16. package/dist/{constructions-DSEjvWMP.d.ts → constructions-Cbz7uEAZ.d.ts} +3 -3
  17. package/dist/desk.d.ts +3 -3
  18. package/dist/desk.js +3 -3
  19. package/dist/dock.d.ts +4 -4
  20. package/dist/dock.js +2 -2
  21. package/dist/dock.js.map +1 -1
  22. package/dist/{float-fit-DRSOU_2y.d.ts → float-fit-DCYxRMru.d.ts} +1 -1
  23. package/dist/{geometry-CkZ6Fcfb.d.ts → geometry-Bf37LbCT.d.ts} +1 -1
  24. package/dist/index.d.ts +4 -4
  25. package/dist/index.js +1 -1
  26. package/dist/index.js.map +1 -1
  27. package/dist/{model-DwojiKKF.d.ts → model-BxFXr9UY.d.ts} +52 -7
  28. package/dist/{model-CPM1Lv65.d.ts → model-X7eUaKlA.d.ts} +2 -2
  29. package/dist/panels.d.ts +5 -5
  30. package/dist/panels.js +3 -3
  31. package/dist/scene-cases.d.ts +59 -15
  32. package/dist/scene-cases.js +114 -21
  33. package/dist/scene-cases.js.map +1 -1
  34. package/dist/scene.d.ts +7 -7
  35. package/dist/scene.js +9 -3
  36. package/dist/stack.d.ts +6 -6
  37. package/dist/stack.js +2 -2
  38. package/dist/{target-CEVCfJd-.d.ts → target-2RYYKkd1.d.ts} +7 -1
  39. package/dist/{targets-BPG7Kf02.d.ts → targets-Du5_4T1u.d.ts} +4 -4
  40. package/dist/targets.d.ts +14 -14
  41. package/dist/targets.js +4 -4
  42. package/dist/targets.js.map +1 -1
  43. package/dist/toolbar.d.ts +11 -11
  44. package/dist/toolbar.js +1 -1
  45. package/package.json +2 -2
  46. package/dist/chunk-3RRCKN74.js.map +0 -1
  47. package/dist/chunk-6GQ3PEZA.js.map +0 -1
  48. package/dist/chunk-WLMJ6JGO.js.map +0 -1
  49. /package/dist/{chunk-OYGOJWAX.js.map → chunk-JVAR67OL.js.map} +0 -0
package/dist/dock.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/dock/constructions.ts"],"sourcesContent":["/**\n * The nine desk constructions, presets built from the parts: a state, the stage size and the options in, a placed\n * rect per item out, plus notes saying how it gave way. How each one gives way when width or height runs out:\n *\n * - Edge docks (`docks`): sections fold to headers (least recently used first), the bottom dock folds to its\n * header, the docks fold to their rails (right first). `docksFull` runs the bottom dock across the full width.\n * - One tiling tree (`tree`): the newest tile that breaks a minimum floats.\n * - Navigator + inspector (`navigator`): the sides fold to icon tabs; height never matters.\n * - Scrolling strip (`strip`): a column whose minimums don't fit splits in two; the strip scrolls to the focus.\n * - Drawers (`drawers`): below a width a drawer slides over the documents instead of pushing them.\n * - Palettes over the documents (`floatOver`), and palettes with the documents tiled around them (`floatAround`):\n * the least recently used shade to their title bars; narrow, the stacks merge in one corner.\n * - Edge docks + tear-off (`dockTear`): as the edge docks, and torn-off panels float (and shade when they don't fit).\n */\nimport { clampInto, rect, type Size } from \"../geometry\";\nimport { columnHeights, share } from \"./arrange\";\nimport {\n DRAWER_DOCK,\n OVER_MARGIN,\n TORN_W,\n TREE_COLUMN,\n accordion,\n aroundDocs,\n bar,\n dockGeometry,\n intoRail,\n paletteArea,\n palettes,\n pill,\n pillBetween,\n plural,\n rail,\n stripGeometry,\n stripMin,\n tabbed,\n tabbedIntoRail,\n tileMin,\n tiles,\n treeArea,\n treeFloats,\n treeRails,\n treeShown,\n treeTiles,\n DOCK,\n type Out,\n} from \"./parts\";\nimport { BAR, G, LAYER, RAIL, TITLE, catalogOf, idOf, isDocKey, panelKey, startState, type Catalog, type DeskSpec, type DeskState, type Layout, type Note, type Options, type Side } from \"./model\";\n\n// --- edge docks (docks, docksFull, dockTear) ------------------------------------------------------------------------\n\nfunction docks(cat: Catalog, s: DeskState, size: { width: number; height: number }, opt: Options, mode: \"between\" | \"full\", notes: Note[]): Out {\n const out: Out = new Map();\n const { width: W, height: H } = size;\n const d = dockGeometry(cat, s, size, opt, mode, notes);\n rail(out, \"left\", 0, 0, d.h, s.left);\n rail(out, \"right\", W - RAIL, 0, d.h, d.right);\n let folded = 0;\n if (d.lOpen) folded += accordion(cat, out, s, RAIL + G, G, DOCK - G, d.h - 2 * G, s.left);\n else intoRail(cat, out, 0, 0, DOCK - G, s.left, \"left\");\n if (d.rOpen) folded += accordion(cat, out, s, W - RAIL - DOCK, G, DOCK - G, d.h - 2 * G, d.right);\n else intoRail(cat, out, W - RAIL, 0, DOCK - G, d.right, \"right\");\n if (folded) notes.push({ code: \"sections-folded\", text: `${plural(folded, \"section\", \"sections\")} folded to ${folded > 1 ? \"headers\" : \"a header\"}` });\n // Reserved: the documents end above the bottom dock. Overlay: it floats over the documents' lower part.\n const overlay = opt.bottom === \"overlay\";\n if (d.bottomRect) {\n const b = d.bottomRect;\n const n = s.bottom.length;\n const w = (b.width - G * (n - 1)) / n;\n s.bottom.forEach((id, i) => {\n const open = d.bh > TITLE;\n out.set(panelKey(id), {\n rect: rect(b.x + i * (w + G), b.y, w, b.height),\n look: overlay ? (open ? \"float\" : \"header\") : open ? \"section\" : \"header\",\n layer: overlay ? LAYER.overlay : LAYER.dock,\n accent: true,\n ...(overlay ? { shadow: true } : {}),\n ...(open ? { min: { height: cat.natural(id) } } : {}),\n });\n });\n }\n const docsBottom = d.bottomOn && !overlay ? H - G - d.bh : H;\n const p = pill(opt, d.x0, d.x1 - d.x0, 0, overlay && d.bottomOn ? H - G - d.bh : docsBottom);\n // With the bottom dock floating, the documents run down under it (but never under a reserved bottom pill).\n const bottomOfDocs = overlay && d.bottomOn && !(opt.toolbar === \"bottom\" && opt.toolbarSpace === \"reserved\") ? H - G : p.bottom;\n tiles(out, rect(d.x0, p.top, d.x1 - d.x0, bottomOfDocs - p.top), s.docs);\n out.set(\"toolbar\", p.placed);\n return out;\n}\n\n/** Tear-off: torn-off panels float over the documents; one that doesn't fit the stage's height shades to its title bar. */\nfunction tornOff(cat: Catalog, out: Out, s: DeskState, size: Size, notes: Note[]): void {\n const docRects = [...out.entries()].filter(([k]) => isDocKey(k)).map(([, p]) => p.rect);\n const right = docRects.length ? Math.max(...docRects.map((r) => r.x + r.width)) : size.width / 2;\n const top = docRects.length ? Math.min(...docRects.map((r) => r.y)) : 0;\n let shaded = 0;\n s.torn.forEach((f, i) => {\n const full = cat.natural(f.id);\n const at = f.at ?? { x: right - 12 - TORN_W - 22 * i, y: top + 40 + 22 * i };\n const fits = at.y + full <= size.height - G;\n const shade = s.folded.includes(f.id) || !fits;\n if (!fits && !s.folded.includes(f.id)) shaded++;\n const r = clampInto(rect(at.x, at.y, TORN_W, shade ? TITLE : full), rect(0, 0, size.width, size.height));\n out.set(panelKey(f.id), { rect: r, look: shade ? \"header\" : \"float\", layer: LAYER.float, shadow: true, ...(shade ? {} : { min: { height: full } }) });\n });\n if (s.torn.length) {\n const items = s.torn.map((f) => panelKey(f.id));\n notes.push({ code: \"torn-floating\", items, text: `${items.map(cat.title).join(\", \")} ${items.length > 1 ? \"float\" : \"floats\"}; drop on a dock or its rail icon to dock again` });\n }\n if (shaded) notes.push({ code: \"torn-shaded\", text: `${plural(shaded, \"floating panel\", \"floating panels\")} shaded` });\n}\n\n// --- one tiling tree (tree) --------------------------------------------------------------------------------------------\n\nfunction tree(cat: Catalog, s: DeskState, size: Size, notes: Note[]): Out {\n const out: Out = new Map();\n const area = treeArea(size, s);\n // A column folded to its rail: icons at the stage's edge, its panels hidden into them.\n const rails = treeRails(s);\n for (const side of [\"left\", \"right\"] as const) {\n if (!rails[side]) continue;\n const ids = (side === \"left\" ? s.tree.L : s.tree.R).map(idOf);\n const x = side === \"left\" ? 0 : size.width - RAIL;\n rail(out, side, x, BAR, size.height - BAR, ids);\n intoRail(cat, out, x, BAR, TREE_COLUMN, ids, side);\n }\n if (rails.left || rails.right) {\n const both = rails.left && rails.right;\n const text = `${both ? \"both side columns\" : `the ${rails.left ? \"left\" : \"right\"} column`} folded to ${both ? \"their rails\" : \"its rail\"}`;\n notes.push({ code: \"columns-railed\", text, ...(both ? {} : { side: rails.left ? \"left\" : \"right\" }) });\n }\n const { tree: t, floats } = treeFloats(cat, treeShown(s), area);\n for (const [k, r] of treeTiles(cat, t, area)) out.set(k, { rect: r, look: isDocKey(k) ? \"doc\" : \"tile\", layer: LAYER.doc, min: tileMin(cat, k) });\n floats.forEach((k, i) => {\n const m = isDocKey(k) ? { w: 300, h: 190 } : { w: 200, h: cat.natural(idOf(k)) };\n const r = clampInto(rect(size.width / 2 - m.w / 2 + 22 * i, BAR + 40 + 22 * i, m.w, m.h), rect(0, 0, size.width, size.height));\n out.set(k, { rect: r, look: isDocKey(k) ? \"doc\" : \"float\", layer: LAYER.float, shadow: true });\n });\n if (floats.length) notes.push({ code: \"tiles-float\", items: floats, text: `${plural(floats.length, \"tile floats\", \"tiles float\")} (newest first): ${floats.map(cat.title).join(\", \")}` });\n out.set(\"toolbar\", bar(size.width));\n return out;\n}\n\n/**\n * The tree's start: on a stage too narrow for the documents to tile between the side columns, the columns start folded to\n * their rails (the right one first), then the centre's panels join the folded right column, so nothing floats\n * until a rail icon opens a column.\n */\nfunction treeStart(cat: Catalog, docs: readonly number[], size?: Size): DeskState {\n const s = startState(cat, docs);\n if (!size) return s;\n const both = { ...s, closed: [\"right\", \"left\"] as Side[] };\n const panels = s.tree.C.filter((k) => !isDocKey(k));\n const tries: DeskState[] = [s, { ...s, closed: [\"right\"] }, both, { ...both, tree: { ...s.tree, R: [...s.tree.R, ...panels], C: s.tree.C.filter(isDocKey) } }];\n return tries.find((st) => treeFloats(cat, treeShown(st), treeArea(size, st)).floats.length === 0) ?? tries.at(-1)!;\n}\n\n// --- navigator + inspector (navigator), and drawers (drawers) ----------------------------------------------------------------------\n\nconst NAV_L = 240;\nconst NAV_R = 240;\nconst NAV_MIN = 380;\n\nfunction navigator(cat: Catalog, s: DeskState, size: Size, opt: Options, notes: Note[]): Out {\n const out: Out = new Map();\n const { width: W, height: H } = size;\n let lw = s.left.length ? NAV_L : 0;\n let rw = s.right.length ? NAV_R : 0;\n if (rw && W - lw - rw < NAV_MIN) {\n rw = RAIL;\n notes.push({ code: \"tabs-folded\", side: \"right\", text: \"inspector folded to icon tabs\" });\n }\n if (lw && W - lw - rw < NAV_MIN) {\n lw = RAIL;\n notes.push({ code: \"tabs-folded\", side: \"left\", text: \"navigator folded to icon tabs\" });\n }\n const side = (sd: Side, x: number, w: number, full: number, ids: readonly number[]): void => {\n if (w === RAIL) {\n rail(out, sd, x, 0, H, ids);\n tabbedIntoRail(cat, out, sd, ids, x, 0, full);\n } else if (w > 0) {\n rail(out, sd, sd === \"left\" ? x : x + w - RAIL, 0, H, ids, true);\n tabbed(out, sd, ids, s.active[sd], x, 0, w, H, false);\n }\n };\n side(\"left\", 0, lw, NAV_L, s.left);\n side(\"right\", W - rw, rw, NAV_R, s.right);\n const cx = lw + G;\n const cw = W - lw - rw - 2 * G;\n const p = pill(opt, cx, cw, 0, H);\n tiles(out, rect(cx, p.top, cw, p.bottom - p.top), s.docs);\n out.set(\"toolbar\", p.placed);\n return out;\n}\n\nconst DRAWER_L = 240;\nconst DRAWER_R = 240;\n\nfunction drawers(cat: Catalog, s: DeskState, size: Size, notes: Note[]): Out {\n const out: Out = new Map();\n const { width: W, height: H } = size;\n const y = BAR;\n const h = H - BAR;\n const rDocked = W >= DRAWER_DOCK.right;\n const lDocked = W >= DRAWER_DOCK.left;\n const lOpen = s.left.length > 0 && !s.closed.includes(\"left\");\n const rOpen = s.right.length > 0 && !s.closed.includes(\"right\");\n if (!rDocked && rOpen) notes.push({ code: \"drawer-over\", side: \"right\", text: \"right drawer slides over the documents\" });\n if (!lDocked && lOpen) notes.push({ code: \"drawer-over\", side: \"left\", text: rDocked || !rOpen ? \"left drawer slides over the documents\" : \"left drawer slides over too\" });\n rail(out, \"left\", 0, y, h, s.left);\n rail(out, \"right\", W - RAIL, y, h, s.right);\n const x0 = RAIL + (lDocked && lOpen ? DRAWER_L : 0) + G;\n const x1 = W - RAIL - (rDocked && rOpen ? DRAWER_R : 0) - G;\n tiles(out, rect(x0, y + G, x1 - x0, h - 2 * G), s.docs);\n // Both sliding over a stage too narrow for the two side by side: each takes half the room between the rails.\n const both = !lDocked && !rDocked && lOpen && rOpen;\n const half = (W - 2 * RAIL - G) / 2;\n const lw = both ? Math.min(DRAWER_L, half) : DRAWER_L;\n const rw = both ? Math.min(DRAWER_R, half) : DRAWER_R;\n if (lOpen) tabbed(out, \"left\", s.left, s.active.left, RAIL, y, lw, h, !lDocked);\n else tabbedIntoRail(cat, out, \"left\", s.left, 0, y, DRAWER_L);\n if (rOpen) tabbed(out, \"right\", s.right, s.active.right, W - RAIL - rw, y, rw, h, !rDocked);\n else tabbedIntoRail(cat, out, \"right\", s.right, W - RAIL, y, DRAWER_R);\n out.set(\"toolbar\", bar(W));\n return out;\n}\n\n// --- scrolling strip (strip) --------------------------------------------------------------------------------------------\n\nfunction strip(cat: Catalog, s: DeskState, size: Size, notes: Note[]): Out {\n const out: Out = new Map();\n const { width: W, height: H } = size;\n const g = stripGeometry(cat, s, size, notes);\n g.cols.forEach((c, ci) => {\n // A column of panels: each at its natural height, the last taking the rest; documents share as before.\n const mins = c.map((k) => stripMin(cat, k));\n const heights = c.some(isDocKey) ? share(g.h - G * (c.length - 1), mins) : columnHeights(g.h, mins, G);\n let cy = g.y;\n c.forEach((k, i) => {\n out.set(k, { rect: rect(g.xs[ci]!, cy, g.widths[ci]!, heights[i]!), look: isDocKey(k) ? \"doc\" : \"tile\", layer: LAYER.doc, offStage: true, min: { width: g.widths[ci]!, height: mins[i]! } });\n cy += heights[i]! + G;\n });\n });\n const scrolls = g.total > W;\n if (scrolls) notes.push({ code: \"strip-scrolls\", text: `the strip is ${Math.round(g.total)} wide: ${Math.round(g.total - W)} px off screen, reached by scrolling` });\n out.set(\"track\", { rect: rect(0, H - 5, W, 5), look: \"track\", layer: LAYER.toolbar, ...(scrolls ? {} : { hidden: true }) });\n const tw = scrolls ? (W / g.total) * W : W;\n out.set(\"thumb\", { rect: rect(scrolls ? (g.scroll / g.total) * W : 0, H - 5, tw, 5), look: \"thumb\", layer: LAYER.toolbar, ...(scrolls ? {} : { hidden: true }) });\n out.set(\"toolbar\", bar(W));\n return out;\n}\n\n// --- floating palettes (floatOver, floatAround) --------------------------------------------------------------------\n\nfunction floatOver(cat: Catalog, s: DeskState, size: Size, opt: Options, notes: Note[]): Out {\n const out: Out = new Map();\n const { area } = paletteArea(size, opt);\n const pals = palettes(cat, s, area, size.width, OVER_MARGIN, notes);\n const tb = pillBetween(opt, size, [...pals.values()].map((p) => p.rect));\n tiles(out, area, s.docs);\n let covered = 0;\n for (const [id, p] of pals) {\n out.set(panelKey(id), { rect: p.rect, look: p.shaded ? \"header\" : \"float\", layer: LAYER.float, shadow: true, ...(p.shaded ? {} : { min: { height: cat.natural(id) } }) });\n covered += p.rect.width * p.rect.height;\n }\n notes.push({ code: \"palettes-cover\", text: `palettes cover ${Math.round((covered / (area.width * area.height)) * 100)}% of the documents` });\n out.set(\"toolbar\", tb);\n return out;\n}\n\nfunction floatAround(cat: Catalog, s: DeskState, size: Size, opt: Options, notes: Note[]): Out {\n const out: Out = new Map();\n const { area } = paletteArea(size, opt);\n const pals = palettes(cat, s, area, size.width, 0, notes);\n const tb = pillBetween(opt, size, [...pals.values()].map((p) => p.rect));\n const docsRect = aroundDocs(pals, area);\n tiles(out, docsRect, s.docs);\n let used = docsRect.width * docsRect.height;\n for (const [id, p] of pals) {\n out.set(panelKey(id), { rect: p.rect, look: p.shaded ? \"header\" : \"palette\", layer: LAYER.palette, shadow: true, ...(p.shaded ? {} : { min: { height: cat.natural(id) } }) });\n used += p.rect.width * p.rect.height;\n }\n notes.push({ code: \"docs-room\", text: `documents get ${Math.round(docsRect.width)} px of width; ${Math.max(0, Math.round((1 - used / (area.width * area.height)) * 100))}% of the desk stays empty under short stacks` });\n out.set(\"toolbar\", tb);\n return out;\n}\n\n// --- the presets ---------------------------------------------------------------------------------------------------\n\nexport type ConstructionId = \"docks\" | \"docksFull\" | \"tree\" | \"navigator\" | \"strip\" | \"drawers\" | \"floatOver\" | \"floatAround\" | \"dockTear\";\n\nexport interface Construction {\n readonly id: ConstructionId;\n readonly title: string;\n readonly idea: string;\n /** It has a floating toolbar pill (top or bottom, reserved or overlay). */\n readonly pill: boolean;\n /** It has a bottom dock (reserved, floating or off). */\n readonly bottom: boolean;\n /** The arrangement it starts from (at this stage size, when it depends on one). */\n readonly initial: (docs: readonly number[], size?: Size) => DeskState;\n readonly layout: (s: DeskState, size: Size, opt: Options) => Layout;\n /** The desk it belongs to (its catalog). */\n readonly desk: Desk;\n}\n\n/** A desk: the catalog, its nine constructions, and the catalog-bound helpers. */\nexport interface Desk {\n readonly catalog: Catalog;\n readonly constructions: readonly Construction[];\n readonly constructionOf: (id: ConstructionId) => Construction;\n /** The arrangement every construction starts from, with these documents open (none by default). */\n readonly initialState: (docs?: readonly number[]) => DeskState;\n readonly natural: (id: number) => number;\n readonly titleOf: (key: string) => string;\n}\n\ntype LayoutFn = (s: DeskState, size: Size, opt: Options, notes: Note[]) => Out;\n\nconst withNotes = (f: LayoutFn) => (s: DeskState, size: Size, opt: Options): Layout => {\n const notes: Note[] = [];\n const items = f(s, size, opt, notes);\n return { items, notes };\n};\n\n/**\n * A desk for these panels: the nine constructions as presets, each a pure layout over the shared state.\n *\n * ```ts\n * const desk = createDesk({ panels: [{ id: 1, title: \"Files\", natural: 160 }], start: { left: [1], right: [], bottom: [] } });\n * const c = desk.constructionOf(\"docks\");\n * const { items, notes } = c.layout(c.initial([1, 2]), { width: 960, height: 560 }, DEFAULT_OPTIONS);\n * ```\n */\nexport function createDesk(spec: DeskSpec): Desk {\n const cat = catalogOf(spec);\n const initial = (docs?: readonly number[]): DeskState => startState(cat, docs);\n const sides = (patch: (s: DeskState) => Partial<DeskState>) => (docs: readonly number[]): DeskState => {\n const s = startState(cat, docs);\n return { ...s, ...patch(s) };\n };\n // Navigator and drawers have no bottom dock: its panels join the right side.\n const noBottom = sides((s) => ({ right: [...s.right, ...s.bottom], bottom: [] }));\n const plain = sides(() => ({}));\n const list: Omit<Construction, \"desk\">[] = [\n {\n id: \"docks\",\n title: \"Edge docks\",\n idea: \"Each side is a dock with a rail of icons; its panels are accordion sections. Short on height, the least recently used fold to headers; short on width, a whole dock folds to its rail (right first). The bottom dock sits between the side docks.\",\n pill: true,\n bottom: true,\n initial: plain,\n layout: withNotes((s, size, opt, notes) => docks(cat, s, size, opt, \"between\", notes)),\n },\n {\n id: \"docksFull\",\n title: \"Edge docks, full-width bottom dock\",\n idea: \"As the edge docks, except the bottom dock runs under everything across the full width; the side docks and their rails stop above it, so they fold sooner.\",\n pill: true,\n bottom: true,\n initial: plain,\n layout: withNotes((s, size, opt, notes) => docks(cat, s, size, opt, \"full\", notes)),\n },\n {\n id: \"tree\",\n title: \"One tiling tree\",\n idea: \"Panels and documents are tiles of one tree, so a panel can sit beside a document. One rule for all: the newest tile that breaks a minimum floats. Opened on a narrow stage, the side columns start folded to rails at its edges.\",\n pill: false,\n bottom: false,\n initial: (docs, size) => treeStart(cat, docs, size),\n layout: withNotes((s, size, _opt, notes) => tree(cat, s, size, notes)),\n },\n {\n id: \"navigator\",\n title: \"Navigator + inspector\",\n idea: \"A fixed left and right side, one panel showing per side (tabs); the toolbar floats over the canvas. Narrow, the sides fold to icon tabs. Height never matters.\",\n pill: true,\n bottom: false,\n initial: noBottom,\n layout: withNotes((s, size, opt, notes) => navigator(cat, s, size, opt, notes)),\n },\n {\n id: \"strip\",\n title: \"Scrolling strip\",\n idea: \"Panels and documents are columns of a strip wider than the screen; nothing shrinks below its minimum, the view scrolls to the focus instead. Short on height, a column splits in two.\",\n pill: false,\n bottom: false,\n initial: plain,\n layout: withNotes((s, size, _opt, notes) => strip(cat, s, size, notes)),\n },\n {\n id: \"drawers\",\n title: \"Drawers\",\n idea: \"Documents take the screen; each side is a drawer with tabs. Wide, the drawers dock and push; narrow, they slide over the documents.\",\n pill: false,\n bottom: false,\n initial: noBottom,\n layout: withNotes((s, size, _opt, notes) => drawers(cat, s, size, notes)),\n },\n {\n id: \"floatOver\",\n title: \"Floating palettes over the documents\",\n idea: \"Documents take the whole desk; panels are palettes floating over them at their natural size, stacked in the top corners and draggable anywhere. Short on height, the least recently used shade to their title bars; the documents never move.\",\n pill: true,\n bottom: false,\n initial: plain,\n layout: withNotes((s, size, opt, notes) => floatOver(cat, s, size, opt, notes)),\n },\n {\n id: \"floatAround\",\n title: \"Floating palettes, documents tile around\",\n idea: \"Palettes float at their natural size but reserve their footprint: the documents tile in the space between them. Nothing is covered; the space under a short stack stays empty.\",\n pill: true,\n bottom: false,\n initial: plain,\n layout: withNotes((s, size, opt, notes) => floatAround(cat, s, size, opt, notes)),\n },\n {\n id: \"dockTear\",\n title: \"Edge docks + tear-off\",\n idea: \"The edge docks, and any panel can be torn off to float over the documents and dropped back on a dock or its rail icon. Docked is the default; floating is the exception you choose.\",\n pill: true,\n bottom: true,\n initial: plain,\n layout: withNotes((s, size, opt, notes) => {\n const out = docks(cat, s, size, opt, \"between\", notes);\n tornOff(cat, out, s, size, notes);\n return out;\n }),\n },\n ];\n const constructions: Construction[] = [];\n const desk: Desk = {\n catalog: cat,\n constructions,\n constructionOf: (id) => constructions.find((c) => c.id === id)!,\n initialState: initial,\n natural: cat.natural,\n titleOf: cat.title,\n };\n constructions.push(...list.map((c) => ({ ...c, desk })));\n return desk;\n}\n\n/** Which items a construction lets the pointer drag: panels everywhere, documents in the tree and the strip. */\nexport const draggable = (c: Construction, key: string): boolean => key.startsWith(\"panel:\") || (key.startsWith(\"doc:\") && (c.id === \"tree\" || c.id === \"strip\"));\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkDA,SAAS,MAAM,KAAc,GAAc,MAAyC,KAAc,MAA0B,OAAoB;AAC9I,QAAM,MAAW,oBAAI,IAAI;AACzB,QAAM,EAAE,OAAO,GAAG,QAAQ,EAAE,IAAI;AAChC,QAAM,IAAI,aAAa,KAAK,GAAG,MAAM,KAAK,MAAM,KAAK;AACrD,OAAK,KAAK,QAAQ,GAAG,GAAG,EAAE,GAAG,EAAE,IAAI;AACnC,OAAK,KAAK,SAAS,IAAI,MAAM,GAAG,EAAE,GAAG,EAAE,KAAK;AAC5C,MAAI,SAAS;AACb,MAAI,EAAE,MAAO,WAAU,UAAU,KAAK,KAAK,GAAG,OAAO,GAAG,GAAG,OAAO,GAAG,EAAE,IAAI,IAAI,GAAG,EAAE,IAAI;AAAA,MACnF,UAAS,KAAK,KAAK,GAAG,GAAG,OAAO,GAAG,EAAE,MAAM,MAAM;AACtD,MAAI,EAAE,MAAO,WAAU,UAAU,KAAK,KAAK,GAAG,IAAI,OAAO,MAAM,GAAG,OAAO,GAAG,EAAE,IAAI,IAAI,GAAG,EAAE,KAAK;AAAA,MAC3F,UAAS,K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A,MACN,QAAQ;AAAA,MACR,SAAS;AAAA,MACT,QAAQ,UAAU,CAAC,GAAG,MAAM,KAAK,UAAU,UAAU,KAAK,GAAG,MAAM,KAAK,KAAK,CAAC;AAAA,IAChF;AAAA,IACA;AAAA,MACE,IAAI;AAAA,MACJ,OAAO;AAAA,MACP,MAAM;AAAA,MACN,MAAM;AAAA,MACN,QAAQ;AAAA,MACR,SAAS;AAAA,MACT,QAAQ,UAAU,CAAC,GAAG,MAAM,KAAK,UAAU,YAAY,KAAK,GAAG,MAAM,KAAK,KAAK,CAAC;AAAA,IAClF;AAAA,IACA;AAAA,MACE,IAAI;AAAA,MACJ,OAAO;AAAA,MACP,MAAM;AAAA,MACN,MAAM;AAAA,MACN,QAAQ;AAAA,MACR,SAAS;AAAA,MACT,QAAQ,UAAU,CAAC,GAAG,MAAM,KAAK,UAAU;AACzC,cAAM,MAAM,MAAM,KAAK,GAAG,MAAM,KAAK,WAAW,KAAK;AACrD,gBAAQ,KAAK,KAAK,GAAG,MAAM,KAAK;AAChC,eAAO;AAAA,MACT,CAAC;AAAA,IACH;AAAA,EACF;AACA,QAAM,gBAAgC,CAAC;AACvC,QAAM,OAAa;AAAA,IACjB,SAAS;AAAA,IACT;AAAA,IACA,gBAAgB,CAAC,OAAO,cAAc,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE;AAAA,IAC7D,cAAc;AAAA,IACd,SAAS,IAAI;AAAA,IACb,SAAS,IAAI;AAAA,EACf;AACA,gBAAc,KAAK,GAAG,KAAK,IAAI,CAAC,OAAO,EAAE,GAAG,GAAG,KAAK,EAAE,CAAC;AACvD,SAAO;AACT;AAGO,IAAM,YAAY,CAAC,GAAiB,QAAyB,IAAI,WAAW,QAAQ,KAAM,IAAI,WAAW,MAAM,MAAM,EAAE,OAAO,UAAU,EAAE,OAAO;","names":[]}
1
+ {"version":3,"sources":["../src/dock/constructions.ts"],"sourcesContent":["/**\n * The nine desk constructions, presets built from the parts: a state, the stage size and the options in, a placed\n * rect per item out, plus notes saying how it gave way. How each one gives way when width or height runs out:\n *\n * - Edge docks (`docks`): sections fold to headers (least recently used first), the bottom dock folds to its\n * header, the docks fold to their rails (right first). `docksFull` runs the bottom dock across the full width.\n * - One tiling tree (`tree`): the newest tile that breaks a minimum floats.\n * - Navigator + inspector (`navigator`): the sides fold to icon tabs; height never matters.\n * - Scrolling strip (`strip`): a column whose minimums don't fit splits in two; the strip scrolls to the focus.\n * - Drawers (`drawers`): below a width a drawer slides over the documents instead of pushing them.\n * - Palettes over the documents (`floatOver`), and palettes with the documents tiled around them (`floatAround`):\n * the least recently used shade to their title bars; narrow, the stacks merge in one corner.\n * - Edge docks + tear-off (`dockTear`): as the edge docks, and torn-off panels float (and shade when they don't fit).\n */\nimport { clampInto, rect, type Size } from \"../geometry\";\nimport { columnHeights, share } from \"./arrange\";\nimport {\n DRAWER_DOCK,\n OVER_MARGIN,\n TORN_W,\n TREE_COLUMN,\n accordion,\n aroundDocs,\n bar,\n dockGeometry,\n intoRail,\n paletteArea,\n palettes,\n pill,\n pillBetween,\n plural,\n rail,\n stripGeometry,\n stripMin,\n tabbed,\n tabbedIntoRail,\n tileMin,\n tiles,\n treeArea,\n treeFloats,\n treeRails,\n treeShown,\n treeTiles,\n DOCK,\n type Out,\n} from \"./parts\";\nimport { BAR, G, LAYER, RAIL, TITLE, catalogOf, idOf, isDocKey, panelKey, startState, type Catalog, type DeskSpec, type DeskState, type Layout, type Note, type Options, type Side } from \"./model\";\n\n// --- edge docks (docks, docksFull, dockTear) ------------------------------------------------------------------------\n\nfunction docks(cat: Catalog, s: DeskState, size: { width: number; height: number }, opt: Options, mode: \"between\" | \"full\", notes: Note[]): Out {\n const out: Out = new Map();\n const { width: W, height: H } = size;\n const d = dockGeometry(cat, s, size, opt, mode, notes);\n rail(out, \"left\", 0, 0, d.h, s.left);\n rail(out, \"right\", W - RAIL, 0, d.h, d.right);\n let folded = 0;\n if (d.lOpen) folded += accordion(cat, out, s, RAIL + G, G, DOCK - G, d.h - 2 * G, s.left);\n else intoRail(cat, out, 0, 0, DOCK - G, s.left, \"left\");\n if (d.rOpen) folded += accordion(cat, out, s, W - RAIL - DOCK, G, DOCK - G, d.h - 2 * G, d.right);\n else intoRail(cat, out, W - RAIL, 0, DOCK - G, d.right, \"right\");\n if (folded) notes.push({ code: \"sections-folded\", text: `${plural(folded, \"section\", \"sections\")} folded to ${folded > 1 ? \"headers\" : \"a header\"}` });\n // Reserved: the documents end above the bottom dock. Overlay: it floats over the documents' lower part.\n const overlay = opt.bottom === \"overlay\";\n if (d.bottomRect) {\n const b = d.bottomRect;\n const n = s.bottom.length;\n const w = (b.width - G * (n - 1)) / n;\n s.bottom.forEach((id, i) => {\n const open = d.bh > TITLE;\n out.set(panelKey(id), {\n rect: rect(b.x + i * (w + G), b.y, w, b.height),\n look: overlay ? (open ? \"float\" : \"header\") : open ? \"section\" : \"header\",\n layer: overlay ? LAYER.overlay : LAYER.dock,\n accent: true,\n ...(overlay ? { shadow: true } : {}),\n ...(open ? { min: { height: cat.natural(id) } } : {}),\n });\n });\n }\n const docsBottom = d.bottomOn && !overlay ? H - G - d.bh : H;\n const p = pill(opt, d.x0, d.x1 - d.x0, 0, overlay && d.bottomOn ? H - G - d.bh : docsBottom);\n // With the bottom dock floating, the documents run down under it (but never under a reserved bottom pill).\n const bottomOfDocs = overlay && d.bottomOn && !(opt.toolbar === \"bottom\" && opt.toolbarSpace === \"reserved\") ? H - G : p.bottom;\n tiles(out, rect(d.x0, p.top, d.x1 - d.x0, bottomOfDocs - p.top), s.docs);\n out.set(\"toolbar\", p.placed);\n return out;\n}\n\n/** Tear-off: torn-off panels float over the documents; one that doesn't fit the stage's height shades to its title bar. */\nfunction tornOff(cat: Catalog, out: Out, s: DeskState, size: Size, notes: Note[]): void {\n const docRects = [...out.entries()].filter(([k]) => isDocKey(k)).map(([, p]) => p.rect);\n const right = docRects.length ? Math.max(...docRects.map((r) => r.x + r.width)) : size.width / 2;\n const top = docRects.length ? Math.min(...docRects.map((r) => r.y)) : 0;\n let shaded = 0;\n s.torn.forEach((f, i) => {\n const full = cat.natural(f.id);\n const at = f.at ?? { x: right - 12 - TORN_W - 22 * i, y: top + 40 + 22 * i };\n const fits = at.y + full <= size.height - G;\n const shade = s.folded.includes(f.id) || !fits;\n if (!fits && !s.folded.includes(f.id)) shaded++;\n const r = clampInto(rect(at.x, at.y, TORN_W, shade ? TITLE : full), rect(0, 0, size.width, size.height));\n out.set(panelKey(f.id), { rect: r, look: shade ? \"header\" : \"float\", layer: LAYER.float, shadow: true, ...(shade ? {} : { min: { height: full } }) });\n });\n if (s.torn.length) {\n const items = s.torn.map((f) => panelKey(f.id));\n notes.push({ code: \"torn-floating\", items, text: `${items.map(cat.title).join(\", \")} ${items.length > 1 ? \"float\" : \"floats\"}; drop on a dock or its rail icon to dock again` });\n }\n if (shaded) notes.push({ code: \"torn-shaded\", text: `${plural(shaded, \"floating panel\", \"floating panels\")} shaded` });\n}\n\n// --- one tiling tree (tree) --------------------------------------------------------------------------------------------\n\nfunction tree(cat: Catalog, s: DeskState, size: Size, notes: Note[]): Out {\n const out: Out = new Map();\n const area = treeArea(size, s);\n // A column folded to its rail: icons at the stage's edge, its panels hidden into them.\n const rails = treeRails(s);\n for (const side of [\"left\", \"right\"] as const) {\n if (!rails[side]) continue;\n const ids = (side === \"left\" ? s.tree.L : s.tree.R).map(idOf);\n const x = side === \"left\" ? 0 : size.width - RAIL;\n rail(out, side, x, BAR, size.height - BAR, ids);\n intoRail(cat, out, x, BAR, TREE_COLUMN, ids, side);\n }\n if (rails.left || rails.right) {\n const both = rails.left && rails.right;\n const text = `${both ? \"both side columns\" : `the ${rails.left ? \"left\" : \"right\"} column`} folded to ${both ? \"their rails\" : \"its rail\"}`;\n notes.push({ code: \"columns-railed\", text, ...(both ? {} : { side: rails.left ? \"left\" : \"right\" }) });\n }\n const { tree: t, floats } = treeFloats(cat, treeShown(s), area);\n for (const [k, r] of treeTiles(cat, t, area)) out.set(k, { rect: r, look: isDocKey(k) ? \"doc\" : \"tile\", layer: LAYER.doc, min: tileMin(cat, k) });\n floats.forEach((k, i) => {\n const m = isDocKey(k) ? { w: 300, h: 190 } : { w: 200, h: cat.natural(idOf(k)) };\n const r = clampInto(rect(size.width / 2 - m.w / 2 + 22 * i, BAR + 40 + 22 * i, m.w, m.h), rect(0, 0, size.width, size.height));\n out.set(k, { rect: r, look: isDocKey(k) ? \"doc\" : \"float\", layer: LAYER.float, shadow: true });\n });\n if (floats.length) notes.push({ code: \"tiles-float\", items: floats, text: `${plural(floats.length, \"tile floats\", \"tiles float\")} (newest first): ${floats.map(cat.title).join(\", \")}` });\n out.set(\"toolbar\", bar(size.width));\n return out;\n}\n\n/**\n * The tree's start: on a stage too narrow for the documents to tile between the side columns, the columns start folded to\n * their rails (the right one first), then the center's panels join the folded right column, so nothing floats\n * until a rail icon opens a column.\n */\nfunction treeStart(cat: Catalog, docs: readonly number[], size?: Size): DeskState {\n const s = startState(cat, docs);\n if (!size) return s;\n const both = { ...s, closed: [\"right\", \"left\"] as Side[] };\n const panels = s.tree.C.filter((k) => !isDocKey(k));\n const tries: DeskState[] = [s, { ...s, closed: [\"right\"] }, both, { ...both, tree: { ...s.tree, R: [...s.tree.R, ...panels], C: s.tree.C.filter(isDocKey) } }];\n return tries.find((st) => treeFloats(cat, treeShown(st), treeArea(size, st)).floats.length === 0) ?? tries.at(-1)!;\n}\n\n// --- navigator + inspector (navigator), and drawers (drawers) ----------------------------------------------------------------------\n\nconst NAV_L = 240;\nconst NAV_R = 240;\nconst NAV_MIN = 380;\n\nfunction navigator(cat: Catalog, s: DeskState, size: Size, opt: Options, notes: Note[]): Out {\n const out: Out = new Map();\n const { width: W, height: H } = size;\n let lw = s.left.length ? NAV_L : 0;\n let rw = s.right.length ? NAV_R : 0;\n if (rw && W - lw - rw < NAV_MIN) {\n rw = RAIL;\n notes.push({ code: \"tabs-folded\", side: \"right\", text: \"inspector folded to icon tabs\" });\n }\n if (lw && W - lw - rw < NAV_MIN) {\n lw = RAIL;\n notes.push({ code: \"tabs-folded\", side: \"left\", text: \"navigator folded to icon tabs\" });\n }\n const side = (sd: Side, x: number, w: number, full: number, ids: readonly number[]): void => {\n if (w === RAIL) {\n rail(out, sd, x, 0, H, ids);\n tabbedIntoRail(cat, out, sd, ids, x, 0, full);\n } else if (w > 0) {\n rail(out, sd, sd === \"left\" ? x : x + w - RAIL, 0, H, ids, true);\n tabbed(out, sd, ids, s.active[sd], x, 0, w, H, false);\n }\n };\n side(\"left\", 0, lw, NAV_L, s.left);\n side(\"right\", W - rw, rw, NAV_R, s.right);\n const cx = lw + G;\n const cw = W - lw - rw - 2 * G;\n const p = pill(opt, cx, cw, 0, H);\n tiles(out, rect(cx, p.top, cw, p.bottom - p.top), s.docs);\n out.set(\"toolbar\", p.placed);\n return out;\n}\n\nconst DRAWER_L = 240;\nconst DRAWER_R = 240;\n\nfunction drawers(cat: Catalog, s: DeskState, size: Size, notes: Note[]): Out {\n const out: Out = new Map();\n const { width: W, height: H } = size;\n const y = BAR;\n const h = H - BAR;\n const rDocked = W >= DRAWER_DOCK.right;\n const lDocked = W >= DRAWER_DOCK.left;\n const lOpen = s.left.length > 0 && !s.closed.includes(\"left\");\n const rOpen = s.right.length > 0 && !s.closed.includes(\"right\");\n if (!rDocked && rOpen) notes.push({ code: \"drawer-over\", side: \"right\", text: \"right drawer slides over the documents\" });\n if (!lDocked && lOpen) notes.push({ code: \"drawer-over\", side: \"left\", text: rDocked || !rOpen ? \"left drawer slides over the documents\" : \"left drawer slides over too\" });\n rail(out, \"left\", 0, y, h, s.left);\n rail(out, \"right\", W - RAIL, y, h, s.right);\n const x0 = RAIL + (lDocked && lOpen ? DRAWER_L : 0) + G;\n const x1 = W - RAIL - (rDocked && rOpen ? DRAWER_R : 0) - G;\n tiles(out, rect(x0, y + G, x1 - x0, h - 2 * G), s.docs);\n // Both sliding over a stage too narrow for the two side by side: each takes half the room between the rails.\n const both = !lDocked && !rDocked && lOpen && rOpen;\n const half = (W - 2 * RAIL - G) / 2;\n const lw = both ? Math.min(DRAWER_L, half) : DRAWER_L;\n const rw = both ? Math.min(DRAWER_R, half) : DRAWER_R;\n if (lOpen) tabbed(out, \"left\", s.left, s.active.left, RAIL, y, lw, h, !lDocked);\n else tabbedIntoRail(cat, out, \"left\", s.left, 0, y, DRAWER_L);\n if (rOpen) tabbed(out, \"right\", s.right, s.active.right, W - RAIL - rw, y, rw, h, !rDocked);\n else tabbedIntoRail(cat, out, \"right\", s.right, W - RAIL, y, DRAWER_R);\n out.set(\"toolbar\", bar(W));\n return out;\n}\n\n// --- scrolling strip (strip) --------------------------------------------------------------------------------------------\n\nfunction strip(cat: Catalog, s: DeskState, size: Size, notes: Note[]): Out {\n const out: Out = new Map();\n const { width: W, height: H } = size;\n const g = stripGeometry(cat, s, size, notes);\n g.cols.forEach((c, ci) => {\n // A column of panels: each at its natural height, the last taking the rest; documents share as before.\n const mins = c.map((k) => stripMin(cat, k));\n const heights = c.some(isDocKey) ? share(g.h - G * (c.length - 1), mins) : columnHeights(g.h, mins, G);\n let cy = g.y;\n c.forEach((k, i) => {\n out.set(k, { rect: rect(g.xs[ci]!, cy, g.widths[ci]!, heights[i]!), look: isDocKey(k) ? \"doc\" : \"tile\", layer: LAYER.doc, offStage: true, min: { width: g.widths[ci]!, height: mins[i]! } });\n cy += heights[i]! + G;\n });\n });\n const scrolls = g.total > W;\n if (scrolls) notes.push({ code: \"strip-scrolls\", text: `the strip is ${Math.round(g.total)} wide: ${Math.round(g.total - W)} px off screen, reached by scrolling` });\n out.set(\"track\", { rect: rect(0, H - 5, W, 5), look: \"track\", layer: LAYER.toolbar, ...(scrolls ? {} : { hidden: true }) });\n const tw = scrolls ? (W / g.total) * W : W;\n out.set(\"thumb\", { rect: rect(scrolls ? (g.scroll / g.total) * W : 0, H - 5, tw, 5), look: \"thumb\", layer: LAYER.toolbar, ...(scrolls ? {} : { hidden: true }) });\n out.set(\"toolbar\", bar(W));\n return out;\n}\n\n// --- floating palettes (floatOver, floatAround) --------------------------------------------------------------------\n\nfunction floatOver(cat: Catalog, s: DeskState, size: Size, opt: Options, notes: Note[]): Out {\n const out: Out = new Map();\n const { area } = paletteArea(size, opt);\n const pals = palettes(cat, s, area, size.width, OVER_MARGIN, notes);\n const tb = pillBetween(opt, size, [...pals.values()].map((p) => p.rect));\n tiles(out, area, s.docs);\n let covered = 0;\n for (const [id, p] of pals) {\n out.set(panelKey(id), { rect: p.rect, look: p.shaded ? \"header\" : \"float\", layer: LAYER.float, shadow: true, ...(p.shaded ? {} : { min: { height: cat.natural(id) } }) });\n covered += p.rect.width * p.rect.height;\n }\n notes.push({ code: \"palettes-cover\", text: `palettes cover ${Math.round((covered / (area.width * area.height)) * 100)}% of the documents` });\n out.set(\"toolbar\", tb);\n return out;\n}\n\nfunction floatAround(cat: Catalog, s: DeskState, size: Size, opt: Options, notes: Note[]): Out {\n const out: Out = new Map();\n const { area } = paletteArea(size, opt);\n const pals = palettes(cat, s, area, size.width, 0, notes);\n const tb = pillBetween(opt, size, [...pals.values()].map((p) => p.rect));\n const docsRect = aroundDocs(pals, area);\n tiles(out, docsRect, s.docs);\n let used = docsRect.width * docsRect.height;\n for (const [id, p] of pals) {\n out.set(panelKey(id), { rect: p.rect, look: p.shaded ? \"header\" : \"palette\", layer: LAYER.palette, shadow: true, ...(p.shaded ? {} : { min: { height: cat.natural(id) } }) });\n used += p.rect.width * p.rect.height;\n }\n notes.push({ code: \"docs-room\", text: `documents get ${Math.round(docsRect.width)} px of width; ${Math.max(0, Math.round((1 - used / (area.width * area.height)) * 100))}% of the desk stays empty under short stacks` });\n out.set(\"toolbar\", tb);\n return out;\n}\n\n// --- the presets ---------------------------------------------------------------------------------------------------\n\nexport type ConstructionId = \"docks\" | \"docksFull\" | \"tree\" | \"navigator\" | \"strip\" | \"drawers\" | \"floatOver\" | \"floatAround\" | \"dockTear\";\n\nexport interface Construction {\n readonly id: ConstructionId;\n readonly title: string;\n readonly idea: string;\n /** It has a floating toolbar pill (top or bottom, reserved or overlay). */\n readonly pill: boolean;\n /** It has a bottom dock (reserved, floating or off). */\n readonly bottom: boolean;\n /** The arrangement it starts from (at this stage size, when it depends on one). */\n readonly initial: (docs: readonly number[], size?: Size) => DeskState;\n readonly layout: (s: DeskState, size: Size, opt: Options) => Layout;\n /** The desk it belongs to (its catalog). */\n readonly desk: Desk;\n}\n\n/** A desk: the catalog, its nine constructions, and the catalog-bound helpers. */\nexport interface Desk {\n readonly catalog: Catalog;\n readonly constructions: readonly Construction[];\n readonly constructionOf: (id: ConstructionId) => Construction;\n /** The arrangement every construction starts from, with these documents open (none by default). */\n readonly initialState: (docs?: readonly number[]) => DeskState;\n readonly natural: (id: number) => number;\n readonly titleOf: (key: string) => string;\n}\n\ntype LayoutFn = (s: DeskState, size: Size, opt: Options, notes: Note[]) => Out;\n\nconst withNotes = (f: LayoutFn) => (s: DeskState, size: Size, opt: Options): Layout => {\n const notes: Note[] = [];\n const items = f(s, size, opt, notes);\n return { items, notes };\n};\n\n/**\n * A desk for these panels: the nine constructions as presets, each a pure layout over the shared state.\n *\n * ```ts\n * const desk = createDesk({ panels: [{ id: 1, title: \"Files\", natural: 160 }], start: { left: [1], right: [], bottom: [] } });\n * const c = desk.constructionOf(\"docks\");\n * const { items, notes } = c.layout(c.initial([1, 2]), { width: 960, height: 560 }, DEFAULT_OPTIONS);\n * ```\n */\nexport function createDesk(spec: DeskSpec): Desk {\n const cat = catalogOf(spec);\n const initial = (docs?: readonly number[]): DeskState => startState(cat, docs);\n const sides = (patch: (s: DeskState) => Partial<DeskState>) => (docs: readonly number[]): DeskState => {\n const s = startState(cat, docs);\n return { ...s, ...patch(s) };\n };\n // Navigator and drawers have no bottom dock: its panels join the right side.\n const noBottom = sides((s) => ({ right: [...s.right, ...s.bottom], bottom: [] }));\n const plain = sides(() => ({}));\n const list: Omit<Construction, \"desk\">[] = [\n {\n id: \"docks\",\n title: \"Edge docks\",\n idea: \"Each side is a dock with a rail of icons; its panels are accordion sections. Short on height, the least recently used fold to headers; short on width, a whole dock folds to its rail (right first). The bottom dock sits between the side docks.\",\n pill: true,\n bottom: true,\n initial: plain,\n layout: withNotes((s, size, opt, notes) => docks(cat, s, size, opt, \"between\", notes)),\n },\n {\n id: \"docksFull\",\n title: \"Edge docks, full-width bottom dock\",\n idea: \"As the edge docks, except the bottom dock runs under everything across the full width; the side docks and their rails stop above it, so they fold sooner.\",\n pill: true,\n bottom: true,\n initial: plain,\n layout: withNotes((s, size, opt, notes) => docks(cat, s, size, opt, \"full\", notes)),\n },\n {\n id: \"tree\",\n title: \"One tiling tree\",\n idea: \"Panels and documents are tiles of one tree, so a panel can sit beside a document. One rule for all: the newest tile that breaks a minimum floats. Opened on a narrow stage, the side columns start folded to rails at its edges.\",\n pill: false,\n bottom: false,\n initial: (docs, size) => treeStart(cat, docs, size),\n layout: withNotes((s, size, _opt, notes) => tree(cat, s, size, notes)),\n },\n {\n id: \"navigator\",\n title: \"Navigator + inspector\",\n idea: \"A fixed left and right side, one panel showing per side (tabs); the toolbar floats over the canvas. Narrow, the sides fold to icon tabs. Height never matters.\",\n pill: true,\n bottom: false,\n initial: noBottom,\n layout: withNotes((s, size, opt, notes) => navigator(cat, s, size, opt, notes)),\n },\n {\n id: \"strip\",\n title: \"Scrolling strip\",\n idea: \"Panels and documents are columns of a strip wider than the screen; nothing shrinks below its minimum, the view scrolls to the focus instead. Short on height, a column splits in two.\",\n pill: false,\n bottom: false,\n initial: plain,\n layout: withNotes((s, size, _opt, notes) => strip(cat, s, size, notes)),\n },\n {\n id: \"drawers\",\n title: \"Drawers\",\n idea: \"Documents take the screen; each side is a drawer with tabs. Wide, the drawers dock and push; narrow, they slide over the documents.\",\n pill: false,\n bottom: false,\n initial: noBottom,\n layout: withNotes((s, size, _opt, notes) => drawers(cat, s, size, notes)),\n },\n {\n id: \"floatOver\",\n title: \"Floating palettes over the documents\",\n idea: \"Documents take the whole desk; panels are palettes floating over them at their natural size, stacked in the top corners and draggable anywhere. Short on height, the least recently used shade to their title bars; the documents never move.\",\n pill: true,\n bottom: false,\n initial: plain,\n layout: withNotes((s, size, opt, notes) => floatOver(cat, s, size, opt, notes)),\n },\n {\n id: \"floatAround\",\n title: \"Floating palettes, documents tile around\",\n idea: \"Palettes float at their natural size but reserve their footprint: the documents tile in the space between them. Nothing is covered; the space under a short stack stays empty.\",\n pill: true,\n bottom: false,\n initial: plain,\n layout: withNotes((s, size, opt, notes) => floatAround(cat, s, size, opt, notes)),\n },\n {\n id: \"dockTear\",\n title: \"Edge docks + tear-off\",\n idea: \"The edge docks, and any panel can be torn off to float over the documents and dropped back on a dock or its rail icon. Docked is the default; floating is the exception you choose.\",\n pill: true,\n bottom: true,\n initial: plain,\n layout: withNotes((s, size, opt, notes) => {\n const out = docks(cat, s, size, opt, \"between\", notes);\n tornOff(cat, out, s, size, notes);\n return out;\n }),\n },\n ];\n const constructions: Construction[] = [];\n const desk: Desk = {\n catalog: cat,\n constructions,\n constructionOf: (id) => constructions.find((c) => c.id === id)!,\n initialState: initial,\n natural: cat.natural,\n titleOf: cat.title,\n };\n constructions.push(...list.map((c) => ({ ...c, desk })));\n return desk;\n}\n\n/** Which items a construction lets the pointer drag: panels everywhere, documents in the tree and the strip. */\nexport const draggable = (c: Construction, key: string): boolean => key.startsWith(\"panel:\") || (key.startsWith(\"doc:\") && (c.id === \"tree\" || c.id === \"strip\"));\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkDA,SAAS,MAAM,KAAc,GAAc,MAAyC,KAAc,MAA0B,OAAoB;AAC9I,QAAM,MAAW,oBAAI,IAAI;AACzB,QAAM,EAAE,OAAO,GAAG,QAAQ,EAAE,IAAI;AAChC,QAAM,IAAI,aAAa,KAAK,GAAG,MAAM,KAAK,MAAM,KAAK;AACrD,OAAK,KAAK,QAAQ,GAAG,GAAG,EAAE,GAAG,EAAE,IAAI;AACnC,OAAK,KAAK,SAAS,IAAI,MAAM,GAAG,EAAE,GAAG,EA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S,IAAI;AAAA,IACb,SAAS,IAAI;AAAA,EACf;AACA,gBAAc,KAAK,GAAG,KAAK,IAAI,CAAC,OAAO,EAAE,GAAG,GAAG,KAAK,EAAE,CAAC;AACvD,SAAO;AACT;AAGO,IAAM,YAAY,CAAC,GAAiB,QAAyB,IAAI,WAAW,QAAQ,KAAM,IAAI,WAAW,MAAM,MAAM,EAAE,OAAO,UAAU,EAAE,OAAO;","names":[]}
@@ -1,4 +1,4 @@
1
- import { R as Rect } from './geometry-CkZ6Fcfb.js';
1
+ import { R as Rect } from './geometry-Bf37LbCT.js';
2
2
 
3
3
  /**
4
4
  * `fitFloat(rect, stage, avoid)`: the rect a float gets. It is moved (never resized) to lie inside the stage, then beside
@@ -22,7 +22,7 @@ declare const rect: (x: number, y: number, width: number, height: number) => Rec
22
22
  declare const overlap: (a: Rect, b: Rect) => number;
23
23
  /** `r` moved (not resized) to lie inside `area`; one larger than the area keeps its top-left corner on the area's. */
24
24
  declare const clampInto: (r: Rect, area: Rect) => Rect;
25
- /** The centre of a rect. */
25
+ /** The center of a rect. */
26
26
  declare const centre: (r: Rect) => Point;
27
27
  /** The tolerance the geometry compares with, px. */
28
28
  declare const EPS = 0.000001;
package/dist/index.d.ts CHANGED
@@ -1,13 +1,13 @@
1
- import { P as Point, R as Rect, S as Size } from './geometry-CkZ6Fcfb.js';
2
- export { C as COLUMN_REACH, E as EPS, a as PLANE, b as RAIL_EDGE, c as area, d as centre, e as clamp, f as clampInto, g as contains, o as overlap, h as overlaps, r as rect, s as subtract } from './geometry-CkZ6Fcfb.js';
3
- export { T as Target } from './target-CEVCfJd-.js';
1
+ import { P as Point, R as Rect, S as Size } from './geometry-Bf37LbCT.js';
2
+ export { C as COLUMN_REACH, E as EPS, a as PLANE, b as RAIL_EDGE, c as area, d as centre, e as clamp, f as clampInto, g as contains, o as overlap, h as overlaps, r as rect, s as subtract } from './geometry-Bf37LbCT.js';
3
+ export { T as Target } from './target-2RYYKkd1.js';
4
4
 
5
5
  /**
6
6
  * Placing a popup (a drop label, a menu, a tooltip) the way Wayland's xdg-positioner does: an anchor point on the
7
7
  * anchor rect, a gravity, an offset, then the constraint adjustments in order per axis: flip, slide, resize.
8
8
  */
9
9
 
10
- /** -1: the start edge (left or top), 0: the centre, 1: the end edge. */
10
+ /** -1: the start edge (left or top), 0: the center, 1: the end edge. */
11
11
  type Align = -1 | 0 | 1;
12
12
  /**
13
13
  * A rule: the popup's anchor point on the anchor rect, the direction it extends from there (gravity), an offset,
package/dist/index.js CHANGED
@@ -12,7 +12,7 @@ import {
12
12
  overlaps,
13
13
  rect,
14
14
  subtract
15
- } from "./chunk-WM5FJ3IS.js";
15
+ } from "./chunk-VLTYJHUA.js";
16
16
 
17
17
  // src/positioner.ts
18
18
  function placeAxis(a0, alen, anchor, gravity, offset, size) {
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/positioner.ts"],"sourcesContent":["/**\n * Placing a popup (a drop label, a menu, a tooltip) the way Wayland's xdg-positioner does: an anchor point on the\n * anchor rect, a gravity, an offset, then the constraint adjustments in order per axis: flip, slide, resize.\n */\nimport type { Point, Rect, Size } from \"./geometry\";\n\n/** -1: the start edge (left or top), 0: the centre, 1: the end edge. */\nexport type Align = -1 | 0 | 1;\n\n/**\n * A rule: the popup's anchor point on the anchor rect, the direction it extends from there (gravity), an offset,\n * and which adjustments are allowed: flip (mirror anchor, gravity and offset; kept only if that fits), then slide\n * (move inside, the start edge winning), then resize (cut to the bounds).\n */\nexport interface PositionerRule {\n readonly anchor: { readonly x: Align; readonly y: Align };\n readonly gravity: { readonly x: Align; readonly y: Align };\n readonly offset: Point;\n readonly flip: boolean;\n readonly slide: boolean;\n readonly resize: boolean;\n}\n\nexport interface Positioned {\n readonly rect: Rect;\n readonly flipped: { readonly x: boolean; readonly y: boolean };\n readonly slid: { readonly x: boolean; readonly y: boolean };\n readonly resized: boolean;\n}\n\nfunction placeAxis(a0: number, alen: number, anchor: Align, gravity: Align, offset: number, size: number): number {\n const point = a0 + ((anchor + 1) / 2) * alen + offset;\n return gravity === 1 ? point : gravity === -1 ? point - size : point - size / 2;\n}\n\n/** Where a popup of `size` goes for `anchorRect` by `rule`, kept inside `bounds` as far as the rule allows. */\nexport function positionPopup(anchorRect: Rect, size: Size, bounds: Rect, rule: PositionerRule): Positioned {\n const axes = [\n { a0: anchorRect.x, alen: anchorRect.width, anchor: rule.anchor.x, gravity: rule.gravity.x, offset: rule.offset.x, size: size.width, b0: bounds.x, blen: bounds.width },\n { a0: anchorRect.y, alen: anchorRect.height, anchor: rule.anchor.y, gravity: rule.gravity.y, offset: rule.offset.y, size: size.height, b0: bounds.y, blen: bounds.height },\n ];\n const out = axes.map((ax) => {\n const fits = (start: number, len: number): boolean => start >= ax.b0 - 0.01 && start + len <= ax.b0 + ax.blen + 0.01;\n let start = placeAxis(ax.a0, ax.alen, ax.anchor, ax.gravity, ax.offset, ax.size);\n let len = ax.size;\n let flipped = false;\n let slid = false;\n let resized = false;\n if (!fits(start, len) && rule.flip && (ax.anchor !== 0 || ax.gravity !== 0)) {\n const mirrored = placeAxis(ax.a0, ax.alen, -ax.anchor as Align, -ax.gravity as Align, -ax.offset, ax.size);\n if (fits(mirrored, len)) {\n start = mirrored;\n flipped = true;\n }\n }\n if (!fits(start, len) && rule.slide) {\n if (start + len > ax.b0 + ax.blen) start = ax.b0 + ax.blen - len;\n if (start < ax.b0) start = ax.b0;\n slid = true;\n }\n if (!fits(start, len) && rule.resize) {\n const end = Math.min(start + len, ax.b0 + ax.blen);\n start = Math.max(start, ax.b0);\n len = Math.max(0, end - start);\n resized = true;\n }\n return { start, len, flipped, slid, resized };\n });\n const [x, y] = out as [(typeof out)[0], (typeof out)[0]];\n return {\n rect: { x: x.start, y: y.start, width: x.len, height: y.len },\n flipped: { x: x.flipped, y: y.flipped },\n slid: { x: x.slid, y: y.slid },\n resized: x.resized || y.resized,\n };\n}\n\n/** Below the anchor's bottom-left corner, extending right and down, 6 px apart; flips, slides and resizes. */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{"version":3,"sources":["../src/positioner.ts"],"sourcesContent":["/**\n * Placing a popup (a drop label, a menu, a tooltip) the way Wayland's xdg-positioner does: an anchor point on the\n * anchor rect, a gravity, an offset, then the constraint adjustments in order per axis: flip, slide, resize.\n */\nimport type { Point, Rect, Size } from \"./geometry\";\n\n/** -1: the start edge (left or top), 0: the center, 1: the end edge. */\nexport type Align = -1 | 0 | 1;\n\n/**\n * A rule: the popup's anchor point on the anchor rect, the direction it extends from there (gravity), an offset,\n * and which adjustments are allowed: flip (mirror anchor, gravity and offset; kept only if that fits), then slide\n * (move inside, the start edge winning), then resize (cut to the bounds).\n */\nexport interface PositionerRule {\n readonly anchor: { readonly x: Align; readonly y: Align };\n readonly gravity: { readonly x: Align; readonly y: Align };\n readonly offset: Point;\n readonly flip: boolean;\n readonly slide: boolean;\n readonly resize: boolean;\n}\n\nexport interface Positioned {\n readonly rect: Rect;\n readonly flipped: { readonly x: boolean; readonly y: boolean };\n readonly slid: { readonly x: boolean; readonly y: boolean };\n readonly resized: boolean;\n}\n\nfunction placeAxis(a0: number, alen: number, anchor: Align, gravity: Align, offset: number, size: number): number {\n const point = a0 + ((anchor + 1) / 2) * alen + offset;\n return gravity === 1 ? point : gravity === -1 ? point - size : point - size / 2;\n}\n\n/** Where a popup of `size` goes for `anchorRect` by `rule`, kept inside `bounds` as far as the rule allows. */\nexport function positionPopup(anchorRect: Rect, size: Size, bounds: Rect, rule: PositionerRule): Positioned {\n const axes = [\n { a0: anchorRect.x, alen: anchorRect.width, anchor: rule.anchor.x, gravity: rule.gravity.x, offset: rule.offset.x, size: size.width, b0: bounds.x, blen: bounds.width },\n { a0: anchorRect.y, alen: anchorRect.height, anchor: rule.anchor.y, gravity: rule.gravity.y, offset: rule.offset.y, size: size.height, b0: bounds.y, blen: bounds.height },\n ];\n const out = axes.map((ax) => {\n const fits = (start: number, len: number): boolean => start >= ax.b0 - 0.01 && start + len <= ax.b0 + ax.blen + 0.01;\n let start = placeAxis(ax.a0, ax.alen, ax.anchor, ax.gravity, ax.offset, ax.size);\n let len = ax.size;\n let flipped = false;\n let slid = false;\n let resized = false;\n if (!fits(start, len) && rule.flip && (ax.anchor !== 0 || ax.gravity !== 0)) {\n const mirrored = placeAxis(ax.a0, ax.alen, -ax.anchor as Align, -ax.gravity as Align, -ax.offset, ax.size);\n if (fits(mirrored, len)) {\n start = mirrored;\n flipped = true;\n }\n }\n if (!fits(start, len) && rule.slide) {\n if (start + len > ax.b0 + ax.blen) start = ax.b0 + ax.blen - len;\n if (start < ax.b0) start = ax.b0;\n slid = true;\n }\n if (!fits(start, len) && rule.resize) {\n const end = Math.min(start + len, ax.b0 + ax.blen);\n start = Math.max(start, ax.b0);\n len = Math.max(0, end - start);\n resized = true;\n }\n return { start, len, flipped, slid, resized };\n });\n const [x, y] = out as [(typeof out)[0], (typeof out)[0]];\n return {\n rect: { x: x.start, y: y.start, width: x.len, height: y.len },\n flipped: { x: x.flipped, y: y.flipped },\n slid: { x: x.slid, y: y.slid },\n resized: x.resized || y.resized,\n };\n}\n\n/** Below the anchor's bottom-left corner, extending right and down, 6 px apart; flips, slides and resizes. */\nexport const BELOW_LEFT: PositionerRule = {\n anchor: { x: -1, y: 1 },\n gravity: { x: 1, y: 1 },\n offset: { x: 0, y: 6 },\n flip: true,\n slide: true,\n resize: true,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AA8BA,SAAS,UAAU,IAAY,MAAc,QAAe,SAAgB,QAAgB,MAAsB;AAChH,QAAM,QAAQ,MAAO,SAAS,KAAK,IAAK,OAAO;AAC/C,SAAO,YAAY,IAAI,QAAQ,YAAY,KAAK,QAAQ,OAAO,QAAQ,OAAO;AAChF;AAGO,SAAS,cAAc,YAAkB,MAAY,QAAc,MAAkC;AAC1G,QAAM,OAAO;AAAA,IACX,EAAE,IAAI,WAAW,GAAG,MAAM,WAAW,OAAO,QAAQ,KAAK,OAAO,GAAG,SAAS,KAAK,QAAQ,GAAG,QAAQ,KAAK,OAAO,GAAG,MAAM,KAAK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YAAM,KAAK,IAAI,GAAG,MAAM,KAAK;AAC7B,gBAAU;AAAA,IACZ;AACA,WAAO,EAAE,OAAO,KAAK,SAAS,MAAM,QAAQ;AAAA,EAC9C,CAAC;AACD,QAAM,CAAC,GAAG,CAAC,IAAI;AACf,SAAO;AAAA,IACL,MAAM,EAAE,GAAG,EAAE,OAAO,GAAG,EAAE,OAAO,OAAO,EAAE,KAAK,QAAQ,EAAE,IAAI;AAAA,IAC5D,SAAS,EAAE,GAAG,EAAE,SAAS,GAAG,EAAE,QAAQ;AAAA,IACtC,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,EAAE,KAAK;AAAA,IAC7B,SAAS,EAAE,WAAW,EAAE;AAAA,EAC1B;AACF;AAGO,IAAM,aAA6B;AAAA,EACxC,QAAQ,EAAE,GAAG,IAAI,GAAG,EAAE;AAAA,EACtB,SAAS,EAAE,GAAG,GAAG,GAAG,EAAE;AAAA,EACtB,QAAQ,EAAE,GAAG,GAAG,GAAG,EAAE;AAAA,EACrB,MAAM;AAAA,EACN,OAAO;AAAA,EACP,QAAQ;AACV;","names":["start","len"]}
@@ -1,6 +1,6 @@
1
- import { R as Rect, S as Size, P as Point } from './geometry-CkZ6Fcfb.js';
2
- import { T as Target } from './target-CEVCfJd-.js';
3
- import { C as CrossLimits, a as StackForm, S as StackFormKind, b as StackFit, c as StackNote } from './model-CPM1Lv65.js';
1
+ import { R as Rect, S as Size, P as Point } from './geometry-Bf37LbCT.js';
2
+ import { T as Target } from './target-2RYYKkd1.js';
3
+ import { C as CrossLimits, a as StackForm, S as StackFormKind, b as StackFit, c as StackNote } from './model-X7eUaKlA.js';
4
4
 
5
5
  /**
6
6
  * The scene's shapes: one model of a whole window. A scene is a stage (the window's inner rect), the edges along its
@@ -16,7 +16,7 @@ type Kind = string;
16
16
  /** A side of the stage. Left and right edges are columns (they run down); top and bottom edges are bars (they run across). */
17
17
  type Side = "top" | "right" | "bottom" | "left";
18
18
  declare const SIDES: readonly Side[];
19
- /** Where an item sits along its edge: packed from the start, centred in the spare length, or packed from the end. */
19
+ /** Where an item sits along its edge: packed from the start, centered in the spare length, or packed from the end. */
20
20
  type Zone = "start" | "center" | "end";
21
21
  declare const ZONES: readonly Zone[];
22
22
  /** A float that follows the content: flush with that side or corner of `layout.content` until a drop gives it a real rect. */
@@ -137,7 +137,7 @@ interface Edge {
137
137
  /** The drop strip's depth while the edge is empty, px (default {@link DEFAULT_STRIP}). */
138
138
  readonly strip?: number;
139
139
  /**
140
- * How a gap's hit runs along the edge. The gaps always split the edge halfway between neighbouring insertion lines, so
140
+ * How a gap's hit runs along the edge. The gaps always split the edge halfway between neighboring insertion lines, so
141
141
  * free space and short items (a toolbar, a closed or folded panel) are covered end to end. A number: over an open
142
142
  * item's body only (a panel), the hit narrows to a band that many px around the line, so the middle of a panel is no
143
143
  * gap and the pointer falls through to the float target, or to none. `"middle"`: no band, so panels are split too.
@@ -215,6 +215,42 @@ interface RailSpec {
215
215
  /** The kinds a drop on the rail may bring (it docks folded). */
216
216
  readonly accepts: readonly Kind[];
217
217
  }
218
+ /** When a host draws a side's rail drop strip: while an item of the kind is held (the default), always, or never. */
219
+ type RailVisibility = "whileDragging" | "always" | "never";
220
+ declare const RAIL_VISIBILITIES: readonly RailVisibility[];
221
+ /** The least width of a rail drop strip, px: a target at the window's edge stays easy to hit (Fitts's law). */
222
+ declare const RAIL_STRIP_MIN = 24;
223
+ /** How far an armed rail drop strip grows inward by default, px, so a hand that wobbles once armed keeps it. */
224
+ declare const DEFAULT_RAIL_MAGNET = 6;
225
+ /**
226
+ * How an item of one kind drops into a side's rail (`Scene.railDrop[kind]`): the geometry of its drop strip. Each kind
227
+ * has its own; a kind with none keeps the rail targets as they were (immediate, no strip).
228
+ *
229
+ * With a policy, each side whose rail can take the kind shows one drop strip at the window's side, at the rail's real
230
+ * width, even while the rail is empty: its targets are `rail:<side>:<ring>` with `arm: "dwell"` (spring-loading: the
231
+ * drag intent arms them on a dwell), `armedHit` (the strip grown by `magnet`) and `strip` (the rect to draw). The strip
232
+ * owns its rect: a drop there is the rail's once armed, the float's before. The side's rail is `Scene.rails[side]`
233
+ * where the scene declares one, else the side's outermost column that takes the kind in its start zone ("the column
234
+ * drawn as a rail"): a drop there docks the item in it as a collapsed header, a rail tile once nothing in it sets its
235
+ * width. The strip means "collapse it at this side": the drop is `moveTo` that side's rail, and lands wherever the
236
+ * scene shows a collapsed panel there (a rail tile, a rider bar under `handFold: "ride"`, a header); the slot is that.
237
+ */
238
+ interface RailDropPolicy {
239
+ /**
240
+ * The strip's width, px, from the window's side inward (default: the rail's drawn width). At least
241
+ * {@link RAIL_STRIP_MIN}; 0 turns the kind's rail docking off.
242
+ */
243
+ readonly railStripWidth?: number;
244
+ /** When the host draws the strip (default `"whileDragging"`); `"never"` turns the kind's rail docking off. */
245
+ readonly railVisibility?: RailVisibility;
246
+ /**
247
+ * How far the strip grows inward once armed, px (default {@link DEFAULT_RAIL_MAGNET}): the armed target's band
248
+ * (`armedHit`). Moving out past its outer edge disarms it, and re-entering the strip needs a new full dwell.
249
+ */
250
+ readonly magnet?: number;
251
+ /** Whether a float may sit inside the strip's area (default true); false keeps a float's rect clear of every strip. */
252
+ readonly floatNearEdge?: boolean;
253
+ }
218
254
  interface SceneFloat {
219
255
  readonly id: string;
220
256
  /** Its rect in stage px (it never scrolls with the content). With `anchor`, only its size counts. */
@@ -249,6 +285,11 @@ interface Scene {
249
285
  * side needs no `rails` entry to have a mode: a column drawn as a rail reads it too. `storeScene` keeps it.
250
286
  */
251
287
  readonly railModes?: Partial<Record<"left" | "right", RailMode>>;
288
+ /**
289
+ * Per item kind: how it drops into a side's rail ({@link RailDropPolicy}), keyed by the scene's own kind strings.
290
+ * Tuning one kind never changes another; a kind left out keeps the rail targets it had.
291
+ */
292
+ readonly railDrop?: Readonly<Partial<Record<Kind, RailDropPolicy>>>;
252
293
  /**
253
294
  * The least the content may be. While the content is narrower than `width`, dynamic columns shrink toward their
254
295
  * minimum, then fold whole into their side's rail: unkept before kept, the one whose newest use is oldest first, the
@@ -524,7 +565,9 @@ declare function fitResize(scene: Scene, id: string, rect: Rect, moving: ResizeE
524
565
  * the zone's items without it, closed ones included), or at the zone's end. The zone becomes the item's `align`.
525
566
  * `{ kind: "column", side, ring }` makes a new column from `scene.columns[side]` at that ring (`Infinity`: the side's
526
567
  * inner end, "Move to › Dock left"); `{ kind: "rail", side, ring }` does the same with the item folded by hand, so it
527
- * shows in the rail; `{ kind: "float", rect?, anchor? }` floats it. A dynamic column an item leaves empty is deleted
568
+ * shows in the rail (on a side with no declared rail, `Scene.rails`, its rail is its outermost column that takes the
569
+ * kind, "the column drawn as a rail": the item docks at the end of its start zone as a collapsed header, folded by
570
+ * hand, a rail tile once nothing there sets the width); `{ kind: "float", rect?, anchor? }` floats it. A dynamic column an item leaves empty is deleted
528
571
  * and its side's rings are closed up.
529
572
  * - `homeFor(scene, id, start)`: the place a start scene gives the item, for `moveTo`.
530
573
  * - `floatAt(scene, id, rect?, orient?)`: floats it on top at `rect` (its size becomes `floatSize`); with no rect, at
@@ -719,6 +762,8 @@ interface SceneTarget extends Target {
719
762
  readonly place: ScenePlace;
720
763
  /** Gaps and strips: the line where the item's leading edge lands, zero thick, across the edge after the drop. */
721
764
  readonly marker?: Rect;
765
+ /** A rail target under a kind's `Scene.railDrop` policy: the side's whole drop strip, for the host to draw. */
766
+ readonly strip?: Rect;
722
767
  /** The scene a release here commits and its layout. Only a float's depends on the pointer. */
723
768
  after(point: Point, grab?: Point): SceneAfter;
724
769
  }
@@ -753,4 +798,4 @@ interface SceneRefusal {
753
798
  readonly reason: "no-room" | "own-place" | "not-accepted";
754
799
  }
755
800
 
756
- export { open as $, type SceneItemLayout as A, type SceneNote as B, type ColumnPlace as C, DEFAULT_FLOAT_SIZE as D, type Edge as E, type FloatAnchor as F, type SceneRailLayout as G, type SceneRead as H, type StoredSceneEdge as I, type StoredSceneFloat as J, type Kind as K, type StoredSceneItem as L, ZONES as M, close as N, type Orient as O, type Place as P, dockHome as Q, type RailMode as R, type Scene as S, fitResize as T, floatAt as U, fold as V, homeFor as W, keep as X, lift as Y, type Zone as Z, moveTo as _, type ScenePlace as a, orient as a0, raise as a1, readScene as a2, resize as a3, setRailMode as a4, setSide as a5, storeScene as a6, use as a7, type SceneLayout as b, type StoredScene as c, type SceneTarget as d, type Side as e, type SceneNoteCode as f, type SceneItem as g, type ZoneAccepts as h, type SolveOptions as i, type SceneTargetOptions as j, type SceneRefusal as k, type ColumnTemplate as l, DEFAULT_HIT_BAND as m, DEFAULT_STRIP as n, type DockPlace as o, type FloatPlace as p, type FloatResize as q, RAIL_MODES as r, type RailPlace as s, type RailSpec as t, type ResizeEdges as u, type ResizeLimit as v, SIDES as w, type SceneAfter as x, type SceneEdgeLayout as y, type SceneFloat as z };
801
+ export { fold as $, type ResizeLimit as A, SIDES as B, type ColumnPlace as C, DEFAULT_FLOAT_SIZE as D, type Edge as E, type FloatAnchor as F, type SceneAfter as G, type SceneEdgeLayout as H, type SceneFloat as I, type SceneItemLayout as J, type Kind as K, type SceneNote as L, type SceneRailLayout as M, type SceneRead as N, type Orient as O, type Place as P, type StoredSceneEdge as Q, type RailMode as R, type Scene as S, type StoredSceneFloat as T, type StoredSceneItem as U, ZONES as V, close as W, dockHome as X, fitResize as Y, type Zone as Z, floatAt as _, type ScenePlace as a, homeFor as a0, keep as a1, lift as a2, moveTo as a3, open as a4, orient as a5, raise as a6, readScene as a7, resize as a8, setRailMode as a9, setSide as aa, storeScene as ab, use as ac, type SceneLayout as b, type StoredScene as c, type SceneTarget as d, type Side as e, type SceneNoteCode as f, type SceneItem as g, type ZoneAccepts as h, type SolveOptions as i, type SceneTargetOptions as j, type SceneRefusal as k, type ColumnTemplate as l, DEFAULT_HIT_BAND as m, DEFAULT_RAIL_MAGNET as n, DEFAULT_STRIP as o, type DockPlace as p, type FloatPlace as q, type FloatResize as r, RAIL_MODES as s, RAIL_STRIP_MIN as t, RAIL_VISIBILITIES as u, type RailDropPolicy as v, type RailPlace as w, type RailSpec as x, type RailVisibility as y, type ResizeEdges as z };
@@ -1,4 +1,4 @@
1
- import { R as Rect } from './geometry-CkZ6Fcfb.js';
1
+ import { R as Rect } from './geometry-Bf37LbCT.js';
2
2
 
3
3
  /**
4
4
  * The edge stack's shapes. A stack is the items along one edge of a stage: a column (vertical, a side region) or a
@@ -181,7 +181,7 @@ interface StackInput {
181
181
  readonly main: number;
182
182
  };
183
183
  /**
184
- * The space between neighbouring drawn items, px (default 0). The » entry is a neighbour of the last drawn item. It
184
+ * The space between neighboring drawn items, px (default 0). The » entry is a neighbor of the last drawn item. It
185
185
  * counts toward the length and the rects include it, so an app draws at the solver's rects.
186
186
  */
187
187
  readonly gap?: number;
package/dist/panels.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { b as PanelsState, S as Side, E as Edge, C as Clock, a as PanelDef } from './targets-BPG7Kf02.js';
2
- export { B as BAND_SIZE, g as Band, h as BandOption, i as Column, D as DEFAULT_PANELS_OPTIONS, j as DockOptions, k as EDGES, F as FLOAT_HEIGHT, m as FLOAT_MIN, n as FloatAt, G as GiveWay, I as IDENTITY_VIEW, e as PanelDrop, o as PanelKind, q as PanelPlace, r as PanelStop, s as PanelStopsOptions, d as PanelTarget, c as PanelTargetInput, f as PanelsLayout, t as PanelsNote, u as PanelsNoteCode, P as PanelsOptions, v as PanelsStart, w as Place, x as PlacedBand, y as PlacedColumn, z as PlacedPanel, A as PlacedRail, R as Reserve, H as ReserveEdge, J as SIDES, V as View, W as Where, K as activate, L as bandHeight, M as bandSize, N as close, O as columnWidth, Q as createPanels, T as defOf, U as dock, X as dockBand, Y as float, Z as floatSize, _ as focus, $ as giveWayOrder, a0 as homePlace, a1 as keep, l as layoutPanels, a2 as liftPanel, a3 as open, a4 as ownWidth, p as panelDrop, a5 as panelStops, a6 as panelTargets, a7 as pin, a8 as placeRank, a9 as resizeBand, aa as resizeColumn, ab as resizeFloat, ac as samePlaces, ad as showTabs, ae as tick, af as toPage, ag as toView, ah as toggleFold, ai as whereIs } from './targets-BPG7Kf02.js';
3
- import { R as Rect } from './geometry-CkZ6Fcfb.js';
4
- export { C as COLUMN_REACH, b as RAIL_EDGE } from './geometry-CkZ6Fcfb.js';
5
- import './target-CEVCfJd-.js';
1
+ import { b as PanelsState, S as Side, E as Edge, C as Clock, a as PanelDef } from './targets-Du5_4T1u.js';
2
+ export { B as BAND_SIZE, g as Band, h as BandOption, i as Column, D as DEFAULT_PANELS_OPTIONS, j as DockOptions, k as EDGES, F as FLOAT_HEIGHT, m as FLOAT_MIN, n as FloatAt, G as GiveWay, I as IDENTITY_VIEW, e as PanelDrop, o as PanelKind, q as PanelPlace, r as PanelStop, s as PanelStopsOptions, d as PanelTarget, c as PanelTargetInput, f as PanelsLayout, t as PanelsNote, u as PanelsNoteCode, P as PanelsOptions, v as PanelsStart, w as Place, x as PlacedBand, y as PlacedColumn, z as PlacedPanel, A as PlacedRail, R as Reserve, H as ReserveEdge, J as SIDES, V as View, W as Where, K as activate, L as bandHeight, M as bandSize, N as close, O as columnWidth, Q as createPanels, T as defOf, U as dock, X as dockBand, Y as float, Z as floatSize, _ as focus, $ as giveWayOrder, a0 as homePlace, a1 as keep, l as layoutPanels, a2 as liftPanel, a3 as open, a4 as ownWidth, p as panelDrop, a5 as panelStops, a6 as panelTargets, a7 as pin, a8 as placeRank, a9 as resizeBand, aa as resizeColumn, ab as resizeFloat, ac as samePlaces, ad as showTabs, ae as tick, af as toPage, ag as toView, ah as toggleFold, ai as whereIs } from './targets-Du5_4T1u.js';
3
+ import { R as Rect } from './geometry-Bf37LbCT.js';
4
+ export { C as COLUMN_REACH, b as RAIL_EDGE } from './geometry-Bf37LbCT.js';
5
+ import './target-2RYYKkd1.js';
6
6
 
7
7
  /**
8
8
  * The panels' stored form: `storePanels(state)` gives plain JSON-safe data (`{ v: 1, … }`); `readPanels(data, defs?)`
package/dist/panels.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  readPanels,
3
3
  storePanels
4
- } from "./chunk-OYGOJWAX.js";
4
+ } from "./chunk-JVAR67OL.js";
5
5
  import {
6
6
  BAND_SIZE,
7
7
  DEFAULT_PANELS_OPTIONS,
@@ -44,11 +44,11 @@ import {
44
44
  toView,
45
45
  toggleFold,
46
46
  whereIs
47
- } from "./chunk-7ASCUAGV.js";
47
+ } from "./chunk-3ZICYLWL.js";
48
48
  import {
49
49
  COLUMN_REACH,
50
50
  RAIL_EDGE
51
- } from "./chunk-WM5FJ3IS.js";
51
+ } from "./chunk-VLTYJHUA.js";
52
52
  export {
53
53
  BAND_SIZE,
54
54
  COLUMN_REACH,
@@ -1,16 +1,16 @@
1
- import { P as Point, R as Rect } from './geometry-CkZ6Fcfb.js';
2
- import { S as StackFormKind } from './model-CPM1Lv65.js';
3
- import { S as Scene, a as ScenePlace, b as SceneLayout, c as StoredScene, d as SceneTarget, Z as Zone, e as Side, f as SceneNoteCode } from './model-DwojiKKF.js';
4
- import './target-CEVCfJd-.js';
1
+ import { P as Point, R as Rect } from './geometry-Bf37LbCT.js';
2
+ import { S as StackFormKind } from './model-X7eUaKlA.js';
3
+ import { S as Scene, a as ScenePlace, b as SceneLayout, c as StoredScene, d as SceneTarget, Z as Zone, e as Side, f as SceneNoteCode } from './model-BxFXr9UY.js';
4
+ import './target-2RYYKkd1.js';
5
5
 
6
6
  /**
7
7
  * The conformance rows' shapes. A row is plain data: a scene, the settings it runs at, the gestures a user makes, and
8
8
  * what the layout (and, in a host with a page, the DOM) must be after them. `runCase(row, host)` (./run) plays a row on
9
- * a `CaseHost`; the in-memory host (./host) is the reference, and a UI kit's host is one more. Nothing here names a DOM
9
+ * a `CaseHost`; the in-memory host (./host) is the reference, and an integrating app's host is one more. Nothing here names a DOM
10
10
  * type: a page's root only has to answer `getAttribute` and `querySelectorAll`, which every DOM element does.
11
11
  */
12
12
 
13
- /** How a row is grouped (the lab's case browser and the kits' report list rows by it). */
13
+ /** How a row is grouped (the lab's case browser and an integrating app's report list rows by it). */
14
14
  type CaseGroup = "panels" | "groups" | "drag" | "floats" | "bars" | "previous" | "kinds" | "bands" | "gestures" | "window-a" | "window-b";
15
15
  /** The settings a row runs at. `stage` replaces the scene's stage with `{ x: 0, y: 0, width: w, height: h }`. */
16
16
  interface CaseSettings {
@@ -161,8 +161,18 @@ interface Checkpoint {
161
161
  readonly layout?: LayoutExpect;
162
162
  readonly note?: string;
163
163
  }
164
+ /**
165
+ * What a row's scene needs of the host's window: a host that can't meet it skips the row or marks it. The runner reads
166
+ * none of it; it is data for the host's suite.
167
+ */
168
+ interface CaseRequires {
169
+ /** The scene's columns use the default `hitBand` (an open panel's body is no drop place); a host whose columns use `"middle"` gets card halves there. */
170
+ readonly hitBand?: "default";
171
+ /** The sides whose rail the scene declares (`Scene.rails`) and shows at the start (a folded column puts panels in it), so a host needs a rail to aim at there. */
172
+ readonly rails?: readonly ("left" | "right")[];
173
+ }
164
174
  interface CaseRow {
165
- /** Generic and stable: the kits' suites name rows by it. */
175
+ /** Generic and stable: an integrating app's suite names rows by it. */
166
176
  readonly id: string;
167
177
  readonly title: string;
168
178
  /** One sentence: what must be true. */
@@ -186,9 +196,11 @@ interface CaseRow {
186
196
  };
187
197
  /**
188
198
  * The library rule this row needs and the Scene doesn't have yet. Such a row is expected to fail on the in-memory host
189
- * until the rule lands (then its suite says to remove this), and a kit's suite may skip it.
199
+ * until the rule lands (then its suite says to remove this), and an integrating app's suite may skip it.
190
200
  */
191
201
  readonly lacks?: string;
202
+ /** What the scene needs of the host's window (see {@link CaseRequires}); a host that can't meet it skips or marks the row. */
203
+ readonly requires?: CaseRequires;
192
204
  }
193
205
  /** What a stored form must hold: per item the named fields exactly (`null`: absent), and strings its JSON never contains. */
194
206
  interface StoredExpect {
@@ -225,6 +237,13 @@ interface CaseHost {
225
237
  stops?(item: string): readonly ScenePlace[];
226
238
  /** The pick rule the host aims with (see {@link PickRule}); the runner never calls it. */
227
239
  readonly pick?: PickRule;
240
+ /**
241
+ * The host's names for a row's items and edges: row id to host id (`{ views: "panels", tools: "commands" }`). The
242
+ * runner passes every id to the host in the host's words (the scene, the gestures, `stops`, `itemSelector`) and reads
243
+ * the layout, the stored form and the stops back in the row's, so the row's expectations stay as written. One to one;
244
+ * an id left out keeps its name. See `./ids`.
245
+ */
246
+ readonly ids?: Readonly<Record<string, string>>;
228
247
  }
229
248
  /**
230
249
  * The pick rule: which of `list` the pointer at `point` is over, or null. There is one, `@n-uf/motion/drag`'s
@@ -248,6 +267,8 @@ interface AsyncCaseHost {
248
267
  stops?(item: string): readonly ScenePlace[] | Promise<readonly ScenePlace[]>;
249
268
  /** The pick rule the host aims with, a plain value (see {@link PickRule}); the runner never calls it. */
250
269
  readonly pick?: PickRule;
270
+ /** The host's names for a row's items and edges, as {@link CaseHost.ids}. */
271
+ readonly ids?: Readonly<Record<string, string>>;
251
272
  }
252
273
  interface CaseResult {
253
274
  readonly ok: boolean;
@@ -261,7 +282,7 @@ interface CaseResult {
261
282
  * the way a page's drag session does: a press on a handle, the first move past the lift threshold lifting the item and
262
283
  * asking `targets` for every drop target, a pointer over the most precise of them (its `pick`: pass
263
284
  * `@n-uf/motion/drag`'s `targetAt`, the one pick rule), the preview drawn from that target's `after.layout`, and a
264
- * release committing `after.scene`. Every solve carries the layout before it as `previous`. The kits' hosts do the same
285
+ * release committing `after.scene`. Every solve carries the layout before it as `previous`. An integrating app's host does the same
265
286
  * with their own pointer and DOM; the rows are the contract between them.
266
287
  *
267
288
  * Also exported: `resolvePlace` (a point that reaches the target at a place, under a pick rule), the pure step a host
@@ -270,7 +291,7 @@ interface CaseResult {
270
291
 
271
292
  /** The lift threshold: the pointer moves this far (px) from the press before the item lifts. */
272
293
  declare const LIFT_THRESHOLD = 4;
273
- /** How far past an edge's ends its first and last gaps reach (px); the kits' toolbars use 24. */
294
+ /** How far past an edge's ends its first and last gaps reach (px); toolbars use 24. */
274
295
  declare const END_REACH = 24;
275
296
  /**
276
297
  * The most precise target under `point`: the lowest priority number, then the smallest zone; null when none is. A
@@ -295,8 +316,8 @@ interface AimArea {
295
316
  /**
296
317
  * A pointer position that reaches the target at `place`: inside its hit and not covered by a more precise target
297
318
  * (`pick` finds it there: the host's pick rule, `@n-uf/motion/drag`'s `targetAt`; default the same rule, `pickTarget`).
298
- * It tries the hit's centre, then a grid across the hit; a target over the whole plane (the float) is aimed at the
299
- * content's centre, then the stage's, then a grid across the stage. Null when no point reaches it (a gap that a home or
319
+ * It tries the hit's center, then a grid across the hit; a target over the whole plane (the float) is aimed at the
320
+ * content's center, then the stage's, then a grid across the stage. Null when no point reaches it (a gap that a home or
300
321
  * a blocked spot covers entirely).
301
322
  */
302
323
  declare function resolvePlace(list: readonly SceneTarget[], place: ScenePlace, item: string, area_: AimArea, pick?: PickRule): Point | null;
@@ -329,7 +350,7 @@ interface SceneHostOptions {
329
350
  /** Where a press with no `point` holds the item, px from its top-left corner (default 8, 8). A test varies it to prove no row depends on it. */
330
351
  readonly grab?: Point;
331
352
  /**
332
- * The pick rule: which target the pointer is over. Pass `@n-uf/motion/drag`'s `targetAt`, the rule a kit's drag intent
353
+ * The pick rule: which target the pointer is over. Pass `@n-uf/motion/drag`'s `targetAt`, the rule an app's drag intent
333
354
  * runs, so the reference host and the kit agree on every boundary pixel. Default: the same rule (`pickTarget`).
334
355
  */
335
356
  readonly pick?: PickRule;
@@ -408,6 +429,27 @@ declare const g: {
408
429
  drag: (item: string, place: ScenePlace, grab?: Point) => Gesture[];
409
430
  };
410
431
 
432
+ /** A row id to the host's id. */
433
+ type IdMap = Readonly<Record<string, string>>;
434
+ /** One rename of one id. */
435
+ type Rename = (id: string) => string;
436
+ /** The renames of a map: `to` (a row's id to the host's) and `from` (back); the identity with no map. */
437
+ declare function idRenames(ids: IdMap | undefined): {
438
+ readonly to: Rename;
439
+ readonly from: Rename;
440
+ readonly active: boolean;
441
+ };
442
+ /** A scene with every item and edge id renamed. */
443
+ declare function mapScene(s: Scene, f: Rename): Scene;
444
+ /** A place with its edge (a `gap` or `side` place) renamed. */
445
+ declare function mapPlace(p: ScenePlace, f: Rename): ScenePlace;
446
+ /** A gesture with its `item`, `edge` and place renamed. */
447
+ declare function mapGesture(g: Gesture, f: Rename): Gesture;
448
+ /** A layout with every id renamed (see the module's docs for which). */
449
+ declare function mapLayout(l: SceneLayout, f: Rename): SceneLayout;
450
+ /** A stored form with every id renamed. */
451
+ declare function mapStored(s: StoredScene, f: Rename): StoredScene;
452
+
411
453
  interface WinSpec {
412
454
  readonly card: {
413
455
  readonly min: number;
@@ -425,7 +467,9 @@ interface WinSpec {
425
467
  /** The folded bar's length. */
426
468
  readonly barMain: number;
427
469
  }
470
+ /** Window A: wide cards, a 12 px gap and 12 px of padding each side; its stage is the window's body, padding inside. */
428
471
  declare const WINDOW_A: WinSpec;
472
+ /** Window B: narrower cards, flush (no gap, no padding); its stage is the window's body, as A's. */
429
473
  declare const WINDOW_B: WinSpec;
430
474
  declare const WINDOW_BARE: WinSpec;
431
475
  interface WinOptions {
@@ -458,7 +502,7 @@ interface WinOptions {
458
502
  /** A window: dynamic columns on both sides, a rail on each, `contentMin`, padding and gap. */
459
503
  declare function winScene(spec: WinSpec, o?: WinOptions): Scene;
460
504
 
461
- /** Every row, in order: the docking cases, the bar cases, the built-in rules, the kits' gestures, the two windows. */
505
+ /** Every row, in order: the docking cases, the bar cases, the built-in rules, the panel gestures, the two windows. */
462
506
  declare const CASES: readonly CaseRow[];
463
507
  /** The groups rows are listed under, in order, with their titles. */
464
508
  declare const CASE_GROUPS: readonly {
@@ -468,4 +512,4 @@ declare const CASE_GROUPS: readonly {
468
512
  /** The row with this id, or undefined. */
469
513
  declare const caseById: (id: string) => CaseRow | undefined;
470
514
 
471
- export { type AimArea, type AsyncCaseHost, CASES, CASE_GROUPS, type CaseGroup, type CaseHost, type CaseResult, type CaseRow, type CaseSettings, type Checkpoint, type DomCheck, type DomRoot, END_REACH, type EdgeExpect, type Gesture, type GestureType, type ItemExpect, LIFT_THRESHOLD, type LayoutExpect, type PickRule, type SceneHost, type SceneHostOptions, type StoredExpect, WINDOW_A, WINDOW_B, WINDOW_BARE, type WinOptions, type WinSpec, caseById, createSceneHost, defaultItemSelector, g, layoutIssues, pickTarget, resolvePlace, runCase, runCaseAsync, runCases, runCasesAsync, winScene };
515
+ export { type AimArea, type AsyncCaseHost, CASES, CASE_GROUPS, type CaseGroup, type CaseHost, type CaseRequires, type CaseResult, type CaseRow, type CaseSettings, type Checkpoint, type DomCheck, type DomRoot, END_REACH, type EdgeExpect, type Gesture, type GestureType, type IdMap, type ItemExpect, LIFT_THRESHOLD, type LayoutExpect, type PickRule, type Rename, type SceneHost, type SceneHostOptions, type StoredExpect, WINDOW_A, WINDOW_B, WINDOW_BARE, type WinOptions, type WinSpec, caseById, createSceneHost, defaultItemSelector, g, idRenames, layoutIssues, mapGesture, mapLayout, mapPlace, mapScene, mapStored, pickTarget, resolvePlace, runCase, runCaseAsync, runCases, runCasesAsync, winScene };