@weasel-js/hud 1.11.0 → 1.12.0

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/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["solid","pathFromD","pathFromD","solid","loupeInnerView","registerDefaultFont","cursorForZone","createRevision","isFocusable","DEFAULT_WIDGET_CLAIMS","createHudContribution","createHud","attachHud","DEFAULT_WINDOW_METRICS","HUD_AFFORDANCE_KIND","claimsOf","pathFromD$1","loupeInnerView$1","labelOf","e","menuNumberText","c","level","stack","deepest","at","checkable","open","i","accessibleMenu","BLUR_LAYERS","BLUR_LAYER_ALPHA","solid$2","roundRectD","k","r","w","h","x","y","outer","rect","b","roundRectPath","s","radius","p","color","children","step","inset","margin","hole","ring","boxShadowCommands","under","over","innerRadius","padding","layers","resolveCurrentColor","current","ROOT","INHERITED","tags","m","body","attrs","a","num","v","d","nums","transformOf","identity","fn","args","next","translate","scale","rotateAboutPoint","multiply","arcRectD","rx","ry","ellipseD","cx","cy","shapeD","name","pts","paintOf","shapeCommands","out","fill","cmd","path","alpha","stroke","dash","frameFor","parent","t","group","mat3","glyphCommands","root","skipping","glyph","top","f","cmds","numberChips","end","panelW","chipAt","inside","plus","minus","valueRowWidth","measure","solid$1","mark","pathFromD","numberCommands","cell","live","ink","low","value","menuNumberCanStep","high","textCommandFromRuns","colorCommands","DEFAULT_MENU_METRICS","rowLayout","entries","row","shortcutOf","formatShortcut","panelSize","last","text","chip","solid","caret","check","ICON_SIZE","PANEL_SHADOW","drawPanel","ctx","fg","muted","tokenPx","font","shadow","parseBoxShadow","expandVars","rows","highlight","iconX","iconY","ref","toIconRef","icons","shown","rowAt","estimateWidth","fontSize","measureLabel","metrics","metricsOf","resolveFontVariant","fontFamily","units","prev","ch","cp","createPlacer","placed","measured","faces","faceGeneration","opts","bounds","width","height","kept","parentRow","old","size","placeMenuUnder","placeMenu","placeSubmenu","CLAIMS","underOnCanvas","toCanvas","createMenuWidget","rev","createMenuController","withLinks","href","place","family","panels","disposed","armed","hoverPanel","levelAt","union","x0","y0","x1","y1","enter","pointer","evt","choose","index","dir","key","accessibleTree","attachMenuHost","widget","returnTo","drop","hud","giveBack","sync","host","held","dismiss","wheel","unsubscribe","unfocus","createContentWatch","camera","seen","view","now","version","moved","POINTER_ENDS","followPointer","holding","local","input","onPointerMove","lens","onPointerDown","onPointerEnd","type","readbackRegion","target","dpr","gx","clamp","rw","gy","bufferHeight","rh","raw","gl","flipped","stride","src","backdropOf","LENS_VIEW","NO_RECT","lensCamera","world","aim","factor","screenToWorld","viewToTransform","createLoupe","element","interactive","pixels","dropPixels","releaseImageSource","pixelsPending","refreshWanted","landed","watch","refreshAsked","content","model","drawVector","drawPixels","backdropColor","backdrop","innerView","createViewportLayer","win","scheduleRefresh","read","cssRect","refreshPixels","data","bmp","requestRedraw","readHex","px","surface","unsubscribeFrame","createLoupeModel","teardown","unfollow","DEFAULT_FONT_FAMILY","loupeInnerView"],"sources":["../src/menu/accessibleMenu.ts","../src/boxShadow.ts","../src/glyph.ts","../src/menu/valueRows.ts","../src/menu/drawPanel.ts","../src/menu/measureLabel.ts","../src/menu/placePanels.ts","../src/menu/menuWidget.ts","../src/menu/attachMenuHost.ts","../src/loupe/contentWatch.ts","../src/loupe/pointerAim.ts","../src/loupe/readback.ts","../src/loupe/createLoupe.ts"],"sourcesContent":["import { menuNumberText, type MenuController, type MenuRowEntry } from '@weasel-js/menu';\nimport type { HudAccessibleNode } from '../widget';\n\n/** A row's name: a value row's label and the value it holds now. */\nfunction labelOf(c: MenuController, e: MenuRowEntry): string {\n if (e.kind === 'number') return `${e.label}: ${menuNumberText(c.numberValue(e), e)}`;\n if (e.kind === 'color') return `${e.label}: ${e.value ?? '—'}`;\n return e.label;\n}\n\n/** One level's rows, with the open submenu nested under the row it hangs from. */\nfunction level(c: MenuController, at: number): HudAccessibleNode[] {\n const stack = c.stack();\n const deepest = at === stack.length - 1;\n return c.entriesAt(at).map((e, i): HudAccessibleNode => {\n if (e.kind === 'separator') return { role: 'separator', key: e.key };\n const checkable = e.kind === 'item' && e.checked !== undefined;\n const open = e.kind === 'submenu' && stack[at] === i && stack.length > at + 1;\n return {\n role: checkable ? 'menuitemcheckbox' : 'menuitem',\n key: e.key,\n label: labelOf(c, e),\n ...(deepest && stack[at] === i ? { active: true } : {}),\n ...(e.kind === 'item' && e.checked !== undefined ? { checked: e.checked } : {}),\n ...(e.disabled || e.kind === 'color' ? { disabled: true } : {}),\n ...(e.kind === 'submenu' ? { expanded: open } : {}),\n ...(open ? { children: [{ role: 'menu', key: 'menu', label: e.label, children: level(c, at + 1) }] } : {}),\n };\n });\n}\n\n/** An open menu as the accessibility tree a DOM menu's panels show: rows with their roles and states, and the\n * highlighted row of the innermost open level active. */\nexport function accessibleMenu(c: MenuController): HudAccessibleNode {\n return { role: 'menu', key: 'menu', label: 'Context menu', children: level(c, 0) };\n}\n","import type { DrawCommand } from '@weasel-js/core/renderer';\nimport { pathFromD, roundRectPath, type Path } from '@weasel-js/geom';\nimport { resolveCurrentColor, type BoxShadow } from '@weasel-js/theme';\nimport type { WidgetBounds } from './widget';\n\n// A blurred layer is drawn as nested rounded rects reaching blur / 2 either side of its edge,\n// whose overlap builds the falloff.\nconst BLUR_LAYERS = 7;\nconst BLUR_LAYER_ALPHA = 0.16;\n\nconst solid = (color: string) => ({ paint: { kind: 'solid' as const, color } });\n\nfunction roundRectD(x: number, y: number, w: number, h: number, r: number): string {\n const k = Math.max(0, Math.min(r, w / 2, h / 2));\n if (k === 0) return `M ${x} ${y} H ${x + w} V ${y + h} H ${x} Z`;\n return `M ${x + k} ${y} H ${x + w - k} A ${k} ${k} 0 0 1 ${x + w} ${y + k} V ${y + h - k} `\n + `A ${k} ${k} 0 0 1 ${x + w - k} ${y + h} H ${x + k} A ${k} ${k} 0 0 1 ${x} ${y + h - k} `\n + `V ${y + k} A ${k} ${k} 0 0 1 ${x + k} ${y} Z`;\n}\n\nfunction outer(b: WidgetBounds, radius: number, s: BoxShadow, color: string): DrawCommand {\n const rect = (e: number): Path | null => {\n const w = b.w + e * 2;\n const h = b.h + e * 2;\n return w > 0 && h > 0 ? roundRectPath(b.x + s.x - e, b.y + s.y - e, w, h, Math.max(0, radius + e)) : null;\n };\n if (s.blur <= 0) {\n const p = rect(s.spread);\n return { kind: 'group', children: p ? [{ kind: 'path', path: p, fill: solid(color) }] : [] };\n }\n const children: DrawCommand[] = [];\n const step = s.blur / (BLUR_LAYERS - 1);\n for (let i = 0; i < BLUR_LAYERS; i++) {\n const p = rect(s.spread + s.blur / 2 - i * step);\n if (p) children.push({ kind: 'path', path: p, fill: solid(color) });\n }\n return { kind: 'group', alpha: BLUR_LAYER_ALPHA, children };\n}\n\n/** An inset layer, hard-edged whatever its blur: the box less itself moved by the offset and shrunk by the spread. */\nfunction inset(b: WidgetBounds, radius: number, s: BoxShadow, color: string): DrawCommand {\n const margin = Math.abs(s.x) + Math.abs(s.y) + Math.abs(s.spread) + 1;\n const hole = roundRectD(b.x + s.x + s.spread, b.y + s.y + s.spread, b.w - s.spread * 2, b.h - s.spread * 2,\n Math.max(0, radius - s.spread));\n const ring = pathFromD(`${roundRectD(b.x - margin, b.y - margin, b.w + margin * 2, b.h + margin * 2, 0)} ${hole}`);\n return {\n kind: 'group',\n clip: roundRectPath(b.x, b.y, b.w, b.h, radius),\n children: [{ kind: 'path', path: ring.kind === 'polygon' ? { ...ring, fillRule: 'evenodd' } : ring, fill: solid(color) }],\n };\n}\n\n/**\n * A CSS `box-shadow` list cast by a rounded box, as draw commands: `under` goes beneath the box's\n * face and `over` on top of it, for `inset` layers, which fall inside `padding` (the box less its\n * border). Layers draw last-first, so the first is topmost, as in CSS. `current` is what a layer\n * written in `currentColor` takes.\n */\nexport function boxShadowCommands(\n b: WidgetBounds, radius: number, layers: readonly BoxShadow[], current: string, padding: WidgetBounds = b,\n): { under: DrawCommand[]; over: DrawCommand[] } {\n const under: DrawCommand[] = [];\n const over: DrawCommand[] = [];\n const innerRadius = Math.max(0, radius - (padding.x - b.x));\n for (const s of [...layers].reverse()) {\n const color = resolveCurrentColor(s.color, current);\n if (s.inset) over.push(inset(padding, innerRadius, s, color));\n else under.push(outer(b, radius, s, color));\n }\n return { under, over };\n}\n","import type { DrawCommand } from '@weasel-js/core/renderer';\nimport {\n identity, mat3, multiply, pathFromD, rotateAboutPoint, scale, translate, type Affine, type Path,\n} from '@weasel-js/geom';\nimport type { IconGlyph } from '@weasel-js/icons';\n\n/** The attributes a glyph's elements inherit, as `<Icon>`'s root `<svg>` sets them. */\nconst ROOT: Readonly<Record<string, string>> = {\n fill: 'none', stroke: 'currentColor', 'stroke-width': '1.5',\n 'stroke-linecap': 'round', 'stroke-linejoin': 'round',\n};\n\nconst INHERITED = new Set([\n 'fill', 'fill-opacity', 'fill-rule', 'stroke', 'stroke-width', 'stroke-opacity',\n 'stroke-linecap', 'stroke-linejoin', 'stroke-dasharray',\n]);\n\n/** What a glyph is drawn in the place of `currentColor` with, and where. */\nexport interface GlyphPlacement {\n x: number;\n y: number;\n /** Width and height; the glyph's 20×20 viewBox scales to it. */\n size: number;\n color: string;\n}\n\ninterface Tag { close: boolean; name: string; attrs: Record<string, string>; selfClosing: boolean }\n\nfunction* tags(body: string): Generator<Tag> {\n for (const m of body.matchAll(/<(\\/?)([a-zA-Z]+)((?:\\s+[\\w:-]+=\"[^\"]*\")*)\\s*(\\/?)>/g)) {\n const attrs: Record<string, string> = {};\n for (const a of m[3]!.matchAll(/([\\w:-]+)=\"([^\"]*)\"/g)) attrs[a[1]!] = a[2]!;\n yield { close: m[1] === '/', name: m[2]!, attrs, selfClosing: m[4] === '/' };\n }\n}\n\nconst num = (v: string | undefined, d = 0) => (v === undefined || v === '' ? d : Number(v));\nconst nums = (v: string) => v.trim().split(/[\\s,]+/).filter((s) => s !== '').map(Number);\n\n/** An SVG `transform` list as one affine. */\nfunction transformOf(v: string | undefined): Affine {\n let m = identity();\n if (!v) return m;\n for (const [, fn, args] of v.matchAll(/(\\w+)\\s*\\(([^)]*)\\)/g)) {\n const a = nums(args!);\n const next: Affine | null = fn === 'translate' ? translate(a[0] ?? 0, a[1] ?? 0)\n : fn === 'scale' ? scale(a[0] ?? 1, a[1] ?? a[0] ?? 1)\n : fn === 'rotate' ? rotateAboutPoint(a[1] ?? 0, a[2] ?? 0, ((a[0] ?? 0) * Math.PI) / 180)\n : fn === 'matrix' && a.length === 6 ? (a as unknown as Affine) : null;\n if (next) m = multiply(m, next);\n }\n return m;\n}\n\nfunction arcRectD(x: number, y: number, w: number, h: number, rx: number, ry: number): string {\n if (rx <= 0 || ry <= 0) return `M ${x} ${y} H ${x + w} V ${y + h} H ${x} Z`;\n return `M ${x + rx} ${y} H ${x + w - rx} A ${rx} ${ry} 0 0 1 ${x + w} ${y + ry} V ${y + h - ry} `\n + `A ${rx} ${ry} 0 0 1 ${x + w - rx} ${y + h} H ${x + rx} A ${rx} ${ry} 0 0 1 ${x} ${y + h - ry} `\n + `V ${y + ry} A ${rx} ${ry} 0 0 1 ${x + rx} ${y} Z`;\n}\n\nconst ellipseD = (cx: number, cy: number, rx: number, ry: number) =>\n `M ${cx - rx} ${cy} A ${rx} ${ry} 0 1 0 ${cx + rx} ${cy} A ${rx} ${ry} 0 1 0 ${cx - rx} ${cy} Z`;\n\n/** A shape element's outline as path data, or undefined for an element that draws none. */\nfunction shapeD(name: string, a: Readonly<Record<string, string>>): string | undefined {\n switch (name) {\n case 'path': return a.d;\n case 'rect': {\n const w = num(a.width), h = num(a.height);\n const rx = Math.min(num(a.rx, num(a.ry)), w / 2), ry = Math.min(num(a.ry, num(a.rx)), h / 2);\n return arcRectD(num(a.x), num(a.y), w, h, rx, ry);\n }\n case 'circle': return ellipseD(num(a.cx), num(a.cy), num(a.r), num(a.r));\n case 'ellipse': return ellipseD(num(a.cx), num(a.cy), num(a.rx), num(a.ry));\n case 'line': return `M ${num(a.x1)} ${num(a.y1)} L ${num(a.x2)} ${num(a.y2)}`;\n case 'polygon':\n case 'polyline': {\n const p = nums(a.points ?? '');\n if (p.length < 4) return undefined;\n const pts = [];\n for (let i = 0; i + 1 < p.length; i += 2) pts.push(`${p[i]} ${p[i + 1]}`);\n return `M ${pts.join(' L ')}${name === 'polygon' ? ' Z' : ''}`;\n }\n default: return undefined;\n }\n}\n\nconst paintOf = (v: string | undefined, color: string): string | null =>\n (v === undefined || v === 'none' ? null : /^currentcolor$/i.test(v) ? color : v);\n\n/** One shape's commands: its fill, then its stroke, each at its own opacity. */\nfunction shapeCommands(path: Path, a: Readonly<Record<string, string>>, color: string): DrawCommand[] {\n const out: DrawCommand[] = [];\n const fill = paintOf(a.fill, color);\n if (fill) {\n const p = path.kind === 'polygon' && a['fill-rule'] === 'evenodd' ? { ...path, fillRule: 'evenodd' as const } : path;\n const cmd: DrawCommand = { kind: 'path', path: p, fill: { paint: { kind: 'solid', color: fill } } };\n const alpha = num(a['fill-opacity'], 1);\n out.push(alpha < 1 ? { kind: 'group', alpha, children: [cmd] } : cmd);\n }\n const stroke = paintOf(a.stroke, color);\n if (stroke) {\n const dash = a['stroke-dasharray'] && a['stroke-dasharray'] !== 'none' ? nums(a['stroke-dasharray']) : undefined;\n const cmd: DrawCommand = {\n kind: 'path', path,\n stroke: {\n paint: { kind: 'solid', color: stroke },\n width: num(a['stroke-width'], 1),\n cap: a['stroke-linecap'] as 'butt' | 'round' | 'square' | undefined,\n join: a['stroke-linejoin'] as 'miter' | 'round' | 'bevel' | undefined,\n ...(dash ? { dash } : {}),\n },\n };\n const alpha = num(a['stroke-opacity'], 1);\n out.push(alpha < 1 ? { kind: 'group', alpha, children: [cmd] } : cmd);\n }\n return out;\n}\n\ninterface Frame { attrs: Readonly<Record<string, string>>; children: DrawCommand[]; group: DrawCommand & { kind: 'group' } }\n\nfunction frameFor(t: Tag, parent: Readonly<Record<string, string>>): Frame {\n const attrs = { ...parent };\n for (const [k, v] of Object.entries(t.attrs)) if (INHERITED.has(k)) attrs[k] = v;\n const children: DrawCommand[] = [];\n const group: Frame['group'] = { kind: 'group', children };\n const m = transformOf(t.attrs.transform);\n if (m.some((v, i) => v !== identity()[i])) group.transform = mat3.fromAffine(m);\n // Every nested `<svg>` a glyph uses has a viewBox matching its own box, so it only clips.\n if (t.name === 'svg') {\n group.clip = { kind: 'rect', x: num(t.attrs.x), y: num(t.attrs.y), width: num(t.attrs.width), height: num(t.attrs.height) };\n }\n return { attrs, children, group };\n}\n\n/**\n * A glyph as draw commands, placed in a square and drawn in `color` wherever it says\n * `currentColor`, as `<Icon>` draws it in the DOM. Reads the elements the icon tables use — `path`,\n * `rect`, `circle`, `ellipse`, `line`, `polygon`, `polyline`, `g` and a nested `svg` — with their\n * presentation attributes and transforms. `defs` and what they hold are skipped, so a `clip-path`\n * pointing into them does not clip.\n */\nexport function glyphCommands(glyph: IconGlyph, at: GlyphPlacement): DrawCommand[] {\n const k = at.size / 20;\n const root: Frame = {\n attrs: ROOT, children: [],\n group: { kind: 'group', transform: mat3.fromAffine([k, 0, 0, k, at.x, at.y]), children: [] },\n };\n root.group.children = root.children;\n const stack: Frame[] = [root];\n let skipping = 0;\n for (const t of tags(glyph.body)) {\n const top = stack.at(-1)!;\n if (skipping > 0 || t.name === 'defs' || t.name === 'clipPath') {\n if (!t.selfClosing) skipping += t.close ? -1 : 1;\n continue;\n }\n if (t.close) {\n if ((t.name === 'g' || t.name === 'svg') && stack.length > 1) stack.pop();\n continue;\n }\n if (t.name === 'g' || t.name === 'svg') {\n const f = frameFor(t, top.attrs);\n top.children.push(f.group);\n if (!t.selfClosing) stack.push(f);\n continue;\n }\n const d = shapeD(t.name, t.attrs);\n if (d === undefined) continue;\n const f = frameFor(t, top.attrs);\n const cmds = shapeCommands(pathFromD(d), f.attrs, at.color);\n if (f.group.transform) top.children.push({ kind: 'group', transform: f.group.transform, children: cmds });\n else top.children.push(...cmds);\n }\n return [root.group];\n}\n","import type { DrawCommand } from '@weasel-js/core/renderer';\nimport { pathFromD, textCommandFromRuns } from '@weasel-js/core';\nimport { menuNumberCanStep, menuNumberText, type MenuColorEntry, type MenuEntry, type MenuNumberEntry } from '@weasel-js/menu';\nimport type { WidgetBounds } from '../widget';\nimport type { MenuMetrics } from './drawPanel';\n\n/** A span across a panel, from its left edge. */\nexport interface Span { x: number; w: number }\n\n/**\n * Where a number row's step chips and value sit, at the row's end: a minus chip, the value in a cell of fixed\n * width so a changing value moves nothing, and a plus chip. `width` is all three.\n */\nexport function numberChips(panelW: number, m: MenuMetrics): { minus: Span; value: Span; plus: Span; width: number } {\n const s = m.rowHeight;\n const end = panelW - m.padX;\n return { minus: { x: end - 4 * s, w: s }, value: { x: end - 3 * s, w: 2 * s }, plus: { x: end - s, w: s }, width: 4 * s };\n}\n\n/** Which way the chip under panel-local `x` steps a number row: 1, -1, or null off both. */\nexport function chipAt(panelW: number, m: MenuMetrics, x: number): 1 | -1 | null {\n const { minus, plus } = numberChips(panelW, m);\n const inside = (s: Span) => x >= s.x && x < s.x + s.w;\n return inside(plus) ? 1 : inside(minus) ? -1 : null;\n}\n\n/** What a value row needs past its label, for sizing the panel; undefined for any other row. */\nexport function valueRowWidth(e: MenuEntry, m: MenuMetrics, measure: (text: string, fontSize: number) => number): number | undefined {\n if (e.kind === 'number') return m.padX + numberChips(0, m).width;\n if (e.kind === 'color') return Math.max(m.rowHeight, m.padX + measure(e.value ?? '—', m.fontSize));\n return undefined;\n}\n\nconst solid = (color: string) => ({ paint: { kind: 'solid' as const, color } });\nconst mark = (d: string, color: string): DrawCommand => ({\n kind: 'path', path: pathFromD(d), stroke: { paint: { kind: 'solid', color }, width: 1.5, cap: 'round' },\n});\n\n/** The colors and font a value row draws in. */\nexport interface ValueInk { fg: string; muted: string; border: string; font: { fontFamily: string; fontSize: number } }\n\n/** A number row's chips and value. A chip with nowhere to step to is muted, as is all of a disabled row. */\nexport function numberCommands(\n b: WidgetBounds, r: { y: number; h: number }, e: MenuNumberEntry, value: number | undefined, m: MenuMetrics, ink: ValueInk,\n): DrawCommand[] {\n const { minus, value: cell, plus } = numberChips(b.w, m);\n const cy = b.y + r.y + r.h / 2;\n const color = (live: boolean) => (live && !e.disabled ? ink.fg : ink.muted);\n const cx = (s: Span) => b.x + s.x + s.w / 2;\n const low = value !== undefined && !menuNumberCanStep(e, value, -1);\n const high = value !== undefined && !menuNumberCanStep(e, value, 1);\n return [\n mark(`M ${cx(minus) - 4} ${cy} L ${cx(minus) + 4} ${cy}`, color(!low)),\n textCommandFromRuns(\n b.x + cell.x, b.y + r.y, [{ text: menuNumberText(value, e), fill: solid(color(true)) }],\n { ...ink.font, align: 'center' }, undefined, r.h, 'center', undefined, cell.w,\n ),\n mark(`M ${cx(plus) - 4} ${cy} L ${cx(plus) + 4} ${cy} M ${cx(plus)} ${cy - 4} L ${cx(plus)} ${cy + 4}`, color(!high)),\n ];\n}\n\n/** The swatch a color row draws in its icon column, and its hex at the row's end. */\nexport function colorCommands(\n b: WidgetBounds, r: { y: number; h: number }, e: MenuColorEntry, m: MenuMetrics, ink: ValueInk,\n): DrawCommand[] {\n const out: DrawCommand[] = [];\n if (e.value !== undefined) {\n const size = 12;\n const x = b.x + m.padX + (m.rowHeight - size) / 2;\n const y = b.y + r.y + (r.h - size) / 2;\n out.push({\n kind: 'path', path: { kind: 'rect', x, y, width: size, height: size },\n fill: solid(e.value), stroke: { paint: { kind: 'solid', color: ink.border }, width: 1 },\n });\n }\n out.push(textCommandFromRuns(\n b.x + m.padX, b.y + r.y, [{ text: e.value ?? '—', fill: solid(ink.muted) }],\n { ...ink.font, align: 'right' }, undefined, r.h, 'center', undefined, b.w - m.padX * 2,\n ));\n return out;\n}\n","import type { DrawCommand } from '@weasel-js/core/renderer';\nimport { pathFromD, textCommandFromRuns } from '@weasel-js/core';\nimport { roundRectPath } from '@weasel-js/geom';\nimport { formatShortcut } from '@weasel-js/gestures';\nimport type { MenuEntry, MenuNumberEntry } from '@weasel-js/menu';\nimport { expandVars, parseBoxShadow, resolveCurrentColor, tokenPx } from '@weasel-js/theme';\nimport { toIconRef, type IconRegistry } from '@weasel-js/icons';\nimport { boxShadowCommands } from '../boxShadow';\nimport { glyphCommands } from '../glyph';\nimport type { HudDrawCtx, WidgetBounds } from '../widget';\nimport { colorCommands, numberCommands, valueRowWidth } from './valueRows';\n\n/** Sizes of a HUD menu panel, in CSS pixels. */\nexport interface MenuMetrics {\n rowHeight: number;\n padX: number;\n padY: number;\n separatorHeight: number;\n minWidth: number;\n fontSize: number;\n}\n\n/** The metrics a menu widget uses when given none, close to the DOM menu's. */\nexport const DEFAULT_MENU_METRICS: MenuMetrics = {\n rowHeight: 24, padX: 8, padY: 4, separatorHeight: 9, minWidth: 180, fontSize: 13,\n};\n\n/** Each entry's y offset and height inside a panel. */\nexport function rowLayout(entries: readonly MenuEntry[], m: MenuMetrics): { y: number; h: number }[] {\n let y = m.padY;\n return entries.map((e) => {\n const h = e.kind === 'separator' ? m.separatorHeight : m.rowHeight;\n const row = { y, h };\n y += h;\n return row;\n });\n}\n\n/** A row's shortcut as the DOM menu prints it, or undefined. */\nconst shortcutOf = (e: MenuEntry): string | undefined =>\n (e.kind === 'item' ? formatShortcut(e.shortcut) : undefined);\n\n/** A panel's size: its widest row — label, then a shortcut or the caret column —\n * plus the icon column, never under `minWidth`. */\nexport function panelSize(\n entries: readonly MenuEntry[], m: MenuMetrics, measure: (text: string, fontSize: number) => number,\n): { w: number; h: number } {\n const rows = rowLayout(entries, m);\n const last = rows.at(-1);\n const rowWidth = (e: MenuEntry) => {\n if (e.kind === 'separator') return 0;\n const value = valueRowWidth(e, m, measure);\n if (value !== undefined) return measure(e.label, m.fontSize) + value;\n const chip = shortcutOf(e);\n return measure(e.label, m.fontSize) + Math.max(m.rowHeight, chip ? m.padX + measure(chip, m.fontSize) : 0);\n };\n const text = Math.max(0, ...entries.map(rowWidth));\n return {\n w: Math.max(m.minWidth, Math.ceil(text) + m.padX * 2 + m.rowHeight),\n h: (last ? last.y + last.h : 0) + m.padY,\n };\n}\n\nconst solid = (color: string) => ({ paint: { kind: 'solid' as const, color } });\nconst rect = (x: number, y: number, width: number, height: number, color: string): DrawCommand => ({\n kind: 'path', path: { kind: 'rect', x, y, width, height }, fill: solid(color),\n});\n\n/** A right-pointing chevron centered on (cx, cy). The bundled atlas has no `›` glyph. */\nfunction caret(cx: number, cy: number, color: string): DrawCommand {\n const s = 3;\n return {\n kind: 'path',\n path: pathFromD(`M ${cx - s / 2} ${cy - s} L ${cx + s / 2} ${cy} L ${cx - s / 2} ${cy + s}`),\n stroke: { paint: { kind: 'solid', color }, width: 1.5, cap: 'round' },\n };\n}\n\n/** A check mark centered on (cx, cy), for a row whose action is on. */\nfunction check(cx: number, cy: number, color: string): DrawCommand {\n return {\n kind: 'path',\n path: pathFromD(`M ${cx - 4} ${cy} L ${cx - 1.5} ${cy + 2.5} L ${cx + 4} ${cy - 3}`),\n stroke: { paint: { kind: 'solid', color }, width: 1.5, cap: 'round', join: 'round' },\n };\n}\n\n/** Where a menu finds the glyph a row's `icon` names: an icon registry, or anything answering as one. */\nexport type MenuIcons = Pick<IconRegistry, 'get' | 'getVersion'>;\n\n/** The DOM row draws its icon at 16px. */\nconst ICON_SIZE = 16;\n\n// The shadow `.surface` in ui's listbox.module.css gives the DOM panel.\nconst PANEL_SHADOW = 'var(--wzl-bevel-raised, 0 8px 24px var(--wzl-shadow))';\n\n/** One panel's commands: its rounded face and the DOM panel's box shadow, a highlight behind row\n * `highlight`, and every row, with the glyph `icons` holds for each row's icon. A number row shows what\n * `shown` says it holds, by default what it opened with. */\nexport function drawPanel(\n ctx: HudDrawCtx, b: WidgetBounds, entries: readonly MenuEntry[], highlight: number | null, m: MenuMetrics,\n icons?: MenuIcons, shown: (e: MenuNumberEntry) => number | undefined = (e) => e.value,\n): DrawCommand[] {\n const t = ctx.tokens;\n const fg = t['--wzl-fg'];\n const muted = resolveCurrentColor(t['--wzl-fg-muted'], fg);\n const radius = tokenPx('--wzl-radius-md', t);\n const font = { fontFamily: ctx.defaultFont, fontSize: m.fontSize };\n const shadow = boxShadowCommands(b, radius, parseBoxShadow(expandVars(PANEL_SHADOW, t)), fg,\n { x: b.x + 1, y: b.y + 1, w: b.w - 2, h: b.h - 2 });\n const out: DrawCommand[] = [...shadow.under, {\n kind: 'path',\n path: roundRectPath(b.x, b.y, b.w, b.h, radius),\n fill: solid(t['--wzl-surface-popover']),\n stroke: { paint: { kind: 'solid', color: t['--wzl-border'] }, width: 1 },\n }, ...shadow.over];\n const rows = rowLayout(entries, m);\n entries.forEach((e, i) => {\n const r = rows[i]!;\n if (e.kind === 'separator') {\n out.push(rect(b.x + m.padX, b.y + r.y + Math.floor(r.h / 2), b.w - m.padX * 2, 1, t['--wzl-border']));\n return;\n }\n if (i === highlight) out.push(rect(b.x + 2, b.y + r.y, b.w - 4, r.h, t['--wzl-surface-hover']));\n // Nothing edits a color row, so it reads as a disabled one does.\n const color = e.disabled || e.kind === 'color' ? muted : fg;\n out.push(textCommandFromRuns(\n b.x + m.padX + m.rowHeight, b.y + r.y,\n [{ text: e.label, fill: solid(color) }],\n font, undefined, r.h, 'center',\n ));\n const iconX = b.x + m.padX + m.rowHeight / 2;\n const iconY = b.y + r.y + r.h / 2;\n const ref = e.kind !== 'color' && typeof e.icon === 'string' ? toIconRef(e.icon) : undefined;\n const glyph = ref ? icons?.get(ref) : undefined;\n if (e.kind === 'item' && e.checked) out.push(check(iconX, iconY, color));\n else if (glyph) out.push(...glyphCommands(glyph, { x: iconX - ICON_SIZE / 2, y: iconY - ICON_SIZE / 2, size: ICON_SIZE, color }));\n const chip = shortcutOf(e);\n if (chip) {\n out.push(textCommandFromRuns(\n b.x + m.padX, b.y + r.y, [{ text: chip, fill: solid(muted) }],\n { ...font, align: 'right' }, undefined, r.h, 'center', undefined, b.w - m.padX * 2,\n ));\n }\n const ink = { fg, muted, border: t['--wzl-border'], font };\n if (e.kind === 'number') out.push(...numberCommands(b, r, e, shown(e), m, ink));\n if (e.kind === 'color') out.push(...colorCommands(b, r, e, m, ink));\n if (e.kind === 'submenu') out.push(caret(b.x + b.w - m.padX - m.rowHeight / 2, b.y + r.y + r.h / 2, color));\n });\n return out;\n}\n\n/** Index of the entry under panel-local `y`, or null. */\nexport function rowAt(entries: readonly MenuEntry[], m: MenuMetrics, y: number): number | null {\n const i = rowLayout(entries, m).findIndex((r) => y >= r.y && y < r.y + r.h);\n return i < 0 ? null : i;\n}\n","import { metricsOf, resolveFontVariant } from '@weasel-js/font';\n\n/** A width for `text` with no face to measure it in. */\nexport function estimateWidth(text: string, fontSize: number): number {\n return text.length * fontSize * 0.55;\n}\n\n/** Width of `text` at `fontSize` in `fontFamily`, from the advances and\n * kerning of the face the text command lays it out with. A face not loaded\n * yet gives an estimate; `faceGeneration` moves when it lands. */\nexport function measureLabel(text: string, fontSize: number, fontFamily: string): number {\n const metrics = metricsOf(resolveFontVariant(fontFamily, 400, 'normal'));\n if (!metrics) return estimateWidth(text, fontSize);\n let units = 0;\n let prev: number | null = null;\n for (const ch of text) {\n const cp = ch.codePointAt(0)!;\n units += metrics.advanceOf(cp) ?? metrics.size * 0.55;\n if (prev !== null) units += metrics.kernOf(prev, cp);\n prev = cp;\n }\n return units * fontSize / metrics.size;\n}\n","import { placeMenu, placeMenuUnder, placeSubmenu, type MenuController, type MenuEntry, type Rect } from '@weasel-js/menu';\nimport { faceGeneration } from '@weasel-js/font';\nimport { panelSize, rowLayout, type MenuMetrics } from './drawPanel';\nimport { estimateWidth } from './measureLabel';\n\ntype XY = { x: number; y: number };\n\n/** What placing needs: where the menu opened, the canvas, and how to measure. */\nexport interface PlaceOptions {\n anchor: XY;\n /** The button the menu hangs from, in canvas pixels; when set, `anchor` is not used. */\n under?: Rect;\n canvasSize(): { width: number; height: number };\n measure(text: string, fontSize: number, fontFamily: string): number;\n metrics: MenuMetrics;\n}\n\ninterface Placed {\n entries: readonly MenuEntry[];\n parentRow: number | null;\n rect: Rect;\n}\n\n/**\n * Places each open level once, when it opens: a level keeps its rect for as\n * long as its entries and the parent row it hangs from stay the same. A new\n * font family, or a face landing, re-measures everything. With no family yet\n * — the hud has not drawn — widths are estimated rather than measured in a\n * guessed family.\n */\nexport function createPlacer(opts: PlaceOptions): (c: MenuController, fontFamily: string | null) => Rect[] {\n let placed: Placed[] = [];\n let measured: { family: string | null; faces: number } | null = null;\n\n return (c, fontFamily) => {\n const faces = faceGeneration();\n if (measured?.family !== fontFamily || measured.faces !== faces) {\n placed = [];\n measured = { family: fontFamily, faces };\n }\n const { width, height } = opts.canvasSize();\n const bounds = { x: 0, y: 0, w: width, h: height };\n const m = opts.metrics;\n const stack = c.stack();\n const next: Placed[] = [];\n let kept = true;\n for (let level = 0; level < stack.length; level++) {\n const entries = c.entriesAt(level);\n const parentRow = level === 0 ? null : stack[level - 1] ?? null;\n const old = placed[level];\n if (kept && old && old.entries === entries && old.parentRow === parentRow) {\n next.push(old);\n continue;\n }\n kept = false;\n const size = panelSize(entries, m, (t, s) => (fontFamily === null ? estimateWidth(t, s) : opts.measure(t, s, fontFamily)));\n let at: XY;\n if (level === 0) {\n at = opts.under ? placeMenuUnder(size, opts.under, bounds) : placeMenu(size, opts.anchor, bounds);\n } else {\n const parent = next[level - 1]!.rect;\n const row = rowLayout(c.entriesAt(level - 1), m)[parentRow!]!;\n at = placeSubmenu(size, { x: parent.x, y: parent.y + row.y, w: parent.w, h: row.h }, bounds);\n }\n const rect = { x: at.x, y: at.y, w: size.w, h: size.h };\n next.push({ entries, parentRow, rect });\n c.setPanel(level, rect);\n }\n placed = next;\n return next.map((p) => p.rect);\n };\n}\n","import { createMenuController, withLinks, type Rect } from '@weasel-js/menu';\nimport { faceGeneration } from '@weasel-js/font';\nimport type { ClaimableGesture, OpenMenu } from '@weasel-js/core';\nimport { createRevision, type HudAccessibleTree, type HudKeyEvent, type HudPointerEvent, type Widget, type WidgetBounds } from '../widget';\nimport { accessibleMenu } from './accessibleMenu';\nimport { DEFAULT_MENU_METRICS, drawPanel, rowAt, type MenuIcons, type MenuMetrics } from './drawPanel';\nimport { measureLabel } from './measureLabel';\nimport { createPlacer } from './placePanels';\nimport { chipAt } from './valueRows';\nimport type { Point } from '@weasel-js/geom';\n\nconst CLAIMS: readonly ClaimableGesture[] = ['pointer', 'doubleClick', 'contextMenu', 'longPress', 'wheel'];\n\n/** What {@link createMenuWidget} needs: the open menu, how to close it, and the canvas it draws on. */\nexport interface MenuWidgetOptions {\n open: OpenMenu;\n /** The menu is done: an item was chosen, or it was dismissed. */\n close(): void;\n /** Viewport point to canvas CSS pixels, for `open.client` and `open.under`. */\n toCanvas(client: Point): Point;\n canvasSize(): { width: number; height: number };\n /** Width of a label in the family the hud draws with. Defaults to the\n * registered face's own advances, which is what the text is laid out with. */\n measure?(text: string, fontSize: number, fontFamily: string): number;\n metrics?: MenuMetrics;\n /** Where a row's icon is looked up; without it no row draws one. */\n icons?: MenuIcons;\n onChange(): void;\n}\n\nfunction underOnCanvas(r: Rect, toCanvas: (client: Point) => Point): Rect {\n const a = toCanvas({ x: r.x, y: r.y });\n const b = toCanvas({ x: r.x + r.w, y: r.y + r.h });\n return { x: a.x, y: a.y, w: b.x - a.x, h: b.y - a.y };\n}\n\n/** A widget that draws `open` as one panel per open level, driven by a menu controller it owns. */\nexport function createMenuWidget(opts: MenuWidgetOptions): Widget {\n const m = opts.metrics ?? DEFAULT_MENU_METRICS;\n const rev = createRevision(opts.onChange);\n const c = createMenuController({\n entries: withLinks(opts.open.entries, (href) => window.location.assign(href)),\n highlightFirst: opts.open.source === 'keyboard', onClose: opts.close,\n });\n const place = createPlacer({\n anchor: opts.toCanvas(opts.open.client),\n ...(opts.open.under ? { under: underOnCanvas(opts.open.under, opts.toCanvas) } : {}),\n canvasSize: opts.canvasSize,\n measure: opts.measure ?? measureLabel, metrics: m,\n });\n // The hud's font is known only once it draws.\n let family: string | null = null;\n let panels: Rect[] = place(c, family);\n let disposed = false;\n let armed = false;\n let hoverPanel: number | null = null;\n c.subscribe(() => { panels = place(c, family); rev.changed(); });\n\n /** The topmost panel under (x, y), or -1. */\n const levelAt = (x: number, y: number): number => {\n for (let i = panels.length - 1; i >= 0; i--) {\n const p = panels[i]!;\n if (x >= p.x && x < p.x + p.w && y >= p.y && y < p.y + p.h) return i;\n }\n return -1;\n };\n\n const union = (): WidgetBounds => {\n const x0 = Math.min(...panels.map((p) => p.x));\n const y0 = Math.min(...panels.map((p) => p.y));\n const x1 = Math.max(...panels.map((p) => p.x + p.w));\n const y1 = Math.max(...panels.map((p) => p.y + p.h));\n return { x: x0, y: y0, w: x1 - x0, h: y1 - y0 };\n };\n\n /** The pointer is now over `level` (null: no panel). Leaving a panel clears\n * its row, as the DOM menu's per-panel `pointerleave` does. */\n const enter = (level: number | null) => {\n if (hoverPanel !== null && hoverPanel !== level) c.hover(hoverPanel, null);\n hoverPanel = level;\n };\n\n const pointer = (evt: HudPointerEvent) => {\n if (evt.type === 'hoverleave') { enter(null); return; }\n if (evt.type === 'cancel') { armed = false; return; }\n if (evt.type === 'down') { armed = true; return; }\n if (evt.type !== 'hovermove' && evt.type !== 'move' && evt.type !== 'up') return;\n const level = levelAt(evt.x, evt.y);\n // Only a release that follows a press here chooses: the release of the\n // right-click or long-press that opened the menu must not.\n const choose = evt.type === 'up' && armed;\n if (evt.type === 'up') armed = false;\n if (!choose) enter(level < 0 ? null : level);\n if (level < 0) return;\n const entries = c.entriesAt(level);\n const index = rowAt(entries, m, evt.y - panels[level]!.y);\n if (!choose) c.hover(level, index, { x: evt.x, y: evt.y });\n else if (index !== null) {\n c.press(level, index);\n // A number row's chips step it, since this menu has no field to type in.\n const e = entries[index];\n const dir = e?.kind === 'number' ? chipAt(panels[level]!.w, m, evt.x - panels[level]!.x) : null;\n if (e?.kind === 'number' && dir !== null) c.spin(e, dir > 0 ? 'ArrowUp' : 'ArrowDown');\n }\n };\n\n const key = (evt: HudKeyEvent): boolean => {\n if (evt.type !== 'keydown') return false;\n if (!evt.ctrlKey && !evt.metaKey && !evt.altKey) c.key(evt.key);\n // Every key belongs to the open menu, so no canvas binding fires under it.\n return true;\n };\n\n const accessibleTree: HudAccessibleTree = { read: () => accessibleMenu(c), subscribe: c.subscribe };\n\n return {\n id: `weasel-menu-${opts.open.seq}`,\n get bounds() { return union(); },\n hidden: false,\n get disposed() { return disposed; },\n claims: CLAIMS,\n focusable: true,\n focusRing: false,\n accessibleName: 'Context menu',\n accessibleTree,\n deps: (ctx) => [...rev.deps(), ctx.defaultFont, faceGeneration(), opts.icons?.getVersion()],\n draw: (ctx) => {\n family = ctx.defaultFont;\n panels = place(c, family);\n return panels.flatMap((p, level) => drawPanel(ctx, p, c.entriesAt(level), c.stack()[level] ?? null, m, opts.icons, c.numberValue));\n },\n hitTest: (x, y) => levelAt(x, y) >= 0,\n cursorAt: () => 'default',\n onPointer: pointer,\n onKey: key,\n dispose() { disposed = true; c.dispose(); },\n };\n}\n","import type { MenuHost } from '@weasel-js/core';\nimport type { Hud } from '../hud';\nimport type { Widget } from '../widget';\nimport { createMenuWidget, type MenuWidgetOptions } from './menuWidget';\n\n/** What {@link attachMenuHost} needs beyond the hud and host. */\nexport type AttachMenuHostOptions =\n Pick<MenuWidgetOptions, 'toCanvas' | 'canvasSize' | 'measure' | 'metrics' | 'icons'>;\n\n/** Draw `host`'s open menu as a widget on `hud`, focused while open. A press\n * anywhere else takes focus from it, which closes the menu, as do a wheel\n * outside it, the window losing focus and a resize. Closing any other way\n * gives focus back to the widget that held it when the menu opened. Returns a detach. */\nexport function attachMenuHost(hud: Hud, host: MenuHost, opts: AttachMenuHostOptions): () => void {\n let widget: Widget | null = null;\n let returnTo: { widget: Widget | null; visible: boolean } = { widget: null, visible: false };\n\n // Cleared before removal: removing the focused widget blurs it, and that\n // blur must not read as a press elsewhere.\n const drop = () => {\n const w = widget;\n widget = null;\n if (!w) return;\n hud.remove(w);\n if (!w.disposed) w.dispose();\n };\n\n const giveBack = () => {\n const { widget: w, visible } = returnTo;\n returnTo = { widget: null, visible: false };\n if (w) hud.focus(w, { visible });\n };\n\n const sync = () => {\n const open = host.current();\n if (!widget) returnTo = { widget: hud.focused, visible: hud.focusVisible };\n const held = widget !== null && hud.focused === widget;\n drop();\n if (!open) {\n if (held) giveBack();\n return;\n }\n const w = createMenuWidget({\n ...opts, open,\n close: () => { if (host.current() === open) host.close(); },\n onChange: () => hud.markDirty(),\n });\n widget = w;\n hud.add(w);\n // A menu that cannot take focus could never be dismissed, so it does not open.\n if (!hud.focus(w)) { drop(); host.close(); }\n };\n\n const dismiss = () => { if (widget) host.close(); };\n const wheel = (e: WheelEvent) => {\n if (!widget) return;\n const p = opts.toCanvas({ x: e.clientX, y: e.clientY });\n if (!widget.hitTest(p.x, p.y)) host.close();\n };\n\n const unsubscribe = host.subscribe(sync);\n const unfocus = hud.subscribeFocus((f) => { if (widget && f !== widget) host.close(); });\n window.addEventListener('wheel', wheel, { capture: true, passive: true });\n window.addEventListener('blur', dismiss);\n window.addEventListener('resize', dismiss);\n sync();\n return () => {\n unsubscribe();\n unfocus();\n window.removeEventListener('wheel', wheel, true);\n window.removeEventListener('blur', dismiss);\n window.removeEventListener('resize', dismiss);\n drop();\n };\n}\n","import type { View } from '@weasel-js/core';\n\n/** Says whether what a lens reads from changed between one landed frame and the next. */\nexport interface ContentWatch {\n /** The camera the lens was just drawn through. */\n drew(view: View): void;\n /** Whether the content version or the camera differs from the last time this was asked. The first ask only\n * takes its bearings, and answers `false`. */\n changed(): boolean;\n}\n\n/**\n * Watches the two things that change the pixels under an aim that holds still: the content, through `version`\n * when the lens is given one, and the camera it is drawn through. A lens redrawing itself moves neither, which is\n * what lets it read the framebuffer again on a change without that read's own redraw asking for another.\n */\nexport function createContentWatch(version: (() => number) | undefined): ContentWatch {\n let camera = '';\n let seen: { version: number | undefined; camera: string } | null = null;\n return {\n drew(view) {\n camera = `${view.x},${view.y},${view.scale.x},${view.scale.y}`;\n },\n changed() {\n const now = { version: version?.(), camera };\n const moved = seen !== null && (seen.version !== now.version || seen.camera !== now.camera);\n seen = now;\n return moved;\n },\n };\n}\n","interface Point { x: number; y: number }\n\nconst POINTER_ENDS = ['pointerup', 'pointercancel', 'lostpointercapture'] as const;\n\n/**\n * Aims a lens from the pointer moving over `input`, in CSS px relative to it. A gesture that begins where\n * `holds` answers true freezes the aim until it ends: the lens camera follows the aim, so re-aiming mid-drag\n * would move the world under the pointer. Returns a detach.\n */\nexport function followPointer(\n input: HTMLElement,\n lens: { aimAt(p: Point): void; holds(p: Point): boolean },\n): () => void {\n let holding = false;\n const local = (evt: PointerEvent): Point => {\n const r = input.getBoundingClientRect();\n return { x: evt.clientX - r.left, y: evt.clientY - r.top };\n };\n const onPointerMove = (evt: PointerEvent) => {\n if (!holding) lens.aimAt(local(evt));\n };\n const onPointerDown = (evt: PointerEvent) => {\n if (lens.holds(local(evt))) holding = true;\n };\n const onPointerEnd = () => { holding = false; };\n\n input.addEventListener('pointermove', onPointerMove);\n input.addEventListener('pointerdown', onPointerDown);\n for (const type of POINTER_ENDS) input.addEventListener(type, onPointerEnd);\n return () => {\n input.removeEventListener('pointermove', onPointerMove);\n input.removeEventListener('pointerdown', onPointerDown);\n for (const type of POINTER_ENDS) input.removeEventListener(type, onPointerEnd);\n };\n}\n","import { clamp } from '@weasel-js/geom';\n\n/**\n * Read a `rw × rh` device-pixel region of the drawing buffer centered on\n * `pointer`, returned top-down. `pointer` is in CSS px relative to `target`,\n * the rect of the buffer the canvas paints into (device px, top-left origin),\n * and the read is clamped to stay inside that rect.\n *\n * GL reports rows bottom-up; every consumer here wants top-down, so both the\n * read origin and the returned rows are flipped.\n */\nexport function readbackRegion(\n gl: WebGL2RenderingContext,\n bufferHeight: number,\n target: { x: number; y: number; width: number; height: number },\n pointer: { x: number; y: number },\n dpr: number,\n rw: number,\n rh: number,\n): ImageData {\n const cx = target.x + Math.round(pointer.x * dpr);\n const cy = target.y + Math.round(pointer.y * dpr);\n const gx = clamp(cx - Math.floor(rw / 2), target.x, target.x + Math.max(0, target.width - rw));\n const gyTop = clamp(cy - Math.floor(rh / 2), target.y, target.y + Math.max(0, target.height - rh));\n const gy = bufferHeight - gyTop - rh;\n\n const raw = new Uint8Array(rw * rh * 4);\n gl.readPixels(gx, gy, rw, rh, gl.RGBA, gl.UNSIGNED_BYTE, raw);\n\n const flipped = new Uint8ClampedArray(rw * rh * 4);\n const stride = rw * 4;\n for (let row = 0; row < rh; row++) {\n const src = (rh - 1 - row) * stride;\n flipped.set(raw.subarray(src, src + stride), row * stride);\n }\n return new ImageData(flipped, rw, rh);\n}\n","import {\n createViewportLayer, screenToWorld, viewToTransform,\n type CanvasViewHandle, type RenderLayer, type SceneCanvasApi, type View, type ViewAt,\n} from '@weasel-js/core';\nimport { releaseImageSource, type DrawCommand } from '@weasel-js/core/renderer';\nimport {\n createLoupeModel, loupeInnerView,\n type LoupeMode, type LoupeModel, type LoupeSurface,\n} from '@weasel-js/loupe';\nimport type { Hud } from '../hud';\nimport type { WindowWidget } from '../widgets/window/window';\nimport type { HudContentCtx, WidgetBounds } from '../widget';\nimport { createContentWatch } from './contentWatch';\nimport { followPointer } from './pointerAim';\nimport { readbackRegion } from './readback';\n\nexport type { LoupeMode };\n\n/** Options for `createLoupe` shared by a plain lens and an interactive one. */\nexport interface LoupeBaseOptions {\n hud: Hud;\n /** The canvas pixel mode reads back from. Supplies the GL context and the\n * drawing-buffer dimensions. */\n canvas: HTMLCanvasElement;\n /** Where the aim comes from: the element pointer events are taken from and\n * the rect client coords are measured against. Defaults to `canvas`, which\n * is right whenever the canvas is also the thing under the pointer. */\n input?: HTMLElement;\n /** The rect of `canvas` the magnified picture occupies, in its CSS px — the\n * one the aim is relative to. Pass `CanvasExtensionApi.getSurfaceRect` for\n * a pane painted into a shared canvas. Defaults to `views.getSurfaceRect`\n * when the lens is a view, and to the whole canvas otherwise. */\n region?: () => { x: number; y: number; width: number; height: number };\n requestRedraw: () => void;\n /**\n * The version of what the canvas paints, read on every landed frame: when it moves, a lens whose aim has not\n * reads the framebuffer and the color under it again. Pass `CanvasExtensionApi.getPaintedVersion`. Defaults to\n * `views.getPaintedVersion` when the lens is a view. Without one the lens follows an edit under a parked aim\n * only in vector mode, or when told through `refresh()`; a camera move it follows either way.\n */\n contentVersion?: () => number;\n mode?: LoupeMode;\n factor?: number;\n bounds?: WidgetBounds;\n title?: string;\n /** Draw the window's titlebar and close box. Default `true`. Pass `false`\n * for a bare lens; the interior then doubles as the move handle, or, for an\n * `interactive` lens, a grip strip across its top does. */\n titlebar?: boolean;\n /** Called with the hex color under the aim point whenever it changes.\n * Sampled from the framebuffer in both modes — vector content is a\n * re-render whose edge colors differ from the screen's, so reading the\n * color off it would report something the user cannot see. */\n onColorChange?: (hex: string) => void;\n /** Fired when a click inside the lens picks a color — an eyedropper on the\n * magnified surface. Where the color goes is the consumer's: the loupe\n * reports the pick and nothing else. An `interactive` lens gives its clicks\n * to the canvas, so only `pick()` reaches this. */\n onPick?: (hex: string) => void;\n /** Fired by the window's close box. The window does not hide itself —\n * whoever owns the loupe's visibility decides what closing means. */\n onClose?: () => void;\n /** Backdrop painted behind the magnified content in both modes, so the\n * outer canvas does not show through where the lens is empty. Defaults to\n * the theme's surface color. */\n background?: string;\n}\n\n/** Options for `createLoupe`. */\nexport type LoupeOptions = LoupeBaseOptions & (\n | {\n /** Layers re-rendered through the magnified inner view in vector mode. */\n source: RenderLayer<unknown>[];\n views?: undefined;\n interactive?: false;\n }\n | {\n /**\n * The canvas, as a host for views. The lens becomes a view on it: vector\n * mode paints the canvas's own stack — scene and selection chrome — and\n * the lens can take input. It magnifies the camera of whatever view is\n * under its aim: aimed over a `<CanvasView>` panel, it shows and edits\n * that panel's world at the panel's zoom times its own factor. A host\n * without `viewAt` gets the canvas's camera wherever it aims.\n */\n views: Pick<SceneCanvasApi, 'addView' | 'getSurfaceRect'> & Partial<Pick<SceneCanvasApi, 'getPaintedVersion' | 'viewAt'>>;\n /** Narrows what vector mode paints. Defaults to the canvas's stack. */\n source?: RenderLayer<unknown>[];\n /**\n * Route input inside the lens to what it shows: a press selects the node\n * magnified under the pointer, and a drag moves it by the pointer travel\n * divided by the magnification. Default `false` — the window keeps its\n * interior, and a click there picks a color.\n */\n interactive?: boolean;\n }\n);\n\nconst backdropOf = (ctx: HudContentCtx, color: string): DrawCommand => ({\n kind: 'path',\n path: { kind: 'rect', x: ctx.rect.x, y: ctx.rect.y, width: ctx.rect.w, height: ctx.rect.h },\n fill: { paint: { kind: 'solid', color } },\n});\n\n/** The id the lens's view takes on its canvas. */\nconst LENS_VIEW = 'weasel-loupe:lens';\n\n/** Where an interactive lens routes while its window is hidden: nowhere. */\nconst NO_RECT = { x: 0, y: 0, w: 0, h: 0 };\n\n/** The lens camera aimed at `aim`: magnifying the view under it, or the\n * canvas's own camera `outer` where no view is. */\nfunction lensCamera(\n aim: { x: number; y: number }, under: ViewAt | null, outer: View, rect: WidgetBounds, factor: number,\n): View {\n if (under && under.id !== null) {\n const world = {\n x: (aim.x - under.rect.x) / under.view.scale.x + under.view.x,\n y: (aim.y - under.rect.y) / under.view.scale.y + under.view.y,\n };\n return loupeInnerView(world, under.view, rect, factor);\n }\n const world = screenToWorld(aim.x, aim.y, viewToTransform(outer));\n return loupeInnerView({ x: world[0], y: world[1] }, outer, rect, factor);\n}\n\n/** Control surface for a live loupe: where it is aimed, how it magnifies,\n * what color it is over, and the window it lives in. */\nexport interface LoupeHandle {\n readonly window: WindowWidget;\n readonly mode: LoupeMode;\n readonly factor: number;\n /** Last aimed point, in screen-space CSS px relative to the canvas. */\n readonly aim: { x: number; y: number };\n /** Hex color under the aim point, read off the framebuffer on the first\n * frame to land after the aim. `null` until then, or when the GL context\n * is unavailable. */\n readonly color: string | null;\n setMode(mode: LoupeMode): void;\n setFactor(factor: number): void;\n /** Aim at a screen point. Ignored while the point is over the window —\n * that is the freeze rule that makes the borders reachable. */\n aimAt(p: { x: number; y: number }): void;\n /** Sample the color the lens is showing at `p` — a screen point inside the\n * lens — and report it to `onPick`. Omit `p` to pick at the aim point.\n * Returns the hex, or `null` when the framebuffer cannot answer for that\n * point, including before any frame has landed. Leaves the aim, and\n * `color`, alone. */\n pick(p?: { x: number; y: number }): string | null;\n /** Ask for a paint, and on the frame that lands read the picture and the color under the aim again: what is\n * under the aim changed in a way no `contentVersion` reports. */\n refresh(): void;\n dispose(): void;\n}\n\n/**\n * Build a magnifier: a HUD window whose interior shows the canvas around an\n * aim point, enlarged. Adds the window to the HUD and starts following the\n * pointer; `dispose` removes it again.\n */\nexport function createLoupe(opts: LoupeOptions): LoupeHandle {\n const { hud, canvas: element, requestRedraw } = opts;\n const host = opts.views;\n const interactive = host !== undefined && opts.interactive === true;\n const input = opts.input ?? element;\n let lens: CanvasViewHandle | null = null;\n let pixels: ImageBitmap | null = null;\n const dropPixels = () => {\n if (!pixels) return;\n releaseImageSource(pixels);\n pixels.close();\n pixels = null;\n };\n let pixelsPending = false;\n let refreshWanted = false;\n let disposed = false;\n // Until a paint lands, the context on a shared canvas may not exist yet, and\n // opening it here would give every tenant one with no stencil buffer.\n let landed = false;\n\n const b = opts.bounds ?? { x: 24, y: 24, w: 220, h: 200 };\n\n const watch = createContentWatch(opts.contentVersion ?? host?.getPaintedVersion);\n let refreshAsked = false;\n\n const content = (ctx: HudContentCtx): DrawCommand[] => {\n watch.drew(ctx.view);\n return model.mode === 'vector' ? drawVector(ctx) : drawPixels(ctx);\n };\n\n const backdropColor = (ctx: HudContentCtx): string =>\n opts.background ?? ctx.tokens['--wzl-surface'];\n const backdrop = (ctx: HudContentCtx): DrawCommand => backdropOf(ctx, backdropColor(ctx));\n\n const innerView = (outer: View, rect: WidgetBounds): View => (\n lensCamera(model.aim, host?.viewAt?.(model.aim, { except: LENS_VIEW }) ?? null, outer, rect, model.factor)\n );\n\n const drawVector = (ctx: HudContentCtx): DrawCommand[] => {\n if (host) return lens ? [backdrop(ctx), ...lens.draw(ctx.data, ctx.view, ctx.dims)] : [backdrop(ctx)];\n // A fresh lens per frame: CreateViewportLayerOpts.view is static, and the\n // inner view moves with the pointer.\n const picture = createViewportLayer<unknown>({\n id: `${win.id}:lens`,\n label: 'Loupe content',\n source: opts.source ?? [],\n view: innerView(ctx.view, ctx.rect),\n bounds: () => ctx.rect,\n background: backdropColor(ctx),\n });\n return picture.draw(ctx.data, ctx.view, ctx.dims);\n };\n\n const drawPixels = (ctx: HudContentCtx): DrawCommand[] => {\n // The backdrop paints even with a bitmap in hand: a readback of a\n // transparent framebuffer is transparent, and before the first one\n // settles there is nothing at all, either of which leaves the lens a\n // hole onto the unmagnified canvas.\n const out: DrawCommand[] = [backdrop(ctx)];\n if (pixels) {\n out.push({\n kind: 'image',\n image: pixels,\n x: ctx.rect.x, y: ctx.rect.y, w: ctx.rect.w, h: ctx.rect.h,\n sampling: 'nearest',\n });\n }\n return out;\n };\n\n // `gl.readPixels` outside a landed paint returns the *previous* frame, so an\n // aim only marks the lens dirty; the read itself happens in the frame\n // subscriber below, on the frame that painted.\n const scheduleRefresh = () => {\n if (disposed || model.mode !== 'pixel') return;\n refreshWanted = true;\n };\n\n /** Read device px of the loupe's region around `at`, sized for the\n * canvas's pixel ratio, or `null` when the framebuffer cannot answer. */\n const read = (\n at: { x: number; y: number },\n rw: (dpr: number) => number,\n rh: (dpr: number) => number,\n ): ImageData | null => {\n if (!landed) return null;\n const gl = element.getContext('webgl2');\n if (!gl) return null;\n const cssRect = element.getBoundingClientRect();\n if (cssRect.width === 0) return null;\n const dpr = element.width / cssRect.width;\n // A view-backed lens knows its canvas, so over a detached pane it reads\n // that pane's pixels without being told where the pane is.\n const r = (opts.region ?? host?.getSurfaceRect)?.();\n const target = r\n ? {\n x: Math.round(r.x * dpr), y: Math.round(r.y * dpr),\n width: Math.round(r.width * dpr), height: Math.round(r.height * dpr),\n }\n : { x: 0, y: 0, width: element.width, height: element.height };\n return readbackRegion(gl, element.height, target, at, dpr, rw(dpr), rh(dpr));\n };\n\n const refreshPixels = () => {\n if (disposed || model.mode !== 'pixel') return;\n const rect = win.contentRect;\n const data = read(\n model.aim,\n (dpr) => Math.max(1, Math.round((rect.w * dpr) / model.factor)),\n (dpr) => Math.max(1, Math.round((rect.h * dpr) / model.factor)),\n );\n if (!data) return;\n pixelsPending = true;\n createImageBitmap(data)\n .then((bmp) => {\n if (disposed) { bmp.close(); return; }\n dropPixels();\n pixels = bmp;\n pixelsPending = false;\n requestRedraw();\n })\n .catch(() => {\n pixelsPending = false;\n requestRedraw();\n });\n };\n\n const readHex = (at: { x: number; y: number }): string | null => {\n const px = read(at, () => 1, () => 1);\n if (!px || px.data[3] === 0) return null;\n return '#' + [px.data[0], px.data[1], px.data[2]]\n .map((c) => c.toString(16).padStart(2, '0')).join('');\n };\n\n const win = hud.window({\n id: 'weasel-loupe',\n x: b.x, y: b.y, w: b.w, h: b.h,\n title: opts.title ?? 'Loupe',\n titlebar: opts.titlebar,\n content,\n interior: interactive ? 'pass' : 'claim',\n onResize: () => { scheduleRefresh(); },\n ...(interactive ? {} : { onContentClick: (p: { x: number; y: number }) => { model.pick(p); } }),\n ...(opts.onClose ? { onClose: opts.onClose } : {}),\n });\n\n const surface: LoupeSurface = {\n lens: () => win.contentRect,\n covers: (p) => win.hitTest(p.x, p.y) || (win.passes?.(p.x, p.y) ?? false),\n sample: readHex,\n hidden: () => win.hidden,\n gone: () => win.disposed === true,\n changed: () => { scheduleRefresh(); requestRedraw(); },\n subscribeFrame: hud.subscribeFrame,\n };\n\n // Subscribed ahead of the model, so the frame that lands first is already\n // readable by the time the model samples on it.\n const unsubscribeFrame = hud.subscribeFrame(() => {\n landed = true;\n if (watch.changed() || refreshAsked) {\n refreshAsked = false;\n scheduleRefresh();\n model.resample();\n }\n // A refresh wanted while a bitmap is in flight is remembered rather than\n // dropped: the flag survives until a frame finds it settled, so the aim\n // the user ends a fast drag on is the one that gets read.\n if (!refreshWanted || pixelsPending) return;\n refreshWanted = false;\n refreshPixels();\n });\n\n const model: LoupeModel = createLoupeModel({\n surface,\n ...(opts.mode ? { mode: opts.mode } : {}),\n ...(opts.factor !== undefined ? { factor: opts.factor } : {}),\n ...(opts.onColorChange ? { onColorChange: opts.onColorChange } : {}),\n ...(opts.onPick ? { onPick: opts.onPick } : {}),\n onDispose: () => teardown(),\n });\n\n if (host) {\n lens = host.addView({\n id: LENS_VIEW,\n label: 'Loupe',\n bounds: () => (win.hidden ? NO_RECT : win.contentRect),\n view: (outer) => innerView(outer, win.contentRect),\n paint: false,\n interactive,\n ...(opts.source ? { layers: () => opts.source! } : {}),\n });\n }\n\n const unfollow = followPointer(input, {\n aimAt: (p) => model.aimAt(p),\n holds: (p) => interactive && surface.covers(p),\n });\n\n const teardown = () => {\n disposed = true;\n unsubscribeFrame();\n unfollow();\n lens?.remove();\n lens = null;\n dropPixels();\n };\n\n return {\n window: win,\n get mode() { return model.mode; },\n get factor() { return model.factor; },\n get aim() { return model.aim; },\n get color() { return model.color; },\n setMode: model.setMode,\n setFactor: model.setFactor,\n aimAt: model.aimAt,\n pick: model.pick,\n refresh() {\n if (disposed) return;\n refreshAsked = true;\n requestRedraw();\n },\n dispose() {\n model.dispose();\n win.dispose();\n },\n };\n}\n"],"mappings":";;;;;;;;;;;AAIA,SAASkB,GAAQ,GAAmB,GAAyB;CAG3D,OAFIC,EAAE,SAAS,WAAiB,GAAGA,EAAE,MAAM,IAAIC,GAAeC,EAAE,YAAYF,CAAC,GAAGA,CAAC,MAC7EA,EAAE,SAAS,UAAgB,GAAGA,EAAE,MAAM,IAAIA,EAAE,SAAS,QAClDA,EAAE;AACX;AAGA,SAASG,EAAM,GAAmB,GAAiC;CACjE,IAAMC,IAAQF,EAAE,MAAM,GAChBG,IAAUC,MAAOF,EAAM,SAAS;CACtC,OAAOF,EAAE,UAAUI,CAAE,CAAC,CAAC,KAAK,GAAG,MAAyB;EACtD,IAAIN,EAAE,SAAS,aAAa,OAAO;GAAE,MAAM;GAAa,KAAKA,EAAE;EAAI;EACnE,IAAMO,IAAYP,EAAE,SAAS,UAAUA,EAAE,YAAY,KAAA,GAC/CQ,IAAOR,EAAE,SAAS,aAAaI,EAAME,OAAQG,KAAKL,EAAM,SAASE,IAAK;EAC5E,OAAO;GACL,MAAMC,IAAY,qBAAqB;GACvC,KAAKP,EAAE;G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AEKqQ,UAAiB;EAMrB,AALA,IAAW,IACXF,EAAiB,GACjBG,EAAS,GACT5D,GAAM,OAAO,GACb,IAAO,MACP+B,EAAW;CACb;CAEA,OAAO;EACL,QAAQe;EACR,IAAI,OAAO;GAAE,OAAOP,EAAM;EAAM;EAChC,IAAI,SAAS;GAAE,OAAOA,EAAM;EAAQ;EACpC,IAAI,MAAM;GAAE,OAAOA,EAAM;EAAK;EAC9B,IAAI,QAAQ;GAAE,OAAOA,EAAM;EAAO;EAClC,SAASA,EAAM;EACf,WAAWA,EAAM;EACjB,OAAOA,EAAM;EACb,MAAMA,EAAM;EACZ,UAAU;GACR,AAAIlF,MACJ,IAAe,IACfgG,EAAc;EAChB;EACA,UAAU;GAER,AADAd,EAAM,QAAQ,GACdO,EAAI,QAAQ;EACd;CACF;AACF"}
1
+ {"version":3,"file":"index.js","names":["solid","pathFromD","pathFromD","solid","loupeInnerView","registerDefaultFont","cursorForZone","createRevision","isFocusable","DEFAULT_WIDGET_CLAIMS","createHudContribution","createHud","attachHud","DEFAULT_WINDOW_METRICS","HUD_AFFORDANCE_KIND","claimsOf","pathFromD$1","loupeInnerView$1","labelOf","e","menuNumberText","c","level","stack","deepest","at","checkable","open","i","accessibleMenu","BLUR_LAYERS","BLUR_LAYER_ALPHA","solid$2","roundRectD","k","r","w","h","x","y","outer","rect","b","roundRectPath","s","radius","p","color","children","step","inset","margin","hole","ring","boxShadowCommands","under","over","innerRadius","padding","layers","resolveCurrentColor","current","ROOT","INHERITED","tags","m","body","attrs","a","num","v","d","nums","transformOf","identity","fn","args","next","translate","scale","rotateAboutPoint","multiply","arcRectD","rx","ry","ellipseD","cx","cy","shapeD","name","pts","paintOf","shapeCommands","out","fill","cmd","path","alpha","stroke","dash","frameFor","parent","t","group","mat3","glyphCommands","root","skipping","glyph","top","f","cmds","numberChips","end","panelW","chipAt","inside","plus","minus","valueRowWidth","measure","solid$1","mark","pathFromD","numberCommands","cell","live","ink","low","value","menuNumberCanStep","high","textCommandFromRuns","textCommands","colorCommands","DEFAULT_MENU_METRICS","rowLayout","entries","row","shortcutOf","formatShortcut","panelSize","last","text","chip","solid","caret","check","ICON_SIZE","PANEL_SHADOW","drawPanel","ctx","fg","muted","tokenPx","font","shadow","parseBoxShadow","expandVars","rows","highlight","iconX","iconY","ref","toIconRef","icons","shown","rowAt","estimateWidth","fontSize","measureLabel","metrics","metricsOf","resolveFontVariant","fontFamily","units","prev","ch","cp","createPlacer","placed","measured","faces","faceGeneration","opts","bounds","width","height","kept","parentRow","old","size","placeMenuUnder","placeMenu","placeSubmenu","CLAIMS","underOnCanvas","toCanvas","createMenuWidget","rev","createMenuController","withLinks","href","place","family","panels","disposed","armed","hoverPanel","levelAt","union","x0","y0","x1","y1","enter","pointer","evt","choose","index","dir","key","accessibleTree","attachMenuHost","widget","returnTo","drop","hud","giveBack","sync","host","held","dismiss","wheel","unsubscribe","unfocus","createContentWatch","camera","seen","view","now","version","moved","POINTER_ENDS","followPointer","holding","local","input","onPointerMove","lens","onPointerDown","onPointerEnd","type","readbackRegion","target","dpr","gx","clamp","rw","gy","bufferHeight","rh","raw","gl","flipped","stride","src","backdropOf","LENS_VIEW","NO_RECT","lensCamera","world","aim","factor","screenToWorld","viewToTransform","createLoupe","element","interactive","pixels","dropPixels","releaseImageSource","pixelsPending","refreshWanted","landed","watch","refreshAsked","content","model","drawVector","drawPixels","backdropColor","backdrop","innerView","createViewportLayer","win","scheduleRefresh","read","cssRect","refreshPixels","data","bmp","requestRedraw","readHex","px","surface","unsubscribeFrame","createLoupeModel","teardown","unfollow","DEFAULT_FONT_FAMILY","loupeInnerView"],"sources":["../src/menu/accessibleMenu.ts","../src/boxShadow.ts","../src/glyph.ts","../src/menu/valueRows.ts","../src/menu/drawPanel.ts","../src/menu/measureLabel.ts","../src/menu/placePanels.ts","../src/menu/menuWidget.ts","../src/menu/attachMenuHost.ts","../src/loupe/contentWatch.ts","../src/loupe/pointerAim.ts","../src/loupe/readback.ts","../src/loupe/createLoupe.ts"],"sourcesContent":["import { menuNumberText, type MenuController, type MenuRowEntry } from '@weasel-js/menu';\nimport type { HudAccessibleNode } from '../widget';\n\n/** A row's name: a value row's label and the value it holds now. */\nfunction labelOf(c: MenuController, e: MenuRowEntry): string {\n if (e.kind === 'number') return `${e.label}: ${menuNumberText(c.numberValue(e), e)}`;\n if (e.kind === 'color') return `${e.label}: ${e.value ?? '—'}`;\n if (e.kind === 'text') return `${e.label}: ${c.textValue(e) ?? '—'}`;\n return e.label;\n}\n\n/** One level's rows, with the open submenu nested under the row it hangs from. */\nfunction level(c: MenuController, at: number): HudAccessibleNode[] {\n const stack = c.stack();\n const deepest = at === stack.length - 1;\n return c.entriesAt(at).map((e, i): HudAccessibleNode => {\n if (e.kind === 'separator') return { role: 'separator', key: e.key };\n const checkable = e.kind === 'item' && e.checked !== undefined;\n const open = e.kind === 'submenu' && stack[at] === i && stack.length > at + 1;\n return {\n role: checkable ? 'menuitemcheckbox' : 'menuitem',\n key: e.key,\n label: labelOf(c, e),\n ...(deepest && stack[at] === i ? { active: true } : {}),\n ...(e.kind === 'item' && e.checked !== undefined ? { checked: e.checked } : {}),\n ...(e.disabled || e.kind === 'color' || e.kind === 'text' ? { disabled: true } : {}),\n ...(e.kind === 'submenu' ? { expanded: open } : {}),\n ...(open ? { children: [{ role: 'menu', key: 'menu', label: e.label, children: level(c, at + 1) }] } : {}),\n };\n });\n}\n\n/** An open menu as the accessibility tree a DOM menu's panels show: rows with their roles and states, and the\n * highlighted row of the innermost open level active. */\nexport function accessibleMenu(c: MenuController): HudAccessibleNode {\n return { role: 'menu', key: 'menu', label: 'Context menu', children: level(c, 0) };\n}\n","import type { DrawCommand } from '@weasel-js/core/renderer';\nimport { pathFromD, roundRectPath, type Path } from '@weasel-js/geom';\nimport { resolveCurrentColor, type BoxShadow } from '@weasel-js/theme';\nimport type { WidgetBounds } from './widget';\n\n// A blurred layer is drawn as nested rounded rects reaching blur / 2 either side of its edge,\n// whose overlap builds the falloff.\nconst BLUR_LAYERS = 7;\nconst BLUR_LAYER_ALPHA = 0.16;\n\nconst solid = (color: string) => ({ paint: { kind: 'solid' as const, color } });\n\nfunction roundRectD(x: number, y: number, w: number, h: number, r: number): string {\n const k = Math.max(0, Math.min(r, w / 2, h / 2));\n if (k === 0) return `M ${x} ${y} H ${x + w} V ${y + h} H ${x} Z`;\n return `M ${x + k} ${y} H ${x + w - k} A ${k} ${k} 0 0 1 ${x + w} ${y + k} V ${y + h - k} `\n + `A ${k} ${k} 0 0 1 ${x + w - k} ${y + h} H ${x + k} A ${k} ${k} 0 0 1 ${x} ${y + h - k} `\n + `V ${y + k} A ${k} ${k} 0 0 1 ${x + k} ${y} Z`;\n}\n\nfunction outer(b: WidgetBounds, radius: number, s: BoxShadow, color: string): DrawCommand {\n const rect = (e: number): Path | null => {\n const w = b.w + e * 2;\n const h = b.h + e * 2;\n return w > 0 && h > 0 ? roundRectPath(b.x + s.x - e, b.y + s.y - e, w, h, Math.max(0, radius + e)) : null;\n };\n if (s.blur <= 0) {\n const p = rect(s.spread);\n return { kind: 'group', children: p ? [{ kind: 'path', path: p, fill: solid(color) }] : [] };\n }\n const children: DrawCommand[] = [];\n const step = s.blur / (BLUR_LAYERS - 1);\n for (let i = 0; i < BLUR_LAYERS; i++) {\n const p = rect(s.spread + s.blur / 2 - i * step);\n if (p) children.push({ kind: 'path', path: p, fill: solid(color) });\n }\n return { kind: 'group', alpha: BLUR_LAYER_ALPHA, children };\n}\n\n/** An inset layer, hard-edged whatever its blur: the box less itself moved by the offset and shrunk by the spread. */\nfunction inset(b: WidgetBounds, radius: number, s: BoxShadow, color: string): DrawCommand {\n const margin = Math.abs(s.x) + Math.abs(s.y) + Math.abs(s.spread) + 1;\n const hole = roundRectD(b.x + s.x + s.spread, b.y + s.y + s.spread, b.w - s.spread * 2, b.h - s.spread * 2,\n Math.max(0, radius - s.spread));\n const ring = pathFromD(`${roundRectD(b.x - margin, b.y - margin, b.w + margin * 2, b.h + margin * 2, 0)} ${hole}`);\n return {\n kind: 'group',\n clip: roundRectPath(b.x, b.y, b.w, b.h, radius),\n children: [{ kind: 'path', path: ring.kind === 'polygon' ? { ...ring, fillRule: 'evenodd' } : ring, fill: solid(color) }],\n };\n}\n\n/**\n * A CSS `box-shadow` list cast by a rounded box, as draw commands: `under` goes beneath the box's\n * face and `over` on top of it, for `inset` layers, which fall inside `padding` (the box less its\n * border). Layers draw last-first, so the first is topmost, as in CSS. `current` is what a layer\n * written in `currentColor` takes.\n */\nexport function boxShadowCommands(\n b: WidgetBounds, radius: number, layers: readonly BoxShadow[], current: string, padding: WidgetBounds = b,\n): { under: DrawCommand[]; over: DrawCommand[] } {\n const under: DrawCommand[] = [];\n const over: DrawCommand[] = [];\n const innerRadius = Math.max(0, radius - (padding.x - b.x));\n for (const s of [...layers].reverse()) {\n const color = resolveCurrentColor(s.color, current);\n if (s.inset) over.push(inset(padding, innerRadius, s, color));\n else under.push(outer(b, radius, s, color));\n }\n return { under, over };\n}\n","import type { DrawCommand } from '@weasel-js/core/renderer';\nimport {\n identity, mat3, multiply, pathFromD, rotateAboutPoint, scale, translate, type Affine, type Path,\n} from '@weasel-js/geom';\nimport type { IconGlyph } from '@weasel-js/icons';\n\n/** The attributes a glyph's elements inherit, as `<Icon>`'s root `<svg>` sets them. */\nconst ROOT: Readonly<Record<string, string>> = {\n fill: 'none', stroke: 'currentColor', 'stroke-width': '1.5',\n 'stroke-linecap': 'round', 'stroke-linejoin': 'round',\n};\n\nconst INHERITED = new Set([\n 'fill', 'fill-opacity', 'fill-rule', 'stroke', 'stroke-width', 'stroke-opacity',\n 'stroke-linecap', 'stroke-linejoin', 'stroke-dasharray',\n]);\n\n/** What a glyph is drawn in the place of `currentColor` with, and where. */\nexport interface GlyphPlacement {\n x: number;\n y: number;\n /** Width and height; the glyph's 20×20 viewBox scales to it. */\n size: number;\n color: string;\n}\n\ninterface Tag { close: boolean; name: string; attrs: Record<string, string>; selfClosing: boolean }\n\nfunction* tags(body: string): Generator<Tag> {\n for (const m of body.matchAll(/<(\\/?)([a-zA-Z]+)((?:\\s+[\\w:-]+=\"[^\"]*\")*)\\s*(\\/?)>/g)) {\n const attrs: Record<string, string> = {};\n for (const a of m[3]!.matchAll(/([\\w:-]+)=\"([^\"]*)\"/g)) attrs[a[1]!] = a[2]!;\n yield { close: m[1] === '/', name: m[2]!, attrs, selfClosing: m[4] === '/' };\n }\n}\n\nconst num = (v: string | undefined, d = 0) => (v === undefined || v === '' ? d : Number(v));\nconst nums = (v: string) => v.trim().split(/[\\s,]+/).filter((s) => s !== '').map(Number);\n\n/** An SVG `transform` list as one affine. */\nfunction transformOf(v: string | undefined): Affine {\n let m = identity();\n if (!v) return m;\n for (const [, fn, args] of v.matchAll(/(\\w+)\\s*\\(([^)]*)\\)/g)) {\n const a = nums(args!);\n const next: Affine | null = fn === 'translate' ? translate(a[0] ?? 0, a[1] ?? 0)\n : fn === 'scale' ? scale(a[0] ?? 1, a[1] ?? a[0] ?? 1)\n : fn === 'rotate' ? rotateAboutPoint(a[1] ?? 0, a[2] ?? 0, ((a[0] ?? 0) * Math.PI) / 180)\n : fn === 'matrix' && a.length === 6 ? (a as unknown as Affine) : null;\n if (next) m = multiply(m, next);\n }\n return m;\n}\n\nfunction arcRectD(x: number, y: number, w: number, h: number, rx: number, ry: number): string {\n if (rx <= 0 || ry <= 0) return `M ${x} ${y} H ${x + w} V ${y + h} H ${x} Z`;\n return `M ${x + rx} ${y} H ${x + w - rx} A ${rx} ${ry} 0 0 1 ${x + w} ${y + ry} V ${y + h - ry} `\n + `A ${rx} ${ry} 0 0 1 ${x + w - rx} ${y + h} H ${x + rx} A ${rx} ${ry} 0 0 1 ${x} ${y + h - ry} `\n + `V ${y + ry} A ${rx} ${ry} 0 0 1 ${x + rx} ${y} Z`;\n}\n\nconst ellipseD = (cx: number, cy: number, rx: number, ry: number) =>\n `M ${cx - rx} ${cy} A ${rx} ${ry} 0 1 0 ${cx + rx} ${cy} A ${rx} ${ry} 0 1 0 ${cx - rx} ${cy} Z`;\n\n/** A shape element's outline as path data, or undefined for an element that draws none. */\nfunction shapeD(name: string, a: Readonly<Record<string, string>>): string | undefined {\n switch (name) {\n case 'path': return a.d;\n case 'rect': {\n const w = num(a.width), h = num(a.height);\n const rx = Math.min(num(a.rx, num(a.ry)), w / 2), ry = Math.min(num(a.ry, num(a.rx)), h / 2);\n return arcRectD(num(a.x), num(a.y), w, h, rx, ry);\n }\n case 'circle': return ellipseD(num(a.cx), num(a.cy), num(a.r), num(a.r));\n case 'ellipse': return ellipseD(num(a.cx), num(a.cy), num(a.rx), num(a.ry));\n case 'line': return `M ${num(a.x1)} ${num(a.y1)} L ${num(a.x2)} ${num(a.y2)}`;\n case 'polygon':\n case 'polyline': {\n const p = nums(a.points ?? '');\n if (p.length < 4) return undefined;\n const pts = [];\n for (let i = 0; i + 1 < p.length; i += 2) pts.push(`${p[i]} ${p[i + 1]}`);\n return `M ${pts.join(' L ')}${name === 'polygon' ? ' Z' : ''}`;\n }\n default: return undefined;\n }\n}\n\nconst paintOf = (v: string | undefined, color: string): string | null =>\n (v === undefined || v === 'none' ? null : /^currentcolor$/i.test(v) ? color : v);\n\n/** One shape's commands: its fill, then its stroke, each at its own opacity. */\nfunction shapeCommands(path: Path, a: Readonly<Record<string, string>>, color: string): DrawCommand[] {\n const out: DrawCommand[] = [];\n const fill = paintOf(a.fill, color);\n if (fill) {\n const p = path.kind === 'polygon' && a['fill-rule'] === 'evenodd' ? { ...path, fillRule: 'evenodd' as const } : path;\n const cmd: DrawCommand = { kind: 'path', path: p, fill: { paint: { kind: 'solid', color: fill } } };\n const alpha = num(a['fill-opacity'], 1);\n out.push(alpha < 1 ? { kind: 'group', alpha, children: [cmd] } : cmd);\n }\n const stroke = paintOf(a.stroke, color);\n if (stroke) {\n const dash = a['stroke-dasharray'] && a['stroke-dasharray'] !== 'none' ? nums(a['stroke-dasharray']) : undefined;\n const cmd: DrawCommand = {\n kind: 'path', path,\n stroke: {\n paint: { kind: 'solid', color: stroke },\n width: num(a['stroke-width'], 1),\n cap: a['stroke-linecap'] as 'butt' | 'round' | 'square' | undefined,\n join: a['stroke-linejoin'] as 'miter' | 'round' | 'bevel' | undefined,\n ...(dash ? { dash } : {}),\n },\n };\n const alpha = num(a['stroke-opacity'], 1);\n out.push(alpha < 1 ? { kind: 'group', alpha, children: [cmd] } : cmd);\n }\n return out;\n}\n\ninterface Frame { attrs: Readonly<Record<string, string>>; children: DrawCommand[]; group: DrawCommand & { kind: 'group' } }\n\nfunction frameFor(t: Tag, parent: Readonly<Record<string, string>>): Frame {\n const attrs = { ...parent };\n for (const [k, v] of Object.entries(t.attrs)) if (INHERITED.has(k)) attrs[k] = v;\n const children: DrawCommand[] = [];\n const group: Frame['group'] = { kind: 'group', children };\n const m = transformOf(t.attrs.transform);\n if (m.some((v, i) => v !== identity()[i])) group.transform = mat3.fromAffine(m);\n // Every nested `<svg>` a glyph uses has a viewBox matching its own box, so it only clips.\n if (t.name === 'svg') {\n group.clip = { kind: 'rect', x: num(t.attrs.x), y: num(t.attrs.y), width: num(t.attrs.width), height: num(t.attrs.height) };\n }\n return { attrs, children, group };\n}\n\n/**\n * A glyph as draw commands, placed in a square and drawn in `color` wherever it says\n * `currentColor`, as `<Icon>` draws it in the DOM. Reads the elements the icon tables use — `path`,\n * `rect`, `circle`, `ellipse`, `line`, `polygon`, `polyline`, `g` and a nested `svg` — with their\n * presentation attributes and transforms. `defs` and what they hold are skipped, so a `clip-path`\n * pointing into them does not clip.\n */\nexport function glyphCommands(glyph: IconGlyph, at: GlyphPlacement): DrawCommand[] {\n const k = at.size / 20;\n const root: Frame = {\n attrs: ROOT, children: [],\n group: { kind: 'group', transform: mat3.fromAffine([k, 0, 0, k, at.x, at.y]), children: [] },\n };\n root.group.children = root.children;\n const stack: Frame[] = [root];\n let skipping = 0;\n for (const t of tags(glyph.body)) {\n const top = stack.at(-1)!;\n if (skipping > 0 || t.name === 'defs' || t.name === 'clipPath') {\n if (!t.selfClosing) skipping += t.close ? -1 : 1;\n continue;\n }\n if (t.close) {\n if ((t.name === 'g' || t.name === 'svg') && stack.length > 1) stack.pop();\n continue;\n }\n if (t.name === 'g' || t.name === 'svg') {\n const f = frameFor(t, top.attrs);\n top.children.push(f.group);\n if (!t.selfClosing) stack.push(f);\n continue;\n }\n const d = shapeD(t.name, t.attrs);\n if (d === undefined) continue;\n const f = frameFor(t, top.attrs);\n const cmds = shapeCommands(pathFromD(d), f.attrs, at.color);\n if (f.group.transform) top.children.push({ kind: 'group', transform: f.group.transform, children: cmds });\n else top.children.push(...cmds);\n }\n return [root.group];\n}\n","import type { DrawCommand } from '@weasel-js/core/renderer';\nimport { pathFromD, textCommandFromRuns } from '@weasel-js/core';\nimport { menuNumberCanStep, menuNumberText, type MenuColorEntry, type MenuEntry, type MenuNumberEntry } from '@weasel-js/menu';\nimport type { WidgetBounds } from '../widget';\nimport type { MenuMetrics } from './drawPanel';\n\n/** A span across a panel, from its left edge. */\nexport interface Span { x: number; w: number }\n\n/**\n * Where a number row's step chips and value sit, at the row's end: a minus chip, the value in a cell of fixed\n * width so a changing value moves nothing, and a plus chip. `width` is all three.\n */\nexport function numberChips(panelW: number, m: MenuMetrics): { minus: Span; value: Span; plus: Span; width: number } {\n const s = m.rowHeight;\n const end = panelW - m.padX;\n return { minus: { x: end - 4 * s, w: s }, value: { x: end - 3 * s, w: 2 * s }, plus: { x: end - s, w: s }, width: 4 * s };\n}\n\n/** Which way the chip under panel-local `x` steps a number row: 1, -1, or null off both. */\nexport function chipAt(panelW: number, m: MenuMetrics, x: number): 1 | -1 | null {\n const { minus, plus } = numberChips(panelW, m);\n const inside = (s: Span) => x >= s.x && x < s.x + s.w;\n return inside(plus) ? 1 : inside(minus) ? -1 : null;\n}\n\n/** What a value row needs past its label, for sizing the panel; undefined for any other row. */\nexport function valueRowWidth(e: MenuEntry, m: MenuMetrics, measure: (text: string, fontSize: number) => number): number | undefined {\n if (e.kind === 'number') return m.padX + numberChips(0, m).width;\n if (e.kind === 'color') return Math.max(m.rowHeight, m.padX + measure(e.value ?? '—', m.fontSize));\n if (e.kind === 'text') return m.padX + measure(e.value ?? '—', m.fontSize);\n return undefined;\n}\n\nconst solid = (color: string) => ({ paint: { kind: 'solid' as const, color } });\nconst mark = (d: string, color: string): DrawCommand => ({\n kind: 'path', path: pathFromD(d), stroke: { paint: { kind: 'solid', color }, width: 1.5, cap: 'round' },\n});\n\n/** The colors and font a value row draws in. */\nexport interface ValueInk { fg: string; muted: string; border: string; font: { fontFamily: string; fontSize: number } }\n\n/** A number row's chips and value. A chip with nowhere to step to is muted, as is all of a disabled row. */\nexport function numberCommands(\n b: WidgetBounds, r: { y: number; h: number }, e: MenuNumberEntry, value: number | undefined, m: MenuMetrics, ink: ValueInk,\n): DrawCommand[] {\n const { minus, value: cell, plus } = numberChips(b.w, m);\n const cy = b.y + r.y + r.h / 2;\n const color = (live: boolean) => (live && !e.disabled ? ink.fg : ink.muted);\n const cx = (s: Span) => b.x + s.x + s.w / 2;\n const low = value !== undefined && !menuNumberCanStep(e, value, -1);\n const high = value !== undefined && !menuNumberCanStep(e, value, 1);\n return [\n mark(`M ${cx(minus) - 4} ${cy} L ${cx(minus) + 4} ${cy}`, color(!low)),\n textCommandFromRuns(\n b.x + cell.x, b.y + r.y, [{ text: menuNumberText(value, e), fill: solid(color(true)) }],\n { ...ink.font, align: 'center' }, undefined, r.h, 'center', undefined, cell.w,\n ),\n mark(`M ${cx(plus) - 4} ${cy} L ${cx(plus) + 4} ${cy} M ${cx(plus)} ${cy - 4} L ${cx(plus)} ${cy + 4}`, color(!high)),\n ];\n}\n\n/** A text row's value at the row's end, muted: nothing in a HUD menu edits it. */\nexport function textCommands(\n b: WidgetBounds, r: { y: number; h: number }, value: string | undefined, m: MenuMetrics, ink: ValueInk,\n): DrawCommand[] {\n return [textCommandFromRuns(\n b.x + m.padX, b.y + r.y, [{ text: value ?? '—', fill: solid(ink.muted) }],\n { ...ink.font, align: 'right' }, undefined, r.h, 'center', undefined, b.w - m.padX * 2,\n )];\n}\n\n/** The swatch a color row draws in its icon column, and its hex at the row's end. */\nexport function colorCommands(\n b: WidgetBounds, r: { y: number; h: number }, e: MenuColorEntry, m: MenuMetrics, ink: ValueInk,\n): DrawCommand[] {\n const out: DrawCommand[] = [];\n if (e.value !== undefined) {\n const size = 12;\n const x = b.x + m.padX + (m.rowHeight - size) / 2;\n const y = b.y + r.y + (r.h - size) / 2;\n out.push({\n kind: 'path', path: { kind: 'rect', x, y, width: size, height: size },\n fill: solid(e.value), stroke: { paint: { kind: 'solid', color: ink.border }, width: 1 },\n });\n }\n out.push(textCommandFromRuns(\n b.x + m.padX, b.y + r.y, [{ text: e.value ?? '—', fill: solid(ink.muted) }],\n { ...ink.font, align: 'right' }, undefined, r.h, 'center', undefined, b.w - m.padX * 2,\n ));\n return out;\n}\n","import type { DrawCommand } from '@weasel-js/core/renderer';\nimport { pathFromD, textCommandFromRuns } from '@weasel-js/core';\nimport { roundRectPath } from '@weasel-js/geom';\nimport { formatShortcut } from '@weasel-js/gestures';\nimport type { MenuEntry, MenuNumberEntry } from '@weasel-js/menu';\nimport { expandVars, parseBoxShadow, resolveCurrentColor, tokenPx } from '@weasel-js/theme';\nimport { toIconRef, type IconRegistry } from '@weasel-js/icons';\nimport { boxShadowCommands } from '../boxShadow';\nimport { glyphCommands } from '../glyph';\nimport type { HudDrawCtx, WidgetBounds } from '../widget';\nimport { colorCommands, numberCommands, textCommands, valueRowWidth } from './valueRows';\n\n/** Sizes of a HUD menu panel, in CSS pixels. */\nexport interface MenuMetrics {\n rowHeight: number;\n padX: number;\n padY: number;\n separatorHeight: number;\n minWidth: number;\n fontSize: number;\n}\n\n/** The metrics a menu widget uses when given none, close to the DOM menu's. */\nexport const DEFAULT_MENU_METRICS: MenuMetrics = {\n rowHeight: 24, padX: 8, padY: 4, separatorHeight: 9, minWidth: 180, fontSize: 13,\n};\n\n/** Each entry's y offset and height inside a panel. */\nexport function rowLayout(entries: readonly MenuEntry[], m: MenuMetrics): { y: number; h: number }[] {\n let y = m.padY;\n return entries.map((e) => {\n const h = e.kind === 'separator' ? m.separatorHeight : m.rowHeight;\n const row = { y, h };\n y += h;\n return row;\n });\n}\n\n/** A row's shortcut as the DOM menu prints it, or undefined. */\nconst shortcutOf = (e: MenuEntry): string | undefined =>\n (e.kind === 'item' ? formatShortcut(e.shortcut) : undefined);\n\n/** A panel's size: its widest row — label, then a shortcut or the caret column —\n * plus the icon column, never under `minWidth`. */\nexport function panelSize(\n entries: readonly MenuEntry[], m: MenuMetrics, measure: (text: string, fontSize: number) => number,\n): { w: number; h: number } {\n const rows = rowLayout(entries, m);\n const last = rows.at(-1);\n const rowWidth = (e: MenuEntry) => {\n if (e.kind === 'separator') return 0;\n const value = valueRowWidth(e, m, measure);\n if (value !== undefined) return measure(e.label, m.fontSize) + value;\n const chip = shortcutOf(e);\n return measure(e.label, m.fontSize) + Math.max(m.rowHeight, chip ? m.padX + measure(chip, m.fontSize) : 0);\n };\n const text = Math.max(0, ...entries.map(rowWidth));\n return {\n w: Math.max(m.minWidth, Math.ceil(text) + m.padX * 2 + m.rowHeight),\n h: (last ? last.y + last.h : 0) + m.padY,\n };\n}\n\nconst solid = (color: string) => ({ paint: { kind: 'solid' as const, color } });\nconst rect = (x: number, y: number, width: number, height: number, color: string): DrawCommand => ({\n kind: 'path', path: { kind: 'rect', x, y, width, height }, fill: solid(color),\n});\n\n/** A right-pointing chevron centered on (cx, cy). The bundled atlas has no `›` glyph. */\nfunction caret(cx: number, cy: number, color: string): DrawCommand {\n const s = 3;\n return {\n kind: 'path',\n path: pathFromD(`M ${cx - s / 2} ${cy - s} L ${cx + s / 2} ${cy} L ${cx - s / 2} ${cy + s}`),\n stroke: { paint: { kind: 'solid', color }, width: 1.5, cap: 'round' },\n };\n}\n\n/** A check mark centered on (cx, cy), for a row whose action is on. */\nfunction check(cx: number, cy: number, color: string): DrawCommand {\n return {\n kind: 'path',\n path: pathFromD(`M ${cx - 4} ${cy} L ${cx - 1.5} ${cy + 2.5} L ${cx + 4} ${cy - 3}`),\n stroke: { paint: { kind: 'solid', color }, width: 1.5, cap: 'round', join: 'round' },\n };\n}\n\n/** Where a menu finds the glyph a row's `icon` names: an icon registry, or anything answering as one. */\nexport type MenuIcons = Pick<IconRegistry, 'get' | 'getVersion'>;\n\n/** The DOM row draws its icon at 16px. */\nconst ICON_SIZE = 16;\n\n// The shadow `.surface` in ui's listbox.module.css gives the DOM panel.\nconst PANEL_SHADOW = 'var(--wzl-bevel-raised, 0 8px 24px var(--wzl-shadow))';\n\n/** One panel's commands: its rounded face and the DOM panel's box shadow, a highlight behind row\n * `highlight`, and every row, with the glyph `icons` holds for each row's icon. A number row shows what\n * `shown` says it holds, by default what it opened with. */\nexport function drawPanel(\n ctx: HudDrawCtx, b: WidgetBounds, entries: readonly MenuEntry[], highlight: number | null, m: MenuMetrics,\n icons?: MenuIcons, shown: (e: MenuNumberEntry) => number | undefined = (e) => e.value,\n): DrawCommand[] {\n const t = ctx.tokens;\n const fg = t['--wzl-fg'];\n const muted = resolveCurrentColor(t['--wzl-fg-muted'], fg);\n const radius = tokenPx('--wzl-radius-md', t);\n const font = { fontFamily: ctx.defaultFont, fontSize: m.fontSize };\n const shadow = boxShadowCommands(b, radius, parseBoxShadow(expandVars(PANEL_SHADOW, t)), fg,\n { x: b.x + 1, y: b.y + 1, w: b.w - 2, h: b.h - 2 });\n const out: DrawCommand[] = [...shadow.under, {\n kind: 'path',\n path: roundRectPath(b.x, b.y, b.w, b.h, radius),\n fill: solid(t['--wzl-surface-popover']),\n stroke: { paint: { kind: 'solid', color: t['--wzl-border'] }, width: 1 },\n }, ...shadow.over];\n const rows = rowLayout(entries, m);\n entries.forEach((e, i) => {\n const r = rows[i]!;\n if (e.kind === 'separator') {\n out.push(rect(b.x + m.padX, b.y + r.y + Math.floor(r.h / 2), b.w - m.padX * 2, 1, t['--wzl-border']));\n return;\n }\n if (i === highlight) out.push(rect(b.x + 2, b.y + r.y, b.w - 4, r.h, t['--wzl-surface-hover']));\n // Nothing here edits a color or a text row, so each reads as a disabled one does.\n const color = e.disabled || e.kind === 'color' || e.kind === 'text' ? muted : fg;\n out.push(textCommandFromRuns(\n b.x + m.padX + m.rowHeight, b.y + r.y,\n [{ text: e.label, fill: solid(color) }],\n font, undefined, r.h, 'center',\n ));\n const iconX = b.x + m.padX + m.rowHeight / 2;\n const iconY = b.y + r.y + r.h / 2;\n const ref = e.kind !== 'color' && typeof e.icon === 'string' ? toIconRef(e.icon) : undefined;\n const glyph = ref ? icons?.get(ref) : undefined;\n if (e.kind === 'item' && e.checked) out.push(check(iconX, iconY, color));\n else if (glyph) out.push(...glyphCommands(glyph, { x: iconX - ICON_SIZE / 2, y: iconY - ICON_SIZE / 2, size: ICON_SIZE, color }));\n const chip = shortcutOf(e);\n if (chip) {\n out.push(textCommandFromRuns(\n b.x + m.padX, b.y + r.y, [{ text: chip, fill: solid(muted) }],\n { ...font, align: 'right' }, undefined, r.h, 'center', undefined, b.w - m.padX * 2,\n ));\n }\n const ink = { fg, muted, border: t['--wzl-border'], font };\n if (e.kind === 'number') out.push(...numberCommands(b, r, e, shown(e), m, ink));\n if (e.kind === 'color') out.push(...colorCommands(b, r, e, m, ink));\n if (e.kind === 'text') out.push(...textCommands(b, r, e.value, m, ink));\n if (e.kind === 'submenu') out.push(caret(b.x + b.w - m.padX - m.rowHeight / 2, b.y + r.y + r.h / 2, color));\n });\n return out;\n}\n\n/** Index of the entry under panel-local `y`, or null. */\nexport function rowAt(entries: readonly MenuEntry[], m: MenuMetrics, y: number): number | null {\n const i = rowLayout(entries, m).findIndex((r) => y >= r.y && y < r.y + r.h);\n return i < 0 ? null : i;\n}\n","import { metricsOf, resolveFontVariant } from '@weasel-js/font';\n\n/** A width for `text` with no face to measure it in. */\nexport function estimateWidth(text: string, fontSize: number): number {\n return text.length * fontSize * 0.55;\n}\n\n/** Width of `text` at `fontSize` in `fontFamily`, from the advances and\n * kerning of the face the text command lays it out with. A face not loaded\n * yet gives an estimate; `faceGeneration` moves when it lands. */\nexport function measureLabel(text: string, fontSize: number, fontFamily: string): number {\n const metrics = metricsOf(resolveFontVariant(fontFamily, 400, 'normal'));\n if (!metrics) return estimateWidth(text, fontSize);\n let units = 0;\n let prev: number | null = null;\n for (const ch of text) {\n const cp = ch.codePointAt(0)!;\n units += metrics.advanceOf(cp) ?? metrics.size * 0.55;\n if (prev !== null) units += metrics.kernOf(prev, cp);\n prev = cp;\n }\n return units * fontSize / metrics.size;\n}\n","import { placeMenu, placeMenuUnder, placeSubmenu, type MenuController, type MenuEntry, type Rect } from '@weasel-js/menu';\nimport { faceGeneration } from '@weasel-js/font';\nimport { panelSize, rowLayout, type MenuMetrics } from './drawPanel';\nimport { estimateWidth } from './measureLabel';\n\ntype XY = { x: number; y: number };\n\n/** What placing needs: where the menu opened, the canvas, and how to measure. */\nexport interface PlaceOptions {\n anchor: XY;\n /** The button the menu hangs from, in canvas pixels; when set, `anchor` is not used. */\n under?: Rect;\n canvasSize(): { width: number; height: number };\n measure(text: string, fontSize: number, fontFamily: string): number;\n metrics: MenuMetrics;\n}\n\ninterface Placed {\n entries: readonly MenuEntry[];\n parentRow: number | null;\n rect: Rect;\n}\n\n/**\n * Places each open level once, when it opens: a level keeps its rect for as\n * long as its entries and the parent row it hangs from stay the same. A new\n * font family, or a face landing, re-measures everything. With no family yet\n * — the hud has not drawn — widths are estimated rather than measured in a\n * guessed family.\n */\nexport function createPlacer(opts: PlaceOptions): (c: MenuController, fontFamily: string | null) => Rect[] {\n let placed: Placed[] = [];\n let measured: { family: string | null; faces: number } | null = null;\n\n return (c, fontFamily) => {\n const faces = faceGeneration();\n if (measured?.family !== fontFamily || measured.faces !== faces) {\n placed = [];\n measured = { family: fontFamily, faces };\n }\n const { width, height } = opts.canvasSize();\n const bounds = { x: 0, y: 0, w: width, h: height };\n const m = opts.metrics;\n const stack = c.stack();\n const next: Placed[] = [];\n let kept = true;\n for (let level = 0; level < stack.length; level++) {\n const entries = c.entriesAt(level);\n const parentRow = level === 0 ? null : stack[level - 1] ?? null;\n const old = placed[level];\n if (kept && old && old.entries === entries && old.parentRow === parentRow) {\n next.push(old);\n continue;\n }\n kept = false;\n const size = panelSize(entries, m, (t, s) => (fontFamily === null ? estimateWidth(t, s) : opts.measure(t, s, fontFamily)));\n let at: XY;\n if (level === 0) {\n at = opts.under ? placeMenuUnder(size, opts.under, bounds) : placeMenu(size, opts.anchor, bounds);\n } else {\n const parent = next[level - 1]!.rect;\n const row = rowLayout(c.entriesAt(level - 1), m)[parentRow!]!;\n at = placeSubmenu(size, { x: parent.x, y: parent.y + row.y, w: parent.w, h: row.h }, bounds);\n }\n const rect = { x: at.x, y: at.y, w: size.w, h: size.h };\n next.push({ entries, parentRow, rect });\n c.setPanel(level, rect);\n }\n placed = next;\n return next.map((p) => p.rect);\n };\n}\n","import { createMenuController, withLinks, type Rect } from '@weasel-js/menu';\nimport { faceGeneration } from '@weasel-js/font';\nimport type { ClaimableGesture, OpenMenu } from '@weasel-js/core';\nimport { createRevision, type HudAccessibleTree, type HudKeyEvent, type HudPointerEvent, type Widget, type WidgetBounds } from '../widget';\nimport { accessibleMenu } from './accessibleMenu';\nimport { DEFAULT_MENU_METRICS, drawPanel, rowAt, type MenuIcons, type MenuMetrics } from './drawPanel';\nimport { measureLabel } from './measureLabel';\nimport { createPlacer } from './placePanels';\nimport { chipAt } from './valueRows';\nimport type { Point } from '@weasel-js/geom';\n\nconst CLAIMS: readonly ClaimableGesture[] = ['pointer', 'doubleClick', 'contextMenu', 'longPress', 'wheel'];\n\n/** What {@link createMenuWidget} needs: the open menu, how to close it, and the canvas it draws on. */\nexport interface MenuWidgetOptions {\n open: OpenMenu;\n /** The menu is done: an item was chosen, or it was dismissed. */\n close(): void;\n /** Viewport point to canvas CSS pixels, for `open.client` and `open.under`. */\n toCanvas(client: Point): Point;\n canvasSize(): { width: number; height: number };\n /** Width of a label in the family the hud draws with. Defaults to the\n * registered face's own advances, which is what the text is laid out with. */\n measure?(text: string, fontSize: number, fontFamily: string): number;\n metrics?: MenuMetrics;\n /** Where a row's icon is looked up; without it no row draws one. */\n icons?: MenuIcons;\n onChange(): void;\n}\n\nfunction underOnCanvas(r: Rect, toCanvas: (client: Point) => Point): Rect {\n const a = toCanvas({ x: r.x, y: r.y });\n const b = toCanvas({ x: r.x + r.w, y: r.y + r.h });\n return { x: a.x, y: a.y, w: b.x - a.x, h: b.y - a.y };\n}\n\n/** A widget that draws `open` as one panel per open level, driven by a menu controller it owns. */\nexport function createMenuWidget(opts: MenuWidgetOptions): Widget {\n const m = opts.metrics ?? DEFAULT_MENU_METRICS;\n const rev = createRevision(opts.onChange);\n const c = createMenuController({\n entries: withLinks(opts.open.entries, (href) => window.location.assign(href)),\n highlightFirst: opts.open.source === 'keyboard', onClose: opts.close,\n });\n const place = createPlacer({\n anchor: opts.toCanvas(opts.open.client),\n ...(opts.open.under ? { under: underOnCanvas(opts.open.under, opts.toCanvas) } : {}),\n canvasSize: opts.canvasSize,\n measure: opts.measure ?? measureLabel, metrics: m,\n });\n // The hud's font is known only once it draws.\n let family: string | null = null;\n let panels: Rect[] = place(c, family);\n let disposed = false;\n let armed = false;\n let hoverPanel: number | null = null;\n c.subscribe(() => { panels = place(c, family); rev.changed(); });\n\n /** The topmost panel under (x, y), or -1. */\n const levelAt = (x: number, y: number): number => {\n for (let i = panels.length - 1; i >= 0; i--) {\n const p = panels[i]!;\n if (x >= p.x && x < p.x + p.w && y >= p.y && y < p.y + p.h) return i;\n }\n return -1;\n };\n\n const union = (): WidgetBounds => {\n const x0 = Math.min(...panels.map((p) => p.x));\n const y0 = Math.min(...panels.map((p) => p.y));\n const x1 = Math.max(...panels.map((p) => p.x + p.w));\n const y1 = Math.max(...panels.map((p) => p.y + p.h));\n return { x: x0, y: y0, w: x1 - x0, h: y1 - y0 };\n };\n\n /** The pointer is now over `level` (null: no panel). Leaving a panel clears\n * its row, as the DOM menu's per-panel `pointerleave` does. */\n const enter = (level: number | null) => {\n if (hoverPanel !== null && hoverPanel !== level) c.hover(hoverPanel, null);\n hoverPanel = level;\n };\n\n const pointer = (evt: HudPointerEvent) => {\n if (evt.type === 'hoverleave') { enter(null); return; }\n if (evt.type === 'cancel') { armed = false; return; }\n if (evt.type === 'down') { armed = true; return; }\n if (evt.type !== 'hovermove' && evt.type !== 'move' && evt.type !== 'up') return;\n const level = levelAt(evt.x, evt.y);\n // Only a release that follows a press here chooses: the release of the\n // right-click or long-press that opened the menu must not.\n const choose = evt.type === 'up' && armed;\n if (evt.type === 'up') armed = false;\n if (!choose) enter(level < 0 ? null : level);\n if (level < 0) return;\n const entries = c.entriesAt(level);\n const index = rowAt(entries, m, evt.y - panels[level]!.y);\n if (!choose) c.hover(level, index, { x: evt.x, y: evt.y });\n else if (index !== null) {\n c.press(level, index);\n // A number row's chips step it, since this menu has no field to type in.\n const e = entries[index];\n const dir = e?.kind === 'number' ? chipAt(panels[level]!.w, m, evt.x - panels[level]!.x) : null;\n if (e?.kind === 'number' && dir !== null) c.spin(e, dir > 0 ? 'ArrowUp' : 'ArrowDown');\n }\n };\n\n const key = (evt: HudKeyEvent): boolean => {\n if (evt.type !== 'keydown') return false;\n if (!evt.ctrlKey && !evt.metaKey && !evt.altKey) c.key(evt.key);\n // Every key belongs to the open menu, so no canvas binding fires under it.\n return true;\n };\n\n const accessibleTree: HudAccessibleTree = { read: () => accessibleMenu(c), subscribe: c.subscribe };\n\n return {\n id: `weasel-menu-${opts.open.seq}`,\n get bounds() { return union(); },\n hidden: false,\n get disposed() { return disposed; },\n claims: CLAIMS,\n focusable: true,\n focusRing: false,\n accessibleName: 'Context menu',\n accessibleTree,\n deps: (ctx) => [...rev.deps(), ctx.defaultFont, faceGeneration(), opts.icons?.getVersion()],\n draw: (ctx) => {\n family = ctx.defaultFont;\n panels = place(c, family);\n return panels.flatMap((p, level) => drawPanel(ctx, p, c.entriesAt(level), c.stack()[level] ?? null, m, opts.icons, c.numberValue));\n },\n hitTest: (x, y) => levelAt(x, y) >= 0,\n cursorAt: () => 'default',\n onPointer: pointer,\n onKey: key,\n dispose() { disposed = true; c.dispose(); },\n };\n}\n","import type { MenuHost } from '@weasel-js/core';\nimport type { Hud } from '../hud';\nimport type { Widget } from '../widget';\nimport { createMenuWidget, type MenuWidgetOptions } from './menuWidget';\n\n/** What {@link attachMenuHost} needs beyond the hud and host. */\nexport type AttachMenuHostOptions =\n Pick<MenuWidgetOptions, 'toCanvas' | 'canvasSize' | 'measure' | 'metrics' | 'icons'>;\n\n/** Draw `host`'s open menu as a widget on `hud`, focused while open. A press\n * anywhere else takes focus from it, which closes the menu, as do a wheel\n * outside it, the window losing focus and a resize. Closing any other way\n * gives focus back to the widget that held it when the menu opened. Returns a detach. */\nexport function attachMenuHost(hud: Hud, host: MenuHost, opts: AttachMenuHostOptions): () => void {\n let widget: Widget | null = null;\n let returnTo: { widget: Widget | null; visible: boolean } = { widget: null, visible: false };\n\n // Cleared before removal: removing the focused widget blurs it, and that\n // blur must not read as a press elsewhere.\n const drop = () => {\n const w = widget;\n widget = null;\n if (!w) return;\n hud.remove(w);\n if (!w.disposed) w.dispose();\n };\n\n const giveBack = () => {\n const { widget: w, visible } = returnTo;\n returnTo = { widget: null, visible: false };\n if (w) hud.focus(w, { visible });\n };\n\n const sync = () => {\n const open = host.current();\n if (!widget) returnTo = { widget: hud.focused, visible: hud.focusVisible };\n const held = widget !== null && hud.focused === widget;\n drop();\n if (!open) {\n if (held) giveBack();\n return;\n }\n const w = createMenuWidget({\n ...opts, open,\n close: () => { if (host.current() === open) host.close(); },\n onChange: () => hud.markDirty(),\n });\n widget = w;\n hud.add(w);\n // A menu that cannot take focus could never be dismissed, so it does not open.\n if (!hud.focus(w)) { drop(); host.close(); }\n };\n\n const dismiss = () => { if (widget) host.close(); };\n const wheel = (e: WheelEvent) => {\n if (!widget) return;\n const p = opts.toCanvas({ x: e.clientX, y: e.clientY });\n if (!widget.hitTest(p.x, p.y)) host.close();\n };\n\n const unsubscribe = host.subscribe(sync);\n const unfocus = hud.subscribeFocus((f) => { if (widget && f !== widget) host.close(); });\n window.addEventListener('wheel', wheel, { capture: true, passive: true });\n window.addEventListener('blur', dismiss);\n window.addEventListener('resize', dismiss);\n sync();\n return () => {\n unsubscribe();\n unfocus();\n window.removeEventListener('wheel', wheel, true);\n window.removeEventListener('blur', dismiss);\n window.removeEventListener('resize', dismiss);\n drop();\n };\n}\n","import type { View } from '@weasel-js/core';\n\n/** Says whether what a lens reads from changed between one landed frame and the next. */\nexport interface ContentWatch {\n /** The camera the lens was just drawn through. */\n drew(view: View): void;\n /** Whether the content version or the camera differs from the last time this was asked. The first ask only\n * takes its bearings, and answers `false`. */\n changed(): boolean;\n}\n\n/**\n * Watches the two things that change the pixels under an aim that holds still: the content, through `version`\n * when the lens is given one, and the camera it is drawn through. A lens redrawing itself moves neither, which is\n * what lets it read the framebuffer again on a change without that read's own redraw asking for another.\n */\nexport function createContentWatch(version: (() => number) | undefined): ContentWatch {\n let camera = '';\n let seen: { version: number | undefined; camera: string } | null = null;\n return {\n drew(view) {\n camera = `${view.x},${view.y},${view.scale.x},${view.scale.y}`;\n },\n changed() {\n const now = { version: version?.(), camera };\n const moved = seen !== null && (seen.version !== now.version || seen.camera !== now.camera);\n seen = now;\n return moved;\n },\n };\n}\n","interface Point { x: number; y: number }\n\nconst POINTER_ENDS = ['pointerup', 'pointercancel', 'lostpointercapture'] as const;\n\n/**\n * Aims a lens from the pointer moving over `input`, in CSS px relative to it. A gesture that begins where\n * `holds` answers true freezes the aim until it ends: the lens camera follows the aim, so re-aiming mid-drag\n * would move the world under the pointer. Returns a detach.\n */\nexport function followPointer(\n input: HTMLElement,\n lens: { aimAt(p: Point): void; holds(p: Point): boolean },\n): () => void {\n let holding = false;\n const local = (evt: PointerEvent): Point => {\n const r = input.getBoundingClientRect();\n return { x: evt.clientX - r.left, y: evt.clientY - r.top };\n };\n const onPointerMove = (evt: PointerEvent) => {\n if (!holding) lens.aimAt(local(evt));\n };\n const onPointerDown = (evt: PointerEvent) => {\n if (lens.holds(local(evt))) holding = true;\n };\n const onPointerEnd = () => { holding = false; };\n\n input.addEventListener('pointermove', onPointerMove);\n input.addEventListener('pointerdown', onPointerDown);\n for (const type of POINTER_ENDS) input.addEventListener(type, onPointerEnd);\n return () => {\n input.removeEventListener('pointermove', onPointerMove);\n input.removeEventListener('pointerdown', onPointerDown);\n for (const type of POINTER_ENDS) input.removeEventListener(type, onPointerEnd);\n };\n}\n","import { clamp } from '@weasel-js/geom';\n\n/**\n * Read a `rw × rh` device-pixel region of the drawing buffer centered on\n * `pointer`, returned top-down. `pointer` is in CSS px relative to `target`,\n * the rect of the buffer the canvas paints into (device px, top-left origin),\n * and the read is clamped to stay inside that rect.\n *\n * GL reports rows bottom-up; every consumer here wants top-down, so both the\n * read origin and the returned rows are flipped.\n */\nexport function readbackRegion(\n gl: WebGL2RenderingContext,\n bufferHeight: number,\n target: { x: number; y: number; width: number; height: number },\n pointer: { x: number; y: number },\n dpr: number,\n rw: number,\n rh: number,\n): ImageData {\n const cx = target.x + Math.round(pointer.x * dpr);\n const cy = target.y + Math.round(pointer.y * dpr);\n const gx = clamp(cx - Math.floor(rw / 2), target.x, target.x + Math.max(0, target.width - rw));\n const gyTop = clamp(cy - Math.floor(rh / 2), target.y, target.y + Math.max(0, target.height - rh));\n const gy = bufferHeight - gyTop - rh;\n\n const raw = new Uint8Array(rw * rh * 4);\n gl.readPixels(gx, gy, rw, rh, gl.RGBA, gl.UNSIGNED_BYTE, raw);\n\n const flipped = new Uint8ClampedArray(rw * rh * 4);\n const stride = rw * 4;\n for (let row = 0; row < rh; row++) {\n const src = (rh - 1 - row) * stride;\n flipped.set(raw.subarray(src, src + stride), row * stride);\n }\n return new ImageData(flipped, rw, rh);\n}\n","import {\n createViewportLayer, screenToWorld, viewToTransform,\n type CanvasViewHandle, type RenderLayer, type SceneCanvasApi, type View, type ViewAt,\n} from '@weasel-js/core';\nimport { releaseImageSource, type DrawCommand } from '@weasel-js/core/renderer';\nimport {\n createLoupeModel, loupeInnerView,\n type LoupeMode, type LoupeModel, type LoupeSurface,\n} from '@weasel-js/loupe';\nimport type { Hud } from '../hud';\nimport type { WindowWidget } from '../widgets/window/window';\nimport type { HudContentCtx, WidgetBounds } from '../widget';\nimport { createContentWatch } from './contentWatch';\nimport { followPointer } from './pointerAim';\nimport { readbackRegion } from './readback';\n\nexport type { LoupeMode };\n\n/** Options for `createLoupe` shared by a plain lens and an interactive one. */\nexport interface LoupeBaseOptions {\n hud: Hud;\n /** The canvas pixel mode reads back from. Supplies the GL context and the\n * drawing-buffer dimensions. */\n canvas: HTMLCanvasElement;\n /** Where the aim comes from: the element pointer events are taken from and\n * the rect client coords are measured against. Defaults to `canvas`, which\n * is right whenever the canvas is also the thing under the pointer. */\n input?: HTMLElement;\n /** The rect of `canvas` the magnified picture occupies, in its CSS px — the\n * one the aim is relative to. Pass `CanvasExtensionApi.getSurfaceRect` for\n * a pane painted into a shared canvas. Defaults to `views.getSurfaceRect`\n * when the lens is a view, and to the whole canvas otherwise. */\n region?: () => { x: number; y: number; width: number; height: number };\n requestRedraw: () => void;\n /**\n * The version of what the canvas paints, read on every landed frame: when it moves, a lens whose aim has not\n * reads the framebuffer and the color under it again. Pass `CanvasExtensionApi.getPaintedVersion`. Defaults to\n * `views.getPaintedVersion` when the lens is a view. Without one the lens follows an edit under a parked aim\n * only in vector mode, or when told through `refresh()`; a camera move it follows either way.\n */\n contentVersion?: () => number;\n mode?: LoupeMode;\n factor?: number;\n bounds?: WidgetBounds;\n title?: string;\n /** Draw the window's titlebar and close box. Default `true`. Pass `false`\n * for a bare lens; the interior then doubles as the move handle, or, for an\n * `interactive` lens, a grip strip across its top does. */\n titlebar?: boolean;\n /** Called with the hex color under the aim point whenever it changes.\n * Sampled from the framebuffer in both modes — vector content is a\n * re-render whose edge colors differ from the screen's, so reading the\n * color off it would report something the user cannot see. */\n onColorChange?: (hex: string) => void;\n /** Fired when a click inside the lens picks a color — an eyedropper on the\n * magnified surface. Where the color goes is the consumer's: the loupe\n * reports the pick and nothing else. An `interactive` lens gives its clicks\n * to the canvas, so only `pick()` reaches this. */\n onPick?: (hex: string) => void;\n /** Fired by the window's close box. The window does not hide itself —\n * whoever owns the loupe's visibility decides what closing means. */\n onClose?: () => void;\n /** Backdrop painted behind the magnified content in both modes, so the\n * outer canvas does not show through where the lens is empty. Defaults to\n * the theme's surface color. */\n background?: string;\n}\n\n/** Options for `createLoupe`. */\nexport type LoupeOptions = LoupeBaseOptions & (\n | {\n /** Layers re-rendered through the magnified inner view in vector mode. */\n source: RenderLayer<unknown>[];\n views?: undefined;\n interactive?: false;\n }\n | {\n /**\n * The canvas, as a host for views. The lens becomes a view on it: vector\n * mode paints the canvas's own stack — scene and selection chrome — and\n * the lens can take input. It magnifies the camera of whatever view is\n * under its aim: aimed over a `<CanvasView>` panel, it shows and edits\n * that panel's world at the panel's zoom times its own factor. A host\n * without `viewAt` gets the canvas's camera wherever it aims.\n */\n views: Pick<SceneCanvasApi, 'addView' | 'getSurfaceRect'> & Partial<Pick<SceneCanvasApi, 'getPaintedVersion' | 'viewAt'>>;\n /** Narrows what vector mode paints. Defaults to the canvas's stack. */\n source?: RenderLayer<unknown>[];\n /**\n * Route input inside the lens to what it shows: a press selects the node\n * magnified under the pointer, and a drag moves it by the pointer travel\n * divided by the magnification. Default `false` — the window keeps its\n * interior, and a click there picks a color.\n */\n interactive?: boolean;\n }\n);\n\nconst backdropOf = (ctx: HudContentCtx, color: string): DrawCommand => ({\n kind: 'path',\n path: { kind: 'rect', x: ctx.rect.x, y: ctx.rect.y, width: ctx.rect.w, height: ctx.rect.h },\n fill: { paint: { kind: 'solid', color } },\n});\n\n/** The id the lens's view takes on its canvas. */\nconst LENS_VIEW = 'weasel-loupe:lens';\n\n/** Where an interactive lens routes while its window is hidden: nowhere. */\nconst NO_RECT = { x: 0, y: 0, w: 0, h: 0 };\n\n/** The lens camera aimed at `aim`: magnifying the view under it, or the\n * canvas's own camera `outer` where no view is. */\nfunction lensCamera(\n aim: { x: number; y: number }, under: ViewAt | null, outer: View, rect: WidgetBounds, factor: number,\n): View {\n if (under && under.id !== null) {\n const world = {\n x: (aim.x - under.rect.x) / under.view.scale.x + under.view.x,\n y: (aim.y - under.rect.y) / under.view.scale.y + under.view.y,\n };\n return loupeInnerView(world, under.view, rect, factor);\n }\n const world = screenToWorld(aim.x, aim.y, viewToTransform(outer));\n return loupeInnerView({ x: world[0], y: world[1] }, outer, rect, factor);\n}\n\n/** Control surface for a live loupe: where it is aimed, how it magnifies,\n * what color it is over, and the window it lives in. */\nexport interface LoupeHandle {\n readonly window: WindowWidget;\n readonly mode: LoupeMode;\n readonly factor: number;\n /** Last aimed point, in screen-space CSS px relative to the canvas. */\n readonly aim: { x: number; y: number };\n /** Hex color under the aim point, read off the framebuffer on the first\n * frame to land after the aim. `null` until then, or when the GL context\n * is unavailable. */\n readonly color: string | null;\n setMode(mode: LoupeMode): void;\n setFactor(factor: number): void;\n /** Aim at a screen point. Ignored while the point is over the window —\n * that is the freeze rule that makes the borders reachable. */\n aimAt(p: { x: number; y: number }): void;\n /** Sample the color the lens is showing at `p` — a screen point inside the\n * lens — and report it to `onPick`. Omit `p` to pick at the aim point.\n * Returns the hex, or `null` when the framebuffer cannot answer for that\n * point, including before any frame has landed. Leaves the aim, and\n * `color`, alone. */\n pick(p?: { x: number; y: number }): string | null;\n /** Ask for a paint, and on the frame that lands read the picture and the color under the aim again: what is\n * under the aim changed in a way no `contentVersion` reports. */\n refresh(): void;\n dispose(): void;\n}\n\n/**\n * Build a magnifier: a HUD window whose interior shows the canvas around an\n * aim point, enlarged. Adds the window to the HUD and starts following the\n * pointer; `dispose` removes it again.\n */\nexport function createLoupe(opts: LoupeOptions): LoupeHandle {\n const { hud, canvas: element, requestRedraw } = opts;\n const host = opts.views;\n const interactive = host !== undefined && opts.interactive === true;\n const input = opts.input ?? element;\n let lens: CanvasViewHandle | null = null;\n let pixels: ImageBitmap | null = null;\n const dropPixels = () => {\n if (!pixels) return;\n releaseImageSource(pixels);\n pixels.close();\n pixels = null;\n };\n let pixelsPending = false;\n let refreshWanted = false;\n let disposed = false;\n // Until a paint lands, the context on a shared canvas may not exist yet, and\n // opening it here would give every tenant one with no stencil buffer.\n let landed = false;\n\n const b = opts.bounds ?? { x: 24, y: 24, w: 220, h: 200 };\n\n const watch = createContentWatch(opts.contentVersion ?? host?.getPaintedVersion);\n let refreshAsked = false;\n\n const content = (ctx: HudContentCtx): DrawCommand[] => {\n watch.drew(ctx.view);\n return model.mode === 'vector' ? drawVector(ctx) : drawPixels(ctx);\n };\n\n const backdropColor = (ctx: HudContentCtx): string =>\n opts.background ?? ctx.tokens['--wzl-surface'];\n const backdrop = (ctx: HudContentCtx): DrawCommand => backdropOf(ctx, backdropColor(ctx));\n\n const innerView = (outer: View, rect: WidgetBounds): View => (\n lensCamera(model.aim, host?.viewAt?.(model.aim, { except: LENS_VIEW }) ?? null, outer, rect, model.factor)\n );\n\n const drawVector = (ctx: HudContentCtx): DrawCommand[] => {\n if (host) return lens ? [backdrop(ctx), ...lens.draw(ctx.data, ctx.view, ctx.dims)] : [backdrop(ctx)];\n // A fresh lens per frame: CreateViewportLayerOpts.view is static, and the\n // inner view moves with the pointer.\n const picture = createViewportLayer<unknown>({\n id: `${win.id}:lens`,\n label: 'Loupe content',\n source: opts.source ?? [],\n view: innerView(ctx.view, ctx.rect),\n bounds: () => ctx.rect,\n background: backdropColor(ctx),\n });\n return picture.draw(ctx.data, ctx.view, ctx.dims);\n };\n\n const drawPixels = (ctx: HudContentCtx): DrawCommand[] => {\n // The backdrop paints even with a bitmap in hand: a readback of a\n // transparent framebuffer is transparent, and before the first one\n // settles there is nothing at all, either of which leaves the lens a\n // hole onto the unmagnified canvas.\n const out: DrawCommand[] = [backdrop(ctx)];\n if (pixels) {\n out.push({\n kind: 'image',\n image: pixels,\n x: ctx.rect.x, y: ctx.rect.y, w: ctx.rect.w, h: ctx.rect.h,\n sampling: 'nearest',\n });\n }\n return out;\n };\n\n // `gl.readPixels` outside a landed paint returns the *previous* frame, so an\n // aim only marks the lens dirty; the read itself happens in the frame\n // subscriber below, on the frame that painted.\n const scheduleRefresh = () => {\n if (disposed || model.mode !== 'pixel') return;\n refreshWanted = true;\n };\n\n /** Read device px of the loupe's region around `at`, sized for the\n * canvas's pixel ratio, or `null` when the framebuffer cannot answer. */\n const read = (\n at: { x: number; y: number },\n rw: (dpr: number) => number,\n rh: (dpr: number) => number,\n ): ImageData | null => {\n if (!landed) return null;\n const gl = element.getContext('webgl2');\n if (!gl) return null;\n const cssRect = element.getBoundingClientRect();\n if (cssRect.width === 0) return null;\n const dpr = element.width / cssRect.width;\n // A view-backed lens knows its canvas, so over a detached pane it reads\n // that pane's pixels without being told where the pane is.\n const r = (opts.region ?? host?.getSurfaceRect)?.();\n const target = r\n ? {\n x: Math.round(r.x * dpr), y: Math.round(r.y * dpr),\n width: Math.round(r.width * dpr), height: Math.round(r.height * dpr),\n }\n : { x: 0, y: 0, width: element.width, height: element.height };\n return readbackRegion(gl, element.height, target, at, dpr, rw(dpr), rh(dpr));\n };\n\n const refreshPixels = () => {\n if (disposed || model.mode !== 'pixel') return;\n const rect = win.contentRect;\n const data = read(\n model.aim,\n (dpr) => Math.max(1, Math.round((rect.w * dpr) / model.factor)),\n (dpr) => Math.max(1, Math.round((rect.h * dpr) / model.factor)),\n );\n if (!data) return;\n pixelsPending = true;\n createImageBitmap(data)\n .then((bmp) => {\n if (disposed) { bmp.close(); return; }\n dropPixels();\n pixels = bmp;\n pixelsPending = false;\n requestRedraw();\n })\n .catch(() => {\n pixelsPending = false;\n requestRedraw();\n });\n };\n\n const readHex = (at: { x: number; y: number }): string | null => {\n const px = read(at, () => 1, () => 1);\n if (!px || px.data[3] === 0) return null;\n return '#' + [px.data[0], px.data[1], px.data[2]]\n .map((c) => c.toString(16).padStart(2, '0')).join('');\n };\n\n const win = hud.window({\n id: 'weasel-loupe',\n x: b.x, y: b.y, w: b.w, h: b.h,\n title: opts.title ?? 'Loupe',\n titlebar: opts.titlebar,\n content,\n interior: interactive ? 'pass' : 'claim',\n onResize: () => { scheduleRefresh(); },\n ...(interactive ? {} : { onContentClick: (p: { x: number; y: number }) => { model.pick(p); } }),\n ...(opts.onClose ? { onClose: opts.onClose } : {}),\n });\n\n const surface: LoupeSurface = {\n lens: () => win.contentRect,\n covers: (p) => win.hitTest(p.x, p.y) || (win.passes?.(p.x, p.y) ?? false),\n sample: readHex,\n hidden: () => win.hidden,\n gone: () => win.disposed === true,\n changed: () => { scheduleRefresh(); requestRedraw(); },\n subscribeFrame: hud.subscribeFrame,\n };\n\n // Subscribed ahead of the model, so the frame that lands first is already\n // readable by the time the model samples on it.\n const unsubscribeFrame = hud.subscribeFrame(() => {\n landed = true;\n if (watch.changed() || refreshAsked) {\n refreshAsked = false;\n scheduleRefresh();\n model.resample();\n }\n // A refresh wanted while a bitmap is in flight is remembered rather than\n // dropped: the flag survives until a frame finds it settled, so the aim\n // the user ends a fast drag on is the one that gets read.\n if (!refreshWanted || pixelsPending) return;\n refreshWanted = false;\n refreshPixels();\n });\n\n const model: LoupeModel = createLoupeModel({\n surface,\n ...(opts.mode ? { mode: opts.mode } : {}),\n ...(opts.factor !== undefined ? { factor: opts.factor } : {}),\n ...(opts.onColorChange ? { onColorChange: opts.onColorChange } : {}),\n ...(opts.onPick ? { onPick: opts.onPick } : {}),\n onDispose: () => teardown(),\n });\n\n if (host) {\n lens = host.addView({\n id: LENS_VIEW,\n label: 'Loupe',\n bounds: () => (win.hidden ? NO_RECT : win.contentRect),\n view: (outer) => innerView(outer, win.contentRect),\n paint: false,\n interactive,\n ...(opts.source ? { layers: () => opts.source! } : {}),\n });\n }\n\n const unfollow = followPointer(input, {\n aimAt: (p) => model.aimAt(p),\n holds: (p) => interactive && surface.covers(p),\n });\n\n const teardown = () => {\n disposed = true;\n unsubscribeFrame();\n unfollow();\n lens?.remove();\n lens = null;\n dropPixels();\n };\n\n return {\n window: win,\n get mode() { return model.mode; },\n get factor() { return model.factor; },\n get aim() { return model.aim; },\n get color() { return model.color; },\n setMode: model.setMode,\n setFactor: model.setFactor,\n aimAt: model.aimAt,\n pick: model.pick,\n refresh() {\n if (disposed) return;\n refreshAsked = true;\n requestRedraw();\n },\n dispose() {\n model.dispose();\n win.dispose();\n },\n };\n}\n"],"mappings":";;;;;;;;;;;AAIA,SAASkB,GAAQ,GAAmB,GAAyB;CAI3D,OAHIC,EAAE,SAAS,WAAiB,GAAGA,EAAE,MAAM,IAAIC,GAAeC,EAAE,YAAYF,CAAC,GAAGA,CAAC,MAC7EA,EAAE,SAAS,UAAgB,GAAGA,EAAE,MAAM,IAAIA,EAAE,SAAS,QACrDA,EAAE,SAAS,SAAe,GAAGA,EAAE,MAAM,IAAIE,EAAE,UAAUF,CAAC,KAAK,QACxDA,EAAE;AACX;AAGA,SAASG,EAAM,GAAmB,GAAiC;CACjE,IAAMC,IAAQF,EAAE,MAAM,GAChBG,IAAUC,MAAOF,EAAM,SAAS;CACtC,OAAOF,EAAE,UAAUI,CAAE,CAAC,CAAC,KAAK,GAAG,MAAyB;EACtD,IAAIN,EAAE,SAAS,aAAa,OAAO;GAAE,MAAM;GAAa,KAAKA,EAAE;EAAI;EACnE,IAAMO,IAAYP,EAAE,SAAS,UAAUA,EAAE,YAAY,KAAA,GAC/CQ,IAAOR,EAAE,SAAS,aAAaI,EAAME,OAAQG,KAAKL,EAAM,SAASE,IAAK;EAC5E,OAAO;GACL,MAAMC,IAAY,qBAAqB;GACvC,KAAKP,EAAE;GACP,OAAOD,GAAQG,GAAGF,CAAC;GACnB,GAAIK,KAAWD,EAAME,OAAQG,IAAI,EAAE,QAAQ,GAAK,IAAI,CAAC;GACrD,GAAIT,EAAE,SAAS,UAAUA,EAAE,YAAY,KAAA,IAAY,EAAE,SAASA,EAAE,QAAQ,IAAI,CAAC;GAC7E,GAAIA,EAAE,YAAYA,EAAE,SAAS,WAAWA,EAAE,SAAS,SAAS,EAAE,UAAU,GAAK,IAAI,CAAC;GAClF,GAAIA,EAAE,SAAS,YAAY,EAAE,UAAUQ,EAAK,IAAI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W;EACjD,OAAO;EACP;EACA,GAAI/G,EAAK,SAAS,EAAE,cAAcA,EAAK,OAAQ,IAAI,CAAC;CACtD,CAAC;CAGH,IAAM6H,IAAWjE,GAAcG,GAAO;EACpC,QAAQ,MAAMyC,EAAM,MAAMlP,CAAC;EAC3B,QAAQ,MAAMwO,KAAe2B,EAAQ,OAAOnQ,CAAC;CAC/C,CAAC,GAEKsQ,UAAiB;EAMrB,AALA,IAAW,IACXF,EAAiB,GACjBG,EAAS,GACT5D,GAAM,OAAO,GACb,IAAO,MACP+B,EAAW;CACb;CAEA,OAAO;EACL,QAAQe;EACR,IAAI,OAAO;GAAE,OAAOP,EAAM;EAAM;EAChC,IAAI,SAAS;GAAE,OAAOA,EAAM;EAAQ;EACpC,IAAI,MAAM;GAAE,OAAOA,EAAM;EAAK;EAC9B,IAAI,QAAQ;GAAE,OAAOA,EAAM;EAAO;EAClC,SAASA,EAAM;EACf,WAAWA,EAAM;EACjB,OAAOA,EAAM;EACb,MAAMA,EAAM;EACZ,UAAU;GACR,AAAIlF,MACJ,IAAe,IACfgG,EAAc;EAChB;EACA,UAAU;GAER,AADAd,EAAM,QAAQ,GACdO,EAAI,QAAQ;EACd;CACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"accessibleMenu.d.ts","sourceRoot":"","sources":["../../src/menu/accessibleMenu.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,cAAc,EAAqB,MAAM,iBAAiB,CAAC;AACzF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AA8BnD;0DAC0D;AAC1D,wBAAgB,cAAc,CAAC,CAAC,EAAE,cAAc,GAAG,iBAAiB,CAEnE"}
1
+ {"version":3,"file":"accessibleMenu.d.ts","sourceRoot":"","sources":["../../src/menu/accessibleMenu.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,cAAc,EAAqB,MAAM,iBAAiB,CAAC;AACzF,OAAO,KAAK,EAAE,iBAAiB,EAAE,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,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,CAQnG;AAMD;oDACoD;AACpD,wBAAgB,SAAS,CACvB,OAAO,EAAE,SAAS,SAAS,EAAE,EAAE,CAAC,EAAE,WAAW,EAAE,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,MAAM,GACjG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAe1B;AA0BD,yGAAyG;AACzG,MAAM,MAAM,SAAS,GAAG,IAAI,CAAC,YAAY,EAAE,KAAK,GAAG,YAAY,CAAC,CAAC;AAQjE;;6DAE6D;AAC7D,wBAAgB,SAAS,CACvB,GAAG,EAAE,UAAU,EAAE,CAAC,EAAE,YAAY,EAAE,OAAO,EAAE,SAAS,SAAS,EAAE,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,EAAE,CAAC,EAAE,WAAW,EACzG,KAAK,CAAC,EAAE,SAAS,EAAE,KAAK,GAAE,CAAC,CAAC,EAAE,eAAe,KAAK,MAAM,GAAG,SAA0B,GACpF,WAAW,EAAE,CAiDf;AAED,yDAAyD;AACzD,wBAAgB,KAAK,CAAC,OAAO,EAAE,SAAS,SAAS,EAAE,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAG7F"}
@@ -36,6 +36,11 @@ export declare function numberCommands(b: WidgetBounds, r: {
36
36
  y: number;
37
37
  h: number;
38
38
  }, e: MenuNumberEntry, value: number | undefined, m: MenuMetrics, ink: ValueInk): DrawCommand[];
39
+ /** A text row's value at the row's end, muted: nothing in a HUD menu edits it. */
40
+ export declare function textCommands(b: WidgetBounds, r: {
41
+ y: number;
42
+ h: number;
43
+ }, value: string | undefined, m: MenuMetrics, ink: ValueInk): DrawCommand[];
39
44
  /** The swatch a color row draws in its icon column, and its hex at the row's end. */
40
45
  export declare function colorCommands(b: WidgetBounds, r: {
41
46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AA;CAAE,EAAE,CAAC,EAAE,cAAc,EAAE,CAAC,EAAE,WAAW,EAAE,GAAG,EAAE,QAAQ,GAC7F,WAAW,EAAE,CAgBf"}
@@ -1,4 +1,4 @@
1
- import { n as e, o as t, r as n } from "../tool-B5AjewKP.js";
1
+ import { n as e, o as t, r as n } from "../tool-DfJuN7jP.js";
2
2
  import { resolveTheme as r, weaselTheme as i } from "@weasel-js/theme";
3
3
  import { useEffect as a, useMemo as o, useState as s } from "react";
4
4
  import { useThemeOptional as c } from "@weasel-js/theme/react";
@@ -1236,7 +1236,8 @@ function fe(e, t) {
1236
1236
  target: { kindOf: X("pointer") },
1237
1237
  mods: J
1238
1238
  },
1239
- actionId: "hud.press"
1239
+ actionId: "hud.press",
1240
+ opts: { id: "weasel-hud.press" }
1240
1241
  },
1241
1242
  {
1242
1243
  spec: {
@@ -1244,7 +1245,8 @@ function fe(e, t) {
1244
1245
  target: { kindOf: X("pointer") },
1245
1246
  mods: J
1246
1247
  },
1247
- actionId: "hud.release"
1248
+ actionId: "hud.release",
1249
+ opts: { id: "weasel-hud.release" }
1248
1250
  },
1249
1251
  {
1250
1252
  spec: {
@@ -1252,7 +1254,8 @@ function fe(e, t) {
1252
1254
  target: { kindOf: X("pointer") },
1253
1255
  mods: J
1254
1256
  },
1255
- actionId: "hud.drag"
1257
+ actionId: "hud.drag",
1258
+ opts: { id: "weasel-hud.drag" }
1256
1259
  },
1257
1260
  {
1258
1261
  spec: {
@@ -1260,7 +1263,8 @@ function fe(e, t) {
1260
1263
  target: { kindOf: X("doubleClick") },
1261
1264
  mods: J
1262
1265
  },
1263
- actionId: "hud.doubleClick"
1266
+ actionId: "hud.doubleClick",
1267
+ opts: { id: "weasel-hud.doubleClick" }
1264
1268
  },
1265
1269
  {
1266
1270
  spec: {
@@ -1268,7 +1272,8 @@ function fe(e, t) {
1268
1272
  target: { kindOf: X("contextMenu") },
1269
1273
  mods: J
1270
1274
  },
1271
- actionId: "hud.contextMenu"
1275
+ actionId: "hud.contextMenu",
1276
+ opts: { id: "weasel-hud.contextMenu" }
1272
1277
  },
1273
1278
  {
1274
1279
  spec: {
@@ -1276,7 +1281,8 @@ function fe(e, t) {
1276
1281
  target: { kindOf: X("longPress") },
1277
1282
  mods: J
1278
1283
  },
1279
- actionId: "hud.longPress"
1284
+ actionId: "hud.longPress",
1285
+ opts: { id: "weasel-hud.longPress" }
1280
1286
  },
1281
1287
  {
1282
1288
  spec: {
@@ -1284,7 +1290,8 @@ function fe(e, t) {
1284
1290
  target: { kindOf: X("wheel") },
1285
1291
  mods: J
1286
1292
  },
1287
- actionId: "hud.wheel"
1293
+ actionId: "hud.wheel",
1294
+ opts: { id: "weasel-hud.wheel" }
1288
1295
  }
1289
1296
  ]
1290
1297
  };
@@ -1292,4 +1299,4 @@ function fe(e, t) {
1292
1299
  //#endregion
1293
1300
  export { R as a, N as c, b as d, x as f, L as i, S as l, fe as n, I as o, W as r, A as s, q as t, C as u };
1294
1301
 
1295
- //# sourceMappingURL=tool-B5AjewKP.js.map
1302
+ //# sourceMappingURL=tool-DfJuN7jP.js.map