@dashfoo/core 0.4.0 → 0.5.1
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/README.md +58 -17
- package/dist/index.d.ts +95 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1149 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/model/schema.ts","../src/state/actions.ts","../src/model/ids.ts","../src/model/tree.ts","../src/model/builders.ts","../src/geometry/geometry.ts","../src/geometry/snap.ts","../src/model/invariants.ts","../src/state/reducer.ts","../src/state/history.ts","../src/machines/dashfoo-machine.ts","../src/machines/drag-dock-machine.ts","../src/model/serialize.ts","../src/model/stack.ts"],"sourcesContent":["import { z } from \"zod\";\n\n// A JSON-serializable value. Per-tab `config` is validated against this so the\n// model stays losslessly serializable (a function or symbol in config fails).\ntype JsonValue = string | number | boolean | null | Array<JsonValue> | { [key: string]: JsonValue };\n\nconst jsonValueSchema: z.ZodType<JsonValue> = z.lazy(() =>\n z.union([\n z.string(),\n z.number(),\n z.boolean(),\n z.null(),\n z.array(jsonValueSchema),\n z.record(z.string(), jsonValueSchema),\n ]),\n);\n\nconst edgeSchema = z.enum([\"top\", \"bottom\", \"left\", \"right\"]);\nconst unitSchema = z.enum([\"px\", \"%\", \"em\", \"rem\", \"vh\", \"vw\"]);\nconst orientationSchema = z.enum([\"row\", \"column\"]);\n\nconst dimensionSchema = z.object({\n unit: unitSchema,\n value: z.number(),\n});\n\n// Magnetic snap config for split resize. The grid the dragged boundary snaps to is\n// the union of two optional sources: `step` (multiples of a fixed percent) and\n// `divisions` (even splits — multiples of 100/d, where d is the number or, for\n// \"panels\", the row's own child count, so a 3-panel row snaps to thirds and a\n// 4-panel row to quarters). `threshold` is the magnetic grab distance in percent.\n// An empty config (or a `step` of 0 with no `divisions`) disables snapping — used\n// to opt a single row out of an inherited global default.\nconst snapSchema = z.object({\n divisions: z.union([z.number().positive(), z.literal(\"panels\")]).optional(),\n step: z.number().min(0).optional(),\n threshold: z.number().positive().optional(),\n});\n\nconst tabNodeSchema = z.object({\n component: z.string(),\n config: jsonValueSchema.optional(),\n enableClose: z.boolean().optional(),\n enableDrag: z.boolean().optional(),\n enableRename: z.boolean().optional(),\n id: z.string(),\n name: z.string(),\n type: z.literal(\"tab\"),\n});\n\nconst tabsetNodeSchema = z.object({\n children: z.array(tabNodeSchema),\n enableClose: z.boolean().optional(),\n enableMaximize: z.boolean().optional(),\n id: z.string(),\n max: dimensionSchema.optional(),\n min: dimensionSchema.optional(),\n name: z.string().optional(),\n selected: z.number().int(),\n type: z.literal(\"tabset\"),\n weight: z.number().optional(),\n});\n\n// RowNode is recursive (a row may contain rows), so its type is declared\n// explicitly and the schema is built with z.lazy.\ntype RowNode = {\n children: Array<RowNode | z.infer<typeof tabsetNodeSchema>>;\n id: string;\n max?: z.infer<typeof dimensionSchema>;\n min?: z.infer<typeof dimensionSchema>;\n orientation: z.infer<typeof orientationSchema>;\n snap?: z.infer<typeof snapSchema>;\n type: \"row\";\n weight?: number;\n};\n\nconst rowNodeSchema: z.ZodType<RowNode> = z.lazy(() =>\n z.object({\n children: z.array(z.union([rowNodeSchema, tabsetNodeSchema])),\n id: z.string(),\n max: dimensionSchema.optional(),\n min: dimensionSchema.optional(),\n orientation: orientationSchema,\n snap: snapSchema.optional(),\n type: z.literal(\"row\"),\n weight: z.number().optional(),\n }),\n);\n\nconst globalAttributesSchema = z.object({\n enableSplitDock: z.boolean().optional(),\n enableSplitResize: z.boolean().optional(),\n snap: snapSchema.optional(),\n splitterSize: z.number().optional(),\n tabEnableClose: z.boolean().optional(),\n tabEnableDrag: z.boolean().optional(),\n tabEnableRename: z.boolean().optional(),\n tabLocation: z.enum([\"top\", \"bottom\"]).optional(),\n tabSetEnableMaximize: z.boolean().optional(),\n tabSetEnableTabStrip: z.boolean().optional(),\n tabSetMinSize: z.number().optional(),\n});\n\nconst dashfooSchema = z.object({\n activeTabsetId: z.string().optional(),\n global: globalAttributesSchema,\n layout: rowNodeSchema,\n maximizedTabsetId: z.string().optional(),\n // The persisted-payload format version, pinned by the schema itself: any\n // future format change bumps the literal, so foreign payloads fail validation.\n version: z.literal(1),\n});\n\ntype Json = JsonValue;\ntype Edge = z.infer<typeof edgeSchema>;\ntype Unit = z.infer<typeof unitSchema>;\ntype Orientation = z.infer<typeof orientationSchema>;\ntype Dimension = z.infer<typeof dimensionSchema>;\ntype SnapConfig = z.infer<typeof snapSchema>;\ntype TabNode = z.infer<typeof tabNodeSchema>;\ntype TabsetNode = z.infer<typeof tabsetNodeSchema>;\ntype GlobalAttributes = z.infer<typeof globalAttributesSchema>;\ntype Dashfoo = z.infer<typeof dashfooSchema>;\ntype Node = RowNode | TabsetNode | TabNode;\n\nexport {\n dashfooSchema,\n dimensionSchema,\n edgeSchema,\n globalAttributesSchema,\n jsonValueSchema,\n orientationSchema,\n rowNodeSchema,\n snapSchema,\n tabNodeSchema,\n tabsetNodeSchema,\n unitSchema,\n};\n\nexport type {\n Dashfoo,\n Dimension,\n Edge,\n GlobalAttributes,\n Json,\n Node,\n Orientation,\n RowNode,\n SnapConfig,\n TabNode,\n TabsetNode,\n Unit,\n};\n","import { z } from \"zod\";\n\nimport {\n dimensionSchema,\n globalAttributesSchema,\n orientationSchema,\n snapSchema,\n tabNodeSchema,\n tabsetNodeSchema,\n} from \"../model/schema\";\n\nconst mutableTabAttrsSchema = tabNodeSchema\n .pick({\n config: true,\n enableClose: true,\n enableDrag: true,\n enableRename: true,\n name: true,\n })\n .partial();\n\nconst mutableTabsetAttrsSchema = tabsetNodeSchema\n .pick({\n enableClose: true,\n enableMaximize: true,\n max: true,\n min: true,\n selected: true,\n weight: true,\n })\n .partial();\n\nconst mutableRowAttrsSchema = z\n .object({\n max: dimensionSchema.optional(),\n min: dimensionSchema.optional(),\n orientation: orientationSchema,\n snap: snapSchema.optional(),\n weight: z.number(),\n })\n .partial();\n\nconst mutableNodeAttrsSchema = z.union([\n mutableTabAttrsSchema,\n mutableTabsetAttrsSchema,\n mutableRowAttrsSchema,\n]);\n\n// Every document mutation is one of these immutable, discriminated actions. The\n// reducer is exhaustive over this union; the React layer validates untrusted\n// payloads against actionSchema before dispatch.\nconst dockLocationSchema = z.enum([\n \"center\",\n \"split-bottom\",\n \"split-left\",\n \"split-right\",\n \"split-top\",\n]);\n\nconst actionSchema = z.discriminatedUnion(\"type\", [\n z.object({\n index: z.number().int().optional(),\n location: dockLocationSchema,\n tab: tabNodeSchema,\n targetId: z.string(),\n type: z.literal(\"addNode\"),\n }),\n z.object({\n index: z.number().int().optional(),\n location: dockLocationSchema,\n sourceId: z.string(),\n targetId: z.string(),\n type: z.literal(\"moveNode\"),\n }),\n z.object({\n index: z.number().int().optional(),\n location: dockLocationSchema,\n sourceId: z.string(),\n targetId: z.string(),\n type: z.literal(\"moveTabset\"),\n }),\n z.object({ index: z.number().int(), tabsetId: z.string(), type: z.literal(\"selectTab\") }),\n z.object({ tabsetId: z.string(), type: z.literal(\"setActiveTabset\") }),\n z.object({ tabsetId: z.string().nullable(), type: z.literal(\"setMaximizedTabset\") }),\n z.object({ name: z.string(), tabId: z.string(), type: z.literal(\"renameTab\") }),\n z.object({ tabId: z.string(), type: z.literal(\"deleteTab\") }),\n z.object({ tabsetId: z.string(), type: z.literal(\"deleteTabset\") }),\n z.object({\n rowId: z.string(),\n type: z.literal(\"adjustSplit\"),\n weights: z.array(z.number()),\n }),\n z.object({\n attrs: mutableNodeAttrsSchema,\n nodeId: z.string(),\n type: z.literal(\"updateNodeAttributes\"),\n }),\n z.object({ attrs: globalAttributesSchema.partial(), type: z.literal(\"updateGlobalAttributes\") }),\n]);\n\ntype DockLocation = z.infer<typeof dockLocationSchema>;\ntype MutableNodeAttrs = z.infer<typeof mutableNodeAttrsSchema>;\ntype Action = z.infer<typeof actionSchema>;\n\n// Where a drag will land: the dock location, the target tabset, and (for a tab\n// stack) the slot index. Co-located with DockLocation; the drag machine and the\n// React adapter both consume it.\ntype DropIntent = { index?: number; location: DockLocation; targetId: string };\n\nexport { actionSchema, dockLocationSchema, mutableNodeAttrsSchema };\nexport type { Action, DockLocation, DropIntent, MutableNodeAttrs };\n","// Unique ids for nodes and tabs. The reducer uses these for split/dock surgery;\n// they are public so consumers building addNode/moveNode payloads (or seed\n// models) have one blessed generator instead of rolling their own.\nconst createNodeId = (prefix = \"node\"): string => `${prefix}-${crypto.randomUUID()}`;\n\nconst createTabId = (): string => createNodeId(\"tab\");\n\nexport { createNodeId, createTabId };\n","import type { Dashfoo, RowNode, TabNode, TabsetNode } from \"./schema\";\n\n// A tab lives inside a tabset.\ntype TabContainer = TabsetNode;\ntype TabLocation = { container: TabContainer; index: number; tab: TabNode };\n\nconst collectTabsetsInRow = (row: RowNode, acc: Array<TabsetNode>): void => {\n for (const child of row.children) {\n if (child.type === \"tabset\") {\n acc.push(child);\n } else {\n collectTabsetsInRow(child, acc);\n }\n }\n};\n\n// Every tabset in the layout tree, depth-first.\nconst collectTabsets = (model: Dashfoo): Array<TabsetNode> => {\n const acc: Array<TabsetNode> = [];\n collectTabsetsInRow(model.layout, acc);\n return acc;\n};\n\nconst getFirstTabset = (model: Dashfoo): TabsetNode | undefined => collectTabsets(model)[0];\n\nconst findTabset = (model: Dashfoo, tabsetId: string): TabsetNode | undefined =>\n collectTabsets(model).find((tabset) => tabset.id === tabsetId);\n\nconst findTabInContainer = (container: TabContainer, tabId: string): TabLocation | undefined => {\n const index = container.children.findIndex((tab) => tab.id === tabId);\n if (index === -1) {\n return undefined;\n }\n\n const tab = container.children[index];\n if (!tab) {\n return undefined;\n }\n\n return { container, index, tab };\n};\n\n// Locate a tab anywhere in the model — searching every tabset — returning the\n// tab, its container, and its index within that container.\nconst findTab = (model: Dashfoo, tabId: string): TabLocation | undefined => {\n for (const tabset of collectTabsets(model)) {\n const found = findTabInContainer(tabset, tabId);\n if (found) {\n return found;\n }\n }\n\n return undefined;\n};\n\ntype AttributedNode = RowNode | TabNode | TabsetNode;\n\n// Find a row anywhere in the layout tree by id.\nconst findRow = (row: RowNode, id: string): RowNode | undefined => {\n if (row.id === id) {\n return row;\n }\n for (const child of row.children) {\n if (child.type === \"row\") {\n const found = findRow(child, id);\n if (found) {\n return found;\n }\n }\n }\n return undefined;\n};\n\nconst findAttributedNodeInRow = (row: RowNode, id: string): AttributedNode | undefined => {\n if (row.id === id) {\n return row;\n }\n for (const child of row.children) {\n if (child.type === \"row\") {\n const found = findAttributedNodeInRow(child, id);\n if (found) {\n return found;\n }\n continue;\n }\n if (child.id === id) {\n return child;\n }\n // Single-id recursive search invoked once per lookup over small layout\n // trees — building a Map per call would cost more than it saves.\n // oxlint-disable-next-line react-doctor/js-index-maps\n const tab = child.children.find((candidate) => candidate.id === id);\n if (tab) {\n return tab;\n }\n }\n return undefined;\n};\n\n// Locate any attributed node (row, tabset, or tab) by id — backs updateNodeAttributes.\nconst findAttributedNode = (model: Dashfoo, id: string): AttributedNode | undefined =>\n findAttributedNodeInRow(model.layout, id);\n\n// The row holding a tabset, and the tabset's index within it — backs split placement.\nconst findTabsetParent = (\n row: RowNode,\n tabsetId: string,\n): { index: number; parent: RowNode } | undefined => {\n const index = row.children.findIndex((child) => child.type === \"tabset\" && child.id === tabsetId);\n if (index !== -1) {\n return { index, parent: row };\n }\n for (const child of row.children) {\n if (child.type === \"row\") {\n const found = findTabsetParent(child, tabsetId);\n if (found) {\n return found;\n }\n }\n }\n return undefined;\n};\n\nconst collectIdsInRow = (row: RowNode, acc: Array<string>): void => {\n acc.push(row.id);\n for (const child of row.children) {\n if (child.type === \"row\") {\n collectIdsInRow(child, acc);\n } else {\n acc.push(child.id);\n for (const tab of child.children) {\n acc.push(tab.id);\n }\n }\n }\n};\n\n// Ids that appear more than once across the whole model (rows, tabsets, tabs).\n// Duplicate ids produce duplicate React keys and corrupt the resize/drag\n// plumbing, so this backs a load-time diagnostic.\nconst findDuplicateIds = (model: Dashfoo): Array<string> => {\n const ids: Array<string> = [];\n collectIdsInRow(model.layout, ids);\n const seen = new Set<string>();\n const duplicates = new Set<string>();\n for (const id of ids) {\n if (seen.has(id)) {\n duplicates.add(id);\n }\n seen.add(id);\n }\n return [...duplicates];\n};\n\nexport {\n collectTabsets,\n findAttributedNode,\n findDuplicateIds,\n findRow,\n findTab,\n findTabset,\n findTabsetParent,\n getFirstTabset,\n};\nexport type { AttributedNode, TabContainer, TabLocation };\n","// Ergonomic constructors for the layout model, so consumers seed a Dashfoo\n// without hand-writing `type`/`version`/`selected` boilerplate or nested\n// literals. Every builder fills the required-but-mechanical fields and leaves\n// the meaningful ones (ids that get referenced, weights) to the caller. Output\n// is schema-valid by construction; id uniqueness across reused components is\n// the caller's responsibility (tabs default their id to the component name), so\n// `model` warns once if it detects duplicate node ids.\n\nimport { createNodeId } from \"./ids\";\nimport type {\n Dashfoo,\n Dimension,\n GlobalAttributes,\n Json,\n RowNode,\n SnapConfig,\n TabNode,\n TabsetNode,\n} from \"./schema\";\nimport { findDuplicateIds } from \"./tree\";\n\nconst toDimension = (value: number | Dimension): Dimension =>\n typeof value === \"number\" ? { unit: \"px\", value } : value;\n\ntype TabOptions = {\n config?: Json;\n enableClose?: boolean;\n enableDrag?: boolean;\n enableRename?: boolean;\n id?: string;\n};\n\n// The id defaults to the component name — the common case where a layout holds\n// one tab per component and references it by that name.\nconst tab = (component: string, name: string, options: TabOptions = {}): TabNode => ({\n component,\n name,\n type: \"tab\",\n ...options,\n id: options.id ?? component,\n});\n\ntype TabsetOptions = {\n enableClose?: boolean;\n enableMaximize?: boolean;\n id?: string;\n max?: number | Dimension;\n min?: number | Dimension;\n name?: string;\n selected?: number;\n weight?: number;\n};\n\nconst tabset = (children: Array<TabNode>, options: TabsetOptions = {}): TabsetNode => {\n const { max, min, ...rest } = options;\n return {\n children,\n type: \"tabset\",\n ...rest,\n ...(max === undefined ? {} : { max: toDimension(max) }),\n ...(min === undefined ? {} : { min: toDimension(min) }),\n id: options.id ?? createNodeId(\"tabset\"),\n selected: options.selected ?? 0,\n };\n};\n\ntype RowOptions = {\n id?: string;\n max?: number | Dimension;\n min?: number | Dimension;\n orientation?: RowNode[\"orientation\"];\n snap?: SnapConfig;\n weight?: number;\n};\n\nconst row = (children: RowNode[\"children\"], options: RowOptions = {}): RowNode => {\n const { max, min, ...rest } = options;\n return {\n children,\n type: \"row\",\n ...rest,\n ...(max === undefined ? {} : { max: toDimension(max) }),\n ...(min === undefined ? {} : { min: toDimension(min) }),\n id: options.id ?? createNodeId(\"row\"),\n orientation: options.orientation ?? \"row\",\n };\n};\n\ntype ModelOptions = {\n activeTabsetId?: string;\n global?: GlobalAttributes;\n maximizedTabsetId?: string;\n};\n\nconst model = (layout: RowNode, options: ModelOptions = {}): Dashfoo => {\n const built: Dashfoo = {\n layout,\n version: 1,\n ...options,\n global: options.global ?? {},\n };\n const duplicates = findDuplicateIds(built);\n if (duplicates.length > 0) {\n // oxlint-disable-next-line no-console\n console.warn(\n `[dashfoo] builder produced duplicate node ids: ${duplicates.join(\", \")} — pass explicit ids when reusing a component`,\n );\n }\n return built;\n};\n\nexport { model, row, tab, tabset };\nexport type { ModelOptions, RowOptions, TabOptions, TabsetOptions };\n","import type { Edge } from \"../model/schema\";\nimport type { DockLocation } from \"../state/actions\";\n\ntype Point = { x: number; y: number };\ntype Rect = { height: number; width: number; x: number; y: number };\ntype DockTarget = { kind: \"tab\" } | { edge: Edge; kind: \"split\" };\ntype BandOptions = { bandFraction?: number };\ntype DockZone = { location: DockLocation; points: Array<Point> };\n\n// Shared by resolveDockTarget and dockZonePolygons so the painted map and the\n// live hit-test can never disagree on where the edge bands end.\nconst DEFAULT_BAND_FRACTION = 0.22;\n\n// Fractional distance of the pointer from each of the four edges of a rect.\nconst edgeDistances = (\n pointer: Point,\n rect: Rect,\n): { bottom: number; left: number; right: number; top: number } => {\n const fx = (pointer.x - rect.x) / rect.width;\n const fy = (pointer.y - rect.y) / rect.height;\n return { bottom: 1 - fy, left: fx, right: 1 - fx, top: fy };\n};\n\nconst closestEdge = (d: { bottom: number; left: number; right: number; top: number }): Edge => {\n const min = Math.min(d.left, d.right, d.top, d.bottom);\n if (min === d.left) {\n return \"left\";\n }\n if (min === d.right) {\n return \"right\";\n }\n if (min === d.top) {\n return \"top\";\n }\n return \"bottom\";\n};\n\n// Where a drag dropped over a tabset should land: stacked as a tab when the\n// pointer is in the center, or splitting the tabset when it is within an outer\n// band (default 22%) of one of the four edges — the closer edge wins in corners.\nconst resolveDockTarget = (pointer: Point, rect: Rect, opts?: BandOptions): DockTarget => {\n const band = opts?.bandFraction ?? DEFAULT_BAND_FRACTION;\n // a zero-size tabset has no meaningful edges; dividing by its width/height\n // yields NaN distances that would silently resolve to a bogus split.\n if (rect.width <= 0 || rect.height <= 0) {\n return { kind: \"tab\" };\n }\n const distances = edgeDistances(pointer, rect);\n const min = Math.min(distances.left, distances.right, distances.top, distances.bottom);\n\n if (min > band) {\n return { kind: \"tab\" };\n }\n return { edge: closestEdge(distances), kind: \"split\" };\n};\n\n// The full hit-region partition of a tabset for resolveDockTarget: four edge\n// trapezoids and the inner center rect. Seams between adjacent edge zones sit\n// where the fractional edge distances tie — straight diagonals from each rect\n// corner to the matching inner-rect corner — so the map is an exact picture of\n// which location a pointer anywhere over the rect resolves to. A zero-size rect\n// collapses to a single center polygon, mirroring resolveDockTarget's fallback.\nconst dockZonePolygons = (rect: Rect, opts?: BandOptions): Array<DockZone> => {\n const { height: h, width: w, x, y } = rect;\n const nw: Point = { x, y };\n const ne: Point = { x: x + w, y };\n const se: Point = { x: x + w, y: y + h };\n const sw: Point = { x, y: y + h };\n if (w <= 0 || h <= 0) {\n return [{ location: \"center\", points: [nw, ne, se, sw] }];\n }\n const band = opts?.bandFraction ?? DEFAULT_BAND_FRACTION;\n const bx = band * w;\n const by = band * h;\n const innerNw: Point = { x: x + bx, y: y + by };\n const innerNe: Point = { x: x + w - bx, y: y + by };\n const innerSe: Point = { x: x + w - bx, y: y + h - by };\n const innerSw: Point = { x: x + bx, y: y + h - by };\n return [\n { location: \"center\", points: [innerNw, innerNe, innerSe, innerSw] },\n { location: \"split-left\", points: [nw, innerNw, innerSw, sw] },\n { location: \"split-right\", points: [ne, se, innerSe, innerNe] },\n { location: \"split-top\", points: [nw, ne, innerNe, innerNw] },\n { location: \"split-bottom\", points: [sw, innerSw, innerSe, se] },\n ];\n};\n\n// The region the dock indicator highlights for a given location over a tabset:\n// the whole tabset for a center stack, the matching half for a split.\nconst zoneRect = (rect: Rect, location: DockLocation): Rect => {\n const halfW = rect.width / 2;\n const halfH = rect.height / 2;\n switch (location) {\n case \"split-bottom\": {\n return { height: halfH, width: rect.width, x: rect.x, y: rect.y + halfH };\n }\n case \"split-left\": {\n return { height: rect.height, width: halfW, x: rect.x, y: rect.y };\n }\n case \"split-right\": {\n return { height: rect.height, width: halfW, x: rect.x + halfW, y: rect.y };\n }\n case \"split-top\": {\n return { height: halfH, width: rect.width, x: rect.x, y: rect.y };\n }\n default: {\n return rect;\n }\n }\n};\n\nexport { dockZonePolygons, resolveDockTarget, zoneRect };\nexport type { BandOptions, DockTarget, DockZone, Point, Rect };\n","import type { SnapConfig } from \"../model/schema\";\n\n// Magnetic snapping for split resize. Pure math over ordered percentage arrays\n// (sizes sum to ~100) so the engine stays framework-free; the React adapter maps\n// rrp's id-keyed layout to/from these arrays. The dragged boundary index is passed\n// in rather than inferred, so a cascading min-size resize can't fool the snap onto\n// the wrong boundary.\n\nconst DEFAULT_SNAP_THRESHOLD = 4;\n// Round grid positions so equal targets from different sources (step 25 vs\n// divisions 4) dedupe and float drift (100/3) compares cleanly.\nconst TARGET_PRECISION = 1e6;\n\nconst addMultiples = (targets: Set<number>, increment: number): void => {\n if (increment <= 0) {\n return;\n }\n for (let position = increment; position < 100; position += increment) {\n const rounded = Math.round(position * TARGET_PRECISION) / TARGET_PRECISION;\n if (rounded < 100) {\n targets.add(rounded);\n }\n }\n};\n\n// The grid the boundary can snap to: the union of the fixed `step` grid and the\n// even-`divisions` grid (multiples of 100/d, where d is the number or, for\n// \"panels\", the row's panel count). Positions strictly inside 0..100.\nconst resolveSnapTargets = (config: SnapConfig, panelCount: number): Array<number> => {\n const targets = new Set<number>();\n if (config.step !== undefined && config.step > 0) {\n addMultiples(targets, config.step);\n }\n if (config.divisions !== undefined) {\n const divisions = config.divisions === \"panels\" ? panelCount : config.divisions;\n if (divisions >= 2) {\n addMultiples(targets, 100 / divisions);\n }\n }\n return [...targets].toSorted((a, b) => a - b);\n};\n\n// Whether a config produces any snap grid at all — used to gate the resize\n// listeners so a non-snapping layout pays nothing per pointer move.\nconst snapEnabled = (config: SnapConfig | null): boolean =>\n config !== null &&\n ((config.step ?? 0) > 0 ||\n config.divisions === \"panels\" ||\n (typeof config.divisions === \"number\" && config.divisions >= 2));\n\nconst nearestTarget = (position: number, targets: Array<number>): number | undefined =>\n targets.reduce<number | undefined>((best, target) => {\n if (best === undefined || Math.abs(target - position) < Math.abs(best - position)) {\n return target;\n }\n return best;\n }, undefined);\n\ntype SnapResult = { sizes: Array<number>; snapped: boolean };\n\n// Snap the dragged boundary (between panel `boundaryIndex` and the next) to the\n// nearest grid target within the threshold, moving only that pair so siblings keep\n// their sizes. Returns the input unchanged when snapping is off, nothing is within\n// reach, the index is out of range, or the correction would drive a panel negative\n// (rrp re-clamps real px minimums on the next frame).\nconst snapSizes = (sizes: Array<number>, boundaryIndex: number, config: SnapConfig): SnapResult => {\n const threshold = config.threshold ?? DEFAULT_SNAP_THRESHOLD;\n const left = sizes[boundaryIndex];\n const right = sizes[boundaryIndex + 1];\n if (boundaryIndex < 0 || left === undefined || right === undefined) {\n return { sizes, snapped: false };\n }\n\n const targets = resolveSnapTargets(config, sizes.length);\n if (targets.length === 0) {\n return { sizes, snapped: false };\n }\n\n let position = 0;\n for (let index = 0; index <= boundaryIndex; index++) {\n position += sizes[index] ?? 0;\n }\n\n const target = nearestTarget(position, targets);\n if (target === undefined || Math.abs(target - position) > threshold) {\n return { sizes, snapped: false };\n }\n\n const delta = target - position;\n if (left + delta < 0 || right - delta < 0) {\n return { sizes, snapped: false };\n }\n\n const next = [...sizes];\n next[boundaryIndex] = left + delta;\n next[boundaryIndex + 1] = right - delta;\n return { sizes: next, snapped: true };\n};\n\nexport { DEFAULT_SNAP_THRESHOLD, resolveSnapTargets, snapEnabled, snapSizes };\nexport type { SnapResult };\n","import type { Dashfoo, RowNode, TabsetNode } from \"./schema\";\nimport { collectTabsets } from \"./tree\";\n\nconst clampSelected = (length: number, selected: number): number => {\n if (length === 0) {\n return 0;\n }\n // coerce to a non-negative integer first to match the schema's z.number().int():\n // a persisted 1.5 or NaN must not survive as a fractional/NaN index.\n const base = Number.isFinite(selected) ? Math.trunc(selected) : 0;\n if (base < 0) {\n return 0;\n }\n if (base > length - 1) {\n return length - 1;\n }\n return base;\n};\n\nconst normalizeTabset = (tabset: TabsetNode): TabsetNode => ({\n ...tabset,\n selected: clampSelected(tabset.children.length, tabset.selected),\n});\n\n// Drop empty tabsets and empty rows, recurse into child rows, and simplify a\n// single-child row by lifting its lone child (which inherits the lifted row's\n// weight so sizing is preserved).\nconst normalizeRowChildren = (children: RowNode[\"children\"]): RowNode[\"children\"] => {\n const out: RowNode[\"children\"] = [];\n\n for (const child of children) {\n if (child.type === \"tabset\") {\n if (child.children.length > 0) {\n out.push(normalizeTabset(child));\n }\n continue;\n }\n\n const grandchildren = normalizeRowChildren(child.children);\n if (grandchildren.length === 0) {\n continue;\n }\n if (grandchildren.length === 1) {\n const only = grandchildren[0];\n if (only !== undefined) {\n out.push(child.weight === undefined ? only : { ...only, weight: child.weight });\n }\n continue;\n }\n out.push({ ...child, children: grandchildren });\n }\n\n return out;\n};\n\n// The root is always a row; if it reduces to a single child that is itself a\n// row, absorb that row (adopt its children + orientation) to avoid redundant\n// nesting.\nconst normalizeLayout = (root: RowNode): RowNode => {\n let children = normalizeRowChildren(root.children);\n let orientation = root.orientation;\n\n let inner = children[0];\n while (children.length === 1 && inner?.type === \"row\") {\n children = inner.children;\n orientation = inner.orientation;\n inner = children[0];\n }\n\n return { ...root, children, orientation };\n};\n\n// Self-healing pass run after every action so the tree stays canonical: no empty\n// tabsets or rows, no redundant single-child rows, selected indices in range,\n// and active/maximized ids that always point at an existing tabset.\nconst normalize = (model: Dashfoo): Dashfoo => {\n const layout = normalizeLayout(model.layout);\n const withLayout: Dashfoo = { ...model, layout };\n\n const tabsetIds = new Set(collectTabsets(withLayout).map((tabset) => tabset.id));\n const firstTabsetId = collectTabsets(withLayout)[0]?.id;\n\n const activeTabsetId =\n model.activeTabsetId !== undefined && tabsetIds.has(model.activeTabsetId)\n ? model.activeTabsetId\n : firstTabsetId;\n\n const maximizedTabsetId =\n model.maximizedTabsetId !== undefined && tabsetIds.has(model.maximizedTabsetId)\n ? model.maximizedTabsetId\n : undefined;\n\n return { ...withLayout, activeTabsetId, maximizedTabsetId };\n};\n\nexport { normalize };\n","import { createNodeId } from \"../model/ids\";\nimport { normalize } from \"../model/invariants\";\nimport type { Dashfoo, RowNode, TabNode, TabsetNode } from \"../model/schema\";\nimport { findAttributedNode, findRow, findTab, findTabset, findTabsetParent } from \"../model/tree\";\n\nimport type { Action, DockLocation } from \"./actions\";\n\nconst assertNever = (value: never): never => {\n throw new Error(`Unhandled action: ${JSON.stringify(value)}`);\n};\n\nconst removeTabset = (row: RowNode, tabsetId: string): boolean => {\n const index = row.children.findIndex((child) => child.type === \"tabset\" && child.id === tabsetId);\n if (index !== -1) {\n row.children.splice(index, 1);\n return true;\n }\n for (const child of row.children) {\n if (child.type === \"row\" && removeTabset(child, tabsetId)) {\n return true;\n }\n }\n return false;\n};\n\n// Detach a tabset from the tree and return it (for moving a whole tabset).\nconst removeTabsetReturning = (row: RowNode, tabsetId: string): TabsetNode | undefined => {\n const index = row.children.findIndex((child) => child.type === \"tabset\" && child.id === tabsetId);\n if (index !== -1) {\n const [removed] = row.children.splice(index, 1);\n return removed?.type === \"tabset\" ? removed : undefined;\n }\n for (const child of row.children) {\n if (child.type === \"row\") {\n const found = removeTabsetReturning(child, tabsetId);\n if (found) {\n return found;\n }\n }\n }\n return undefined;\n};\n\nconst splitOrientation = (location: DockLocation): \"column\" | \"row\" =>\n location === \"split-left\" || location === \"split-right\" ? \"row\" : \"column\";\n\nconst splitsBefore = (location: DockLocation): boolean =>\n location === \"split-left\" || location === \"split-top\";\n\n// Place an (already-detached) tabset beside the target for a split-* location:\n// reuse the parent row when the orientation already matches, else wrap the target\n// in a new row. Shared by insertTab (a fresh tabset) and moveTabset (an existing\n// one). Splits the target's space in half.\nconst placeBesideTarget = (\n draft: Dashfoo,\n placed: TabsetNode,\n targetId: string,\n location: DockLocation,\n): void => {\n const targetTabset = findTabset(draft, targetId);\n const found = findTabsetParent(draft.layout, targetId);\n if (!targetTabset || !found) {\n return;\n }\n\n const orientation = splitOrientation(location);\n const before = splitsBefore(location);\n\n if (found.parent.orientation === orientation) {\n const targetWeight = targetTabset.weight ?? 100;\n targetTabset.weight = targetWeight / 2;\n placed.weight = targetWeight / 2;\n found.parent.children.splice(before ? found.index : found.index + 1, 0, placed);\n } else {\n const targetWeight = targetTabset.weight;\n targetTabset.weight = 50;\n placed.weight = 50;\n const newRow: RowNode = {\n children: before ? [placed, targetTabset] : [targetTabset, placed],\n id: createNodeId(\"row\"),\n orientation,\n type: \"row\",\n };\n if (targetWeight !== undefined) {\n newRow.weight = targetWeight;\n }\n found.parent.children.splice(found.index, 1, newRow);\n }\n\n draft.activeTabsetId = placed.id;\n};\n\n// Insert a tab into the model at a dock target. center stacks it into the target\n// tabset; split-* creates a new tabset beside the target.\ntype DropTarget = { id: string; index?: number; location: DockLocation };\n\nconst insertTab = (draft: Dashfoo, tab: TabNode, target: DropTarget): void => {\n const { id: targetId, index, location } = target;\n const targetTabset = findTabset(draft, targetId);\n if (!targetTabset) {\n return;\n }\n\n if (location === \"center\") {\n const at = index ?? targetTabset.children.length;\n targetTabset.children.splice(at, 0, tab);\n targetTabset.selected = at;\n return;\n }\n\n const newTabset: TabsetNode = {\n children: [tab],\n id: createNodeId(\"tabset\"),\n selected: 0,\n type: \"tabset\",\n weight: 50,\n };\n placeBesideTarget(draft, newTabset, targetId, location);\n};\n\nconst applyAction = (draft: Dashfoo, action: Action): void => {\n switch (action.type) {\n case \"addNode\": {\n insertTab(draft, action.tab, {\n id: action.targetId,\n index: action.index,\n location: action.location,\n });\n return;\n }\n case \"adjustSplit\": {\n const row = findRow(draft.layout, action.rowId);\n if (!row) {\n return;\n }\n for (let index = 0; index < action.weights.length; index++) {\n const child = row.children[index];\n const weight = action.weights[index];\n if (!child || weight === undefined) {\n continue;\n }\n child.weight = weight;\n }\n return;\n }\n case \"deleteTab\": {\n const location = findTab(draft, action.tabId);\n if (location) {\n location.container.children.splice(location.index, 1);\n }\n return;\n }\n case \"deleteTabset\": {\n removeTabset(draft.layout, action.tabsetId);\n return;\n }\n case \"moveNode\": {\n const source = findTab(draft, action.sourceId);\n if (!source) {\n return;\n }\n // Remove the source first; action.index is the destination slot measured\n // against the tabs that remain (the drag adapter excludes the dragged tab),\n // so it indexes the post-removal array directly — no reorder adjustment.\n const [removed] = source.container.children.splice(source.index, 1);\n if (!removed) {\n return;\n }\n insertTab(draft, removed, {\n id: action.targetId,\n index: action.index,\n location: action.location,\n });\n return;\n }\n case \"moveTabset\": {\n if (action.sourceId === action.targetId) {\n return;\n }\n const source = findTabset(draft, action.sourceId);\n if (!source) {\n return;\n }\n if (action.location === \"center\") {\n const target = findTabset(draft, action.targetId);\n if (target) {\n const mergeStart = target.children.length;\n // Clamp the source's selection against the SOURCE's own tab count before\n // offsetting. normalize's clampSelected only bounds against the FINAL\n // merged length, so a stale/out-of-range source.selected would otherwise\n // resolve to a valid-but-wrong merged index (an original target tab, or\n // the wrong source tab) that normalize cannot catch. Clamp here so the\n // merged selection always lands on a tab that came from the source.\n const sourceSelected = Math.min(Math.max(source.selected, 0), source.children.length - 1);\n target.children.push(...source.children);\n target.selected = mergeStart + sourceSelected;\n removeTabset(draft.layout, action.sourceId);\n }\n return;\n }\n // split-* moves the whole tabset beside the target.\n if (action.location.startsWith(\"split-\")) {\n const detached = removeTabsetReturning(draft.layout, action.sourceId);\n if (detached) {\n placeBesideTarget(draft, detached, action.targetId, action.location);\n }\n }\n return;\n }\n case \"renameTab\": {\n const location = findTab(draft, action.tabId);\n if (location) {\n location.tab.name = action.name;\n }\n return;\n }\n case \"selectTab\": {\n const tabset = findTabset(draft, action.tabsetId);\n if (tabset) {\n tabset.selected = action.index;\n }\n return;\n }\n case \"setActiveTabset\": {\n if (findTabset(draft, action.tabsetId)) {\n draft.activeTabsetId = action.tabsetId;\n }\n return;\n }\n case \"setMaximizedTabset\": {\n draft.maximizedTabsetId = action.tabsetId ?? undefined;\n return;\n }\n case \"updateGlobalAttributes\": {\n Object.assign(draft.global, action.attrs);\n return;\n }\n case \"updateNodeAttributes\": {\n const node = findAttributedNode(draft, action.nodeId);\n if (node) {\n Object.assign(node, action.attrs);\n }\n return;\n }\n default: {\n assertNever(action);\n }\n }\n};\n\n// The canonical engine: deep-copy the model (so the input is never mutated),\n// apply one action to the copy, then run the self-healing invariants so the\n// result is always a valid, canonical model.\nconst reducer = (model: Dashfoo, action: Action): Dashfoo => {\n const draft = structuredClone(model);\n applyAction(draft, action);\n return normalize(draft);\n};\n\nexport { reducer };\n","import type { Dashfoo } from \"../model/schema\";\n\nimport type { Action } from \"./actions\";\nimport { reducer } from \"./reducer\";\n\n// past/present/future snapshots. Each committed action is its own undo step:\n// rrp v4's onLayoutChanged fires one adjustSplit per release, so there is no\n// per-frame burst to coalesce.\ntype History = {\n future: Array<Dashfoo>;\n past: Array<Dashfoo>;\n present: Dashfoo;\n};\n\n// Snapshots are full model clones, so an unbounded past grows memory for the\n// life of the session (every action — even a tab click — is one step). 100\n// steps is far beyond practical undo depth while keeping memory flat.\nconst HISTORY_LIMIT = 100;\n\nconst createHistory = (present: Dashfoo): History => ({\n future: [],\n past: [],\n present,\n});\n\nconst canUndo = (history: History): boolean => history.past.length > 0;\nconst canRedo = (history: History): boolean => history.future.length > 0;\n\nconst dispatch = (history: History, action: Action): History => {\n const present = reducer(history.present, action);\n return { future: [], past: [...history.past, history.present].slice(-HISTORY_LIMIT), present };\n};\n\nconst undo = (history: History): History => {\n const previous = history.past.at(-1);\n if (previous === undefined) {\n return history;\n }\n return {\n future: [history.present, ...history.future],\n past: history.past.slice(0, -1),\n present: previous,\n };\n};\n\nconst redo = (history: History): History => {\n const [next, ...rest] = history.future;\n if (next === undefined) {\n return history;\n }\n return {\n future: rest,\n past: [...history.past, history.present].slice(-HISTORY_LIMIT),\n present: next,\n };\n};\n\nexport { canRedo, canUndo, createHistory, dispatch, HISTORY_LIMIT, redo, undo };\nexport type { History };\n","import { assign, setup } from \"xstate\";\n\nimport type { Dashfoo } from \"../model/schema\";\nimport type { Action } from \"../state/actions\";\nimport type { History } from \"../state/history\";\nimport { createHistory, dispatch, redo, undo } from \"../state/history\";\n\ntype DashfooContext = { history: History };\n\ntype DashfooEvent =\n | { action: Action; type: \"DISPATCH\" }\n | { model: Dashfoo; type: \"SET_MODEL\" }\n | { type: \"REDO\" }\n | { type: \"UNDO\" };\n\ntype DashfooInput = { model: Dashfoo };\n\n// The document actor: it owns the undo/redo history (whose `present` is the live\n// model) and processes document mutations by invoking the pure reducer via the\n// history helpers. It has no finite states beyond `ready` — the document is data,\n// not a lifecycle — so every mutation is an event handled with assign.\nconst dashfooMachine = setup({\n types: {\n context: {} as DashfooContext,\n events: {} as DashfooEvent,\n input: {} as DashfooInput,\n },\n}).createMachine({\n context: ({ input }) => ({ history: createHistory(input.model) }),\n id: \"dashfoo\",\n initial: \"ready\",\n states: {\n ready: {\n on: {\n DISPATCH: {\n actions: assign({\n history: ({ context, event }) => dispatch(context.history, event.action),\n }),\n },\n REDO: {\n actions: assign({ history: ({ context }) => redo(context.history) }),\n },\n SET_MODEL: {\n actions: assign({ history: ({ event }) => createHistory(event.model) }),\n },\n UNDO: {\n actions: assign({ history: ({ context }) => undo(context.history) }),\n },\n },\n },\n },\n});\n\nexport { dashfooMachine };\nexport type { DashfooContext, DashfooEvent, DashfooInput };\n","import { assign, emit, setup } from \"xstate\";\n\nimport type { TabNode } from \"../model/schema\";\nimport type { Action, DropIntent } from \"../state/actions\";\n\n// Internal subjects reference a node already in the document; an external\n// subject carries the TabNode to insert on drop (a widget dragged in from\n// outside the layout), so its id never has to exist in the model.\ntype DragSubject =\n | { id: string; kind: \"tab\" | \"tabset\" }\n | { id: string; kind: \"external\"; tab: TabNode };\n\ntype DragContext = { intent: DropIntent | null; subject: DragSubject | null };\n\ntype DragEvent =\n | { intent: DropIntent | null; type: \"OVER\" }\n | { subject: DragSubject; type: \"START\" }\n | { type: \"CANCEL\" }\n | { type: \"DROP\" };\n\ntype DragEmitted = { action: Action; type: \"COMMIT\" };\n\nconst requireDrop = (context: DragContext): { intent: DropIntent; subject: DragSubject } => {\n if (context.subject === null || context.intent === null) {\n throw new Error(\"drop requires a subject and a drop intent\");\n }\n return { intent: context.intent, subject: context.subject };\n};\n\n// The drag/dock interaction lifecycle, driven by abstract events the dnd-kit\n// adapter maps from pointer/keyboard input. It owns transient drag state only and\n// never touches the document — on a valid drop it emits a COMMIT carrying the\n// resulting action (moveNode/moveTabset, or addNode for an external subject),\n// which the React layer forwards to the document machine.\nconst dragDockMachine = setup({\n guards: {\n hasValidDrop: ({ context }) => context.subject !== null && context.intent !== null,\n },\n types: {\n context: {} as DragContext,\n emitted: {} as DragEmitted,\n events: {} as DragEvent,\n },\n}).createMachine({\n context: { intent: null, subject: null },\n id: \"dragDock\",\n initial: \"idle\",\n states: {\n dragging: {\n on: {\n CANCEL: { target: \"idle\" },\n DROP: [\n {\n actions: emit(({ context }) => {\n const { intent, subject } = requireDrop(context);\n const action: Action =\n subject.kind === \"external\"\n ? {\n index: intent.index,\n location: intent.location,\n tab: subject.tab,\n targetId: intent.targetId,\n type: \"addNode\",\n }\n : {\n index: intent.index,\n location: intent.location,\n sourceId: subject.id,\n targetId: intent.targetId,\n type: subject.kind === \"tabset\" ? \"moveTabset\" : \"moveNode\",\n };\n return { action, type: \"COMMIT\" };\n }),\n guard: \"hasValidDrop\",\n target: \"idle\",\n },\n { target: \"idle\" },\n ],\n OVER: { actions: assign({ intent: ({ event }) => event.intent }) },\n },\n },\n idle: {\n entry: assign({ intent: null, subject: null }),\n on: {\n START: { actions: assign({ subject: ({ event }) => event.subject }), target: \"dragging\" },\n },\n },\n },\n});\n\nexport { dragDockMachine };\nexport type { DragContext, DragEmitted, DragEvent, DragSubject };\n","import { normalize } from \"./invariants\";\nimport type { Dashfoo } from \"./schema\";\nimport { dashfooSchema } from \"./schema\";\nimport { findDuplicateIds } from \"./tree\";\n\n// Validate an untrusted value against the schema and return a normalized,\n// canonical model. Throws if the value is not a valid model — including a\n// payload whose `version` is not the pinned `1`; warns (does not throw) on\n// duplicate ids, which corrupt React keys and the plumbing.\nconst parseModel = (value: unknown): Dashfoo => {\n const model = normalize(dashfooSchema.parse(value));\n const duplicates = findDuplicateIds(model);\n if (duplicates.length > 0) {\n // oxlint-disable-next-line no-console\n console.warn(`[dashfoo] duplicate node ids in the loaded layout: ${duplicates.join(\", \")}`);\n }\n return model;\n};\n\nconst toJSON = (model: Dashfoo): string => JSON.stringify(model);\n\nconst fromJSON = (json: string): Dashfoo => parseModel(JSON.parse(json));\n\nexport { fromJSON, parseModel, toJSON };\n","import { normalize } from \"./invariants\";\nimport type { Dashfoo, Orientation, TabsetNode } from \"./schema\";\nimport { collectTabsets } from \"./tree\";\n\n// Flatten any layout into a single row (default a column) of all its tabsets, in\n// document order, each with equal weight, so nothing is lost on a narrow screen;\n// maximize is cleared. The building block for a mobile breakpoint:\n// `stackModel(desktopModel)`.\nconst stackModel = (model: Dashfoo, orientation: Orientation = \"column\"): Dashfoo => {\n // Equal weight so stacked panels share the space evenly. A loop (not map) so we\n // create fresh nodes without mutating the shared input tabsets.\n const children: Array<TabsetNode> = [];\n for (const tabset of collectTabsets(model)) {\n children.push({ ...tabset, weight: 1 });\n }\n\n return normalize({\n ...model,\n layout: {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EAAc,MAAM,CAAK,CAAC,EAC5C,EAAa,EAAiB,CAAK,EAKzC,OAJI,EAAW,OAAS,GAEtB,QAAQ,KAAK,sDAAsD,EAAW,KAAK,IAAI,GAAG,EAErF,CACT,EAEM,GAAU,GAA2B,KAAK,UAAU,CAAK,EAEzD,GAAY,GAA0B,EAAW,KAAK,MAAM,CAAI,CAAC,ECbjE,IAAc,EAAgB,EAA2B,WAAsB,CAGnF,IAAM,EAA8B,CAAC,EACrC,IAAK,IAAM,KAAU,EAAe,CAAK,EACvC,EAAS,KAAK,CAAE,GAAG,EAAQ,OAAQ,CAAE,CAAC,EAGxC,OAAO,EAAU,CACf,GAAG,EACH,OAAQ,CAAE,WAAU,GAAI,EAAM,OAAO,GAAI,cAAa,KAAM,KAAM,EAClE,kBAAmB,IAAA,EACrB,CAAC,CACH"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/model/schema.ts","../src/state/actions.ts","../src/model/ids.ts","../src/model/tree.ts","../src/model/builders.ts","../src/geometry/geometry.ts","../src/geometry/snap.ts","../src/model/invariants.ts","../src/state/surgery.ts","../src/state/floats.ts","../src/state/reducer.ts","../src/state/history.ts","../src/machines/dashfoo-machine.ts","../src/machines/drag-dock-machine.ts","../src/model/serialize.ts","../src/model/stack.ts"],"sourcesContent":["import { z } from \"zod\";\n\n// A JSON-serializable value. Per-tab `config` is validated against this so the\n// model stays losslessly serializable (a function or symbol in config fails).\ntype JsonValue = string | number | boolean | null | Array<JsonValue> | { [key: string]: JsonValue };\n\nconst jsonValueSchema: z.ZodType<JsonValue> = z.lazy(() =>\n z.union([\n z.string(),\n z.number(),\n z.boolean(),\n z.null(),\n z.array(jsonValueSchema),\n z.record(z.string(), jsonValueSchema),\n ]),\n);\n\nconst edgeSchema = z.enum([\"top\", \"bottom\", \"left\", \"right\"]);\nconst unitSchema = z.enum([\"px\", \"%\", \"em\", \"rem\", \"vh\", \"vw\"]);\nconst orientationSchema = z.enum([\"row\", \"column\"]);\n\nconst dimensionSchema = z.object({\n unit: unitSchema,\n value: z.number(),\n});\n\n// Magnetic snap config for split resize. The grid the dragged boundary snaps to is\n// the union of two optional sources: `step` (multiples of a fixed percent) and\n// `divisions` (even splits — multiples of 100/d, where d is the number or, for\n// \"panels\", the row's own child count, so a 3-panel row snaps to thirds and a\n// 4-panel row to quarters). `threshold` is the magnetic grab distance in percent.\n// An empty config (or a `step` of 0 with no `divisions`) disables snapping — used\n// to opt a single row out of an inherited global default.\nconst snapSchema = z.object({\n divisions: z.union([z.number().positive(), z.literal(\"panels\")]).optional(),\n step: z.number().min(0).optional(),\n threshold: z.number().positive().optional(),\n});\n\nconst tabNodeSchema = z.object({\n component: z.string(),\n config: jsonValueSchema.optional(),\n enableClose: z.boolean().optional(),\n enableDrag: z.boolean().optional(),\n enableRename: z.boolean().optional(),\n id: z.string(),\n name: z.string(),\n type: z.literal(\"tab\"),\n});\n\nconst tabsetNodeSchema = z.object({\n children: z.array(tabNodeSchema),\n enableClose: z.boolean().optional(),\n enableMaximize: z.boolean().optional(),\n id: z.string(),\n max: dimensionSchema.optional(),\n min: dimensionSchema.optional(),\n name: z.string().optional(),\n selected: z.number().int(),\n type: z.literal(\"tabset\"),\n weight: z.number().optional(),\n});\n\n// RowNode is recursive (a row may contain rows), so its type is declared\n// explicitly and the schema is built with z.lazy.\ntype RowNode = {\n children: Array<RowNode | z.infer<typeof tabsetNodeSchema>>;\n id: string;\n max?: z.infer<typeof dimensionSchema>;\n min?: z.infer<typeof dimensionSchema>;\n orientation: z.infer<typeof orientationSchema>;\n snap?: z.infer<typeof snapSchema>;\n type: \"row\";\n weight?: number;\n};\n\nconst rowNodeSchema: z.ZodType<RowNode> = z.lazy(() =>\n z.object({\n children: z.array(z.union([rowNodeSchema, tabsetNodeSchema])),\n id: z.string(),\n max: dimensionSchema.optional(),\n min: dimensionSchema.optional(),\n orientation: orientationSchema,\n snap: snapSchema.optional(),\n type: z.literal(\"row\"),\n weight: z.number().optional(),\n }),\n);\n\n// A floating panel's rectangle, in CSS pixels relative to the layout container.\n// Captured when the panel is floated and refreshed as the user drags or resizes\n// it, so the model round-trips the float's position.\nconst geometrySchema = z.object({\n height: z.number(),\n left: z.number(),\n top: z.number(),\n width: z.number(),\n});\n\n// A floating panel: a tabset (or split) lifted out of the docked layout into a\n// draggable, resizable overlay that still lives in the same app. It owns a full\n// RowNode layout (the same shape as the main root), so a float can hold a single\n// tab, several tabs, or nested splits and reuses the exact same rendering.\nconst floatNodeSchema = z.object({\n geometry: geometrySchema,\n id: z.string(),\n layout: rowNodeSchema,\n // Collapsed to a small chip (the window minimized); geometry is preserved so\n // restoring reopens it at its previous rect.\n minimized: z.boolean().optional(),\n name: z.string().optional(),\n type: z.literal(\"float\"),\n});\n\nconst globalAttributesSchema = z.object({\n enableSplitDock: z.boolean().optional(),\n enableSplitResize: z.boolean().optional(),\n snap: snapSchema.optional(),\n splitterSize: z.number().optional(),\n tabEnableClose: z.boolean().optional(),\n tabEnableDrag: z.boolean().optional(),\n tabEnableRename: z.boolean().optional(),\n tabLocation: z.enum([\"top\", \"bottom\"]).optional(),\n tabSetEnableMaximize: z.boolean().optional(),\n tabSetEnableTabStrip: z.boolean().optional(),\n tabSetMinSize: z.number().optional(),\n});\n\nconst dashfooSchema = z.object({\n activeTabsetId: z.string().optional(),\n global: globalAttributesSchema,\n layout: rowNodeSchema,\n maximizedTabsetId: z.string().optional(),\n // The persisted-payload format version, pinned by the schema itself: any\n // future format change bumps the literal, so foreign payloads fail validation.\n version: z.literal(1),\n // Floating panels, each owning its own layout subtree. Optional so existing\n // payloads (and hand-built models) stay valid; absent means \"nothing floating\".\n floats: z.array(floatNodeSchema).optional(),\n});\n\ntype Json = JsonValue;\ntype Edge = z.infer<typeof edgeSchema>;\ntype Unit = z.infer<typeof unitSchema>;\ntype Orientation = z.infer<typeof orientationSchema>;\ntype Dimension = z.infer<typeof dimensionSchema>;\ntype SnapConfig = z.infer<typeof snapSchema>;\ntype TabNode = z.infer<typeof tabNodeSchema>;\ntype TabsetNode = z.infer<typeof tabsetNodeSchema>;\ntype Geometry = z.infer<typeof geometrySchema>;\ntype FloatNode = z.infer<typeof floatNodeSchema>;\ntype GlobalAttributes = z.infer<typeof globalAttributesSchema>;\ntype Dashfoo = z.infer<typeof dashfooSchema>;\ntype Node = RowNode | TabsetNode | TabNode;\n\nexport {\n dashfooSchema,\n dimensionSchema,\n edgeSchema,\n floatNodeSchema,\n geometrySchema,\n globalAttributesSchema,\n jsonValueSchema,\n orientationSchema,\n rowNodeSchema,\n snapSchema,\n tabNodeSchema,\n tabsetNodeSchema,\n unitSchema,\n};\n\nexport type {\n Dashfoo,\n Dimension,\n Edge,\n FloatNode,\n Geometry,\n GlobalAttributes,\n Json,\n Node,\n Orientation,\n RowNode,\n SnapConfig,\n TabNode,\n TabsetNode,\n Unit,\n};\n","import { z } from \"zod\";\n\nimport {\n dimensionSchema,\n geometrySchema,\n globalAttributesSchema,\n orientationSchema,\n snapSchema,\n tabNodeSchema,\n tabsetNodeSchema,\n} from \"../model/schema\";\n\nconst mutableTabAttrsSchema = tabNodeSchema\n .pick({\n config: true,\n enableClose: true,\n enableDrag: true,\n enableRename: true,\n name: true,\n })\n .partial();\n\nconst mutableTabsetAttrsSchema = tabsetNodeSchema\n .pick({\n enableClose: true,\n enableMaximize: true,\n max: true,\n min: true,\n selected: true,\n weight: true,\n })\n .partial();\n\nconst mutableRowAttrsSchema = z\n .object({\n max: dimensionSchema.optional(),\n min: dimensionSchema.optional(),\n orientation: orientationSchema,\n snap: snapSchema.optional(),\n weight: z.number(),\n })\n .partial();\n\nconst mutableNodeAttrsSchema = z.union([\n mutableTabAttrsSchema,\n mutableTabsetAttrsSchema,\n mutableRowAttrsSchema,\n]);\n\n// Every document mutation is one of these immutable, discriminated actions. The\n// reducer is exhaustive over this union; the React layer validates untrusted\n// payloads against actionSchema before dispatch.\nconst dockLocationSchema = z.enum([\n \"center\",\n \"split-bottom\",\n \"split-left\",\n \"split-right\",\n \"split-top\",\n]);\n\nconst actionSchema = z.discriminatedUnion(\"type\", [\n z.object({\n index: z.number().int().optional(),\n location: dockLocationSchema,\n tab: tabNodeSchema,\n targetId: z.string(),\n type: z.literal(\"addNode\"),\n }),\n z.object({\n index: z.number().int().optional(),\n location: dockLocationSchema,\n sourceId: z.string(),\n targetId: z.string(),\n type: z.literal(\"moveNode\"),\n }),\n z.object({\n index: z.number().int().optional(),\n location: dockLocationSchema,\n sourceId: z.string(),\n targetId: z.string(),\n type: z.literal(\"moveTabset\"),\n }),\n z.object({ index: z.number().int(), tabsetId: z.string(), type: z.literal(\"selectTab\") }),\n z.object({ tabsetId: z.string(), type: z.literal(\"setActiveTabset\") }),\n z.object({ tabsetId: z.string().nullable(), type: z.literal(\"setMaximizedTabset\") }),\n z.object({ name: z.string(), tabId: z.string(), type: z.literal(\"renameTab\") }),\n z.object({ tabId: z.string(), type: z.literal(\"deleteTab\") }),\n z.object({ tabsetId: z.string(), type: z.literal(\"deleteTabset\") }),\n z.object({\n rowId: z.string(),\n type: z.literal(\"adjustSplit\"),\n weights: z.array(z.number()),\n }),\n z.object({\n attrs: mutableNodeAttrsSchema,\n nodeId: z.string(),\n type: z.literal(\"updateNodeAttributes\"),\n }),\n z.object({ attrs: globalAttributesSchema.partial(), type: z.literal(\"updateGlobalAttributes\") }),\n // Float a single tab out of its tabset into a new floating panel. `geometry` is\n // the float's initial in-app rect; `floatId` lets the caller mint the id so the\n // model node and any UI tracking it agree.\n z.object({\n floatId: z.string().optional(),\n geometry: geometrySchema.optional(),\n tabId: z.string(),\n type: z.literal(\"floatTab\"),\n }),\n // Float a whole tabset (with all its tabs) into a new floating panel.\n z.object({\n floatId: z.string().optional(),\n geometry: geometrySchema.optional(),\n tabsetId: z.string(),\n type: z.literal(\"floatTabset\"),\n }),\n // Dock a floating panel's tabs back into the main layout, then drop the float.\n // `targetId`/`location` default to the active main tabset, center.\n z.object({\n floatId: z.string(),\n location: dockLocationSchema.optional(),\n targetId: z.string().optional(),\n type: z.literal(\"dockFloat\"),\n }),\n // Persist a float's rect as the user drags or resizes it.\n z.object({\n floatId: z.string(),\n geometry: geometrySchema,\n type: z.literal(\"moveFloat\"),\n }),\n // Collapse a float to a chip (minimized: true) or restore it (false).\n z.object({\n floatId: z.string(),\n minimized: z.boolean(),\n type: z.literal(\"setFloatMinimized\"),\n }),\n // Rename a floating panel (its window title).\n z.object({\n floatId: z.string(),\n name: z.string(),\n type: z.literal(\"renameFloat\"),\n }),\n]);\n\ntype DockLocation = z.infer<typeof dockLocationSchema>;\ntype MutableNodeAttrs = z.infer<typeof mutableNodeAttrsSchema>;\ntype Action = z.infer<typeof actionSchema>;\n\n// Where a drag will land: the dock location, the target tabset, and (for a tab\n// stack) the slot index. Co-located with DockLocation; the drag machine and the\n// React adapter both consume it.\ntype DropIntent = { index?: number; location: DockLocation; targetId: string };\n\nexport { actionSchema, dockLocationSchema, mutableNodeAttrsSchema };\nexport type { Action, DockLocation, DropIntent, MutableNodeAttrs };\n","// Unique ids for nodes and tabs. The reducer uses these for split/dock surgery;\n// they are public so consumers building addNode/moveNode payloads (or seed\n// models) have one blessed generator instead of rolling their own.\nconst createNodeId = (prefix = \"node\"): string => `${prefix}-${crypto.randomUUID()}`;\n\nconst createTabId = (): string => createNodeId(\"tab\");\n\nexport { createNodeId, createTabId };\n","import type { Dashfoo, FloatNode, RowNode, TabNode, TabsetNode } from \"./schema\";\n\n// A tab lives inside a tabset.\ntype TabContainer = TabsetNode;\ntype TabLocation = { container: TabContainer; index: number; tab: TabNode };\n\n// Every layout root: the main layout first, then each floating panel's layout.\n// Traversals fan out over this so a floated tabset is as reachable as a docked\n// one; \"first\" semantics (active tabset fallbacks) prefer the main layout.\nconst collectRoots = (model: Dashfoo): Array<RowNode> => [\n model.layout,\n ...(model.floats ?? []).map((float) => float.layout),\n];\n\nconst findFloat = (model: Dashfoo, floatId: string): FloatNode | undefined =>\n (model.floats ?? []).find((float) => float.id === floatId);\n\nconst collectTabsetsInRow = (row: RowNode, acc: Array<TabsetNode>): void => {\n for (const child of row.children) {\n if (child.type === \"tabset\") {\n acc.push(child);\n } else {\n collectTabsetsInRow(child, acc);\n }\n }\n};\n\n// Every tabset across all roots (main layout + windows), depth-first.\nconst collectTabsets = (model: Dashfoo): Array<TabsetNode> => {\n const acc: Array<TabsetNode> = [];\n for (const root of collectRoots(model)) {\n collectTabsetsInRow(root, acc);\n }\n return acc;\n};\n\nconst getFirstTabset = (model: Dashfoo): TabsetNode | undefined => collectTabsets(model)[0];\n\nconst findTabset = (model: Dashfoo, tabsetId: string): TabsetNode | undefined =>\n collectTabsets(model).find((tabset) => tabset.id === tabsetId);\n\nconst findTabInContainer = (container: TabContainer, tabId: string): TabLocation | undefined => {\n const index = container.children.findIndex((tab) => tab.id === tabId);\n if (index === -1) {\n return undefined;\n }\n\n const tab = container.children[index];\n if (!tab) {\n return undefined;\n }\n\n return { container, index, tab };\n};\n\n// Locate a tab anywhere in the model — searching every tabset — returning the\n// tab, its container, and its index within that container.\nconst findTab = (model: Dashfoo, tabId: string): TabLocation | undefined => {\n for (const tabset of collectTabsets(model)) {\n const found = findTabInContainer(tabset, tabId);\n if (found) {\n return found;\n }\n }\n\n return undefined;\n};\n\ntype AttributedNode = RowNode | TabNode | TabsetNode;\n\n// Find a row anywhere in the layout tree by id.\nconst findRow = (row: RowNode, id: string): RowNode | undefined => {\n if (row.id === id) {\n return row;\n }\n for (const child of row.children) {\n if (child.type === \"row\") {\n const found = findRow(child, id);\n if (found) {\n return found;\n }\n }\n }\n return undefined;\n};\n\nconst findAttributedNodeInRow = (row: RowNode, id: string): AttributedNode | undefined => {\n if (row.id === id) {\n return row;\n }\n for (const child of row.children) {\n if (child.type === \"row\") {\n const found = findAttributedNodeInRow(child, id);\n if (found) {\n return found;\n }\n continue;\n }\n if (child.id === id) {\n return child;\n }\n // Single-id recursive search invoked once per lookup over small layout\n // trees — building a Map per call would cost more than it saves.\n // oxlint-disable-next-line react-doctor/js-index-maps\n const tab = child.children.find((candidate) => candidate.id === id);\n if (tab) {\n return tab;\n }\n }\n return undefined;\n};\n\n// Locate any attributed node (row, tabset, or tab) by id — backs updateNodeAttributes.\nconst findAttributedNode = (model: Dashfoo, id: string): AttributedNode | undefined => {\n for (const root of collectRoots(model)) {\n const found = findAttributedNodeInRow(root, id);\n if (found) {\n return found;\n }\n }\n return undefined;\n};\n\n// The root row (main layout or a float's layout) whose subtree contains the\n// node. Lets the reducer run root-relative surgery (findRow, findTabsetParent,\n// removeTabset) against the correct tree instead of assuming the main layout.\nconst findRootContaining = (model: Dashfoo, nodeId: string): RowNode | undefined => {\n for (const root of collectRoots(model)) {\n if (findAttributedNodeInRow(root, nodeId)) {\n return root;\n }\n }\n return undefined;\n};\n\n// The row holding a tabset, and the tabset's index within it — backs split placement.\nconst findTabsetParent = (\n row: RowNode,\n tabsetId: string,\n): { index: number; parent: RowNode } | undefined => {\n const index = row.children.findIndex((child) => child.type === \"tabset\" && child.id === tabsetId);\n if (index !== -1) {\n return { index, parent: row };\n }\n for (const child of row.children) {\n if (child.type === \"row\") {\n const found = findTabsetParent(child, tabsetId);\n if (found) {\n return found;\n }\n }\n }\n return undefined;\n};\n\nconst collectIdsInRow = (row: RowNode, acc: Array<string>): void => {\n acc.push(row.id);\n for (const child of row.children) {\n if (child.type === \"row\") {\n collectIdsInRow(child, acc);\n } else {\n acc.push(child.id);\n for (const tab of child.children) {\n acc.push(tab.id);\n }\n }\n }\n};\n\n// Ids that appear more than once across the whole model (rows, tabsets, tabs).\n// Duplicate ids produce duplicate React keys and corrupt the resize/drag\n// plumbing, so this backs a load-time diagnostic.\nconst findDuplicateIds = (model: Dashfoo): Array<string> => {\n const ids: Array<string> = [];\n for (const float of model.floats ?? []) {\n ids.push(float.id);\n }\n for (const root of collectRoots(model)) {\n collectIdsInRow(root, ids);\n }\n const seen = new Set<string>();\n const duplicates = new Set<string>();\n for (const id of ids) {\n if (seen.has(id)) {\n duplicates.add(id);\n }\n seen.add(id);\n }\n return [...duplicates];\n};\n\nexport {\n collectRoots,\n collectTabsets,\n collectTabsetsInRow,\n findAttributedNode,\n findDuplicateIds,\n findFloat,\n findRootContaining,\n findRow,\n findTab,\n findTabset,\n findTabsetParent,\n getFirstTabset,\n};\nexport type { AttributedNode, TabContainer, TabLocation };\n","// Ergonomic constructors for the layout model, so consumers seed a Dashfoo\n// without hand-writing `type`/`version`/`selected` boilerplate or nested\n// literals. Every builder fills the required-but-mechanical fields and leaves\n// the meaningful ones (ids that get referenced, weights) to the caller. Output\n// is schema-valid by construction; id uniqueness across reused components is\n// the caller's responsibility (tabs default their id to the component name), so\n// `model` warns once if it detects duplicate node ids.\n\nimport { createNodeId } from \"./ids\";\nimport type {\n Dashfoo,\n Dimension,\n FloatNode,\n Geometry,\n GlobalAttributes,\n Json,\n RowNode,\n SnapConfig,\n TabNode,\n TabsetNode,\n} from \"./schema\";\nimport { findDuplicateIds } from \"./tree\";\n\nconst toDimension = (value: number | Dimension): Dimension =>\n typeof value === \"number\" ? { unit: \"px\", value } : value;\n\ntype TabOptions = {\n config?: Json;\n enableClose?: boolean;\n enableDrag?: boolean;\n enableRename?: boolean;\n id?: string;\n};\n\n// The id defaults to the component name — the common case where a layout holds\n// one tab per component and references it by that name.\nconst tab = (component: string, name: string, options: TabOptions = {}): TabNode => ({\n component,\n name,\n type: \"tab\",\n ...options,\n id: options.id ?? component,\n});\n\ntype TabsetOptions = {\n enableClose?: boolean;\n enableMaximize?: boolean;\n id?: string;\n max?: number | Dimension;\n min?: number | Dimension;\n name?: string;\n selected?: number;\n weight?: number;\n};\n\nconst tabset = (children: Array<TabNode>, options: TabsetOptions = {}): TabsetNode => {\n const { max, min, ...rest } = options;\n return {\n children,\n type: \"tabset\",\n ...rest,\n ...(max === undefined ? {} : { max: toDimension(max) }),\n ...(min === undefined ? {} : { min: toDimension(min) }),\n id: options.id ?? createNodeId(\"tabset\"),\n selected: options.selected ?? 0,\n };\n};\n\ntype RowOptions = {\n id?: string;\n max?: number | Dimension;\n min?: number | Dimension;\n orientation?: RowNode[\"orientation\"];\n snap?: SnapConfig;\n weight?: number;\n};\n\nconst row = (children: RowNode[\"children\"], options: RowOptions = {}): RowNode => {\n const { max, min, ...rest } = options;\n return {\n children,\n type: \"row\",\n ...rest,\n ...(max === undefined ? {} : { max: toDimension(max) }),\n ...(min === undefined ? {} : { min: toDimension(min) }),\n id: options.id ?? createNodeId(\"row\"),\n orientation: options.orientation ?? \"row\",\n };\n};\n\ntype FloatOptions = {\n id?: string;\n name?: string;\n};\n\n// A floating panel wrapping a layout subtree at a given in-app rect.\nconst floatNode = (layout: RowNode, geometry: Geometry, options: FloatOptions = {}): FloatNode => ({\n geometry,\n layout,\n type: \"float\",\n ...options,\n id: options.id ?? createNodeId(\"float\"),\n});\n\ntype ModelOptions = {\n activeTabsetId?: string;\n floats?: Array<FloatNode>;\n global?: GlobalAttributes;\n maximizedTabsetId?: string;\n};\n\nconst model = (layout: RowNode, options: ModelOptions = {}): Dashfoo => {\n const built: Dashfoo = {\n layout,\n version: 1,\n ...options,\n global: options.global ?? {},\n };\n const duplicates = findDuplicateIds(built);\n if (duplicates.length > 0) {\n // oxlint-disable-next-line no-console\n console.warn(\n `[dashfoo] builder produced duplicate node ids: ${duplicates.join(\", \")} — pass explicit ids when reusing a component`,\n );\n }\n return built;\n};\n\nexport { floatNode, model, row, tab, tabset };\nexport type { FloatOptions, ModelOptions, RowOptions, TabOptions, TabsetOptions };\n","import type { Edge } from \"../model/schema\";\nimport type { DockLocation } from \"../state/actions\";\n\ntype Point = { x: number; y: number };\ntype Rect = { height: number; width: number; x: number; y: number };\ntype DockTarget = { kind: \"tab\" } | { edge: Edge; kind: \"split\" };\ntype BandOptions = { bandFraction?: number };\ntype DockZone = { location: DockLocation; points: Array<Point> };\n\n// Shared by resolveDockTarget and dockZonePolygons so the painted map and the\n// live hit-test can never disagree on where the edge bands end.\nconst DEFAULT_BAND_FRACTION = 0.22;\n\n// Fractional distance of the pointer from each of the four edges of a rect.\nconst edgeDistances = (\n pointer: Point,\n rect: Rect,\n): { bottom: number; left: number; right: number; top: number } => {\n const fx = (pointer.x - rect.x) / rect.width;\n const fy = (pointer.y - rect.y) / rect.height;\n return { bottom: 1 - fy, left: fx, right: 1 - fx, top: fy };\n};\n\nconst closestEdge = (d: { bottom: number; left: number; right: number; top: number }): Edge => {\n const min = Math.min(d.left, d.right, d.top, d.bottom);\n if (min === d.left) {\n return \"left\";\n }\n if (min === d.right) {\n return \"right\";\n }\n if (min === d.top) {\n return \"top\";\n }\n return \"bottom\";\n};\n\n// Where a drag dropped over a tabset should land: stacked as a tab when the\n// pointer is in the center, or splitting the tabset when it is within an outer\n// band (default 22%) of one of the four edges — the closer edge wins in corners.\nconst resolveDockTarget = (pointer: Point, rect: Rect, opts?: BandOptions): DockTarget => {\n const band = opts?.bandFraction ?? DEFAULT_BAND_FRACTION;\n // a zero-size tabset has no meaningful edges; dividing by its width/height\n // yields NaN distances that would silently resolve to a bogus split.\n if (rect.width <= 0 || rect.height <= 0) {\n return { kind: \"tab\" };\n }\n const distances = edgeDistances(pointer, rect);\n const min = Math.min(distances.left, distances.right, distances.top, distances.bottom);\n\n if (min > band) {\n return { kind: \"tab\" };\n }\n return { edge: closestEdge(distances), kind: \"split\" };\n};\n\n// The full hit-region partition of a tabset for resolveDockTarget: four edge\n// trapezoids and the inner center rect. Seams between adjacent edge zones sit\n// where the fractional edge distances tie — straight diagonals from each rect\n// corner to the matching inner-rect corner — so the map is an exact picture of\n// which location a pointer anywhere over the rect resolves to. A zero-size rect\n// collapses to a single center polygon, mirroring resolveDockTarget's fallback.\nconst dockZonePolygons = (rect: Rect, opts?: BandOptions): Array<DockZone> => {\n const { height: h, width: w, x, y } = rect;\n const nw: Point = { x, y };\n const ne: Point = { x: x + w, y };\n const se: Point = { x: x + w, y: y + h };\n const sw: Point = { x, y: y + h };\n if (w <= 0 || h <= 0) {\n return [{ location: \"center\", points: [nw, ne, se, sw] }];\n }\n const band = opts?.bandFraction ?? DEFAULT_BAND_FRACTION;\n const bx = band * w;\n const by = band * h;\n const innerNw: Point = { x: x + bx, y: y + by };\n const innerNe: Point = { x: x + w - bx, y: y + by };\n const innerSe: Point = { x: x + w - bx, y: y + h - by };\n const innerSw: Point = { x: x + bx, y: y + h - by };\n return [\n { location: \"center\", points: [innerNw, innerNe, innerSe, innerSw] },\n { location: \"split-left\", points: [nw, innerNw, innerSw, sw] },\n { location: \"split-right\", points: [ne, se, innerSe, innerNe] },\n { location: \"split-top\", points: [nw, ne, innerNe, innerNw] },\n { location: \"split-bottom\", points: [sw, innerSw, innerSe, se] },\n ];\n};\n\n// The region the dock indicator highlights for a given location over a tabset:\n// the whole tabset for a center stack, the matching half for a split.\nconst zoneRect = (rect: Rect, location: DockLocation): Rect => {\n const halfW = rect.width / 2;\n const halfH = rect.height / 2;\n switch (location) {\n case \"split-bottom\": {\n return { height: halfH, width: rect.width, x: rect.x, y: rect.y + halfH };\n }\n case \"split-left\": {\n return { height: rect.height, width: halfW, x: rect.x, y: rect.y };\n }\n case \"split-right\": {\n return { height: rect.height, width: halfW, x: rect.x + halfW, y: rect.y };\n }\n case \"split-top\": {\n return { height: halfH, width: rect.width, x: rect.x, y: rect.y };\n }\n default: {\n return rect;\n }\n }\n};\n\nexport { dockZonePolygons, resolveDockTarget, zoneRect };\nexport type { BandOptions, DockTarget, DockZone, Point, Rect };\n","import type { SnapConfig } from \"../model/schema\";\n\n// Magnetic snapping for split resize. Pure math over ordered percentage arrays\n// (sizes sum to ~100) so the engine stays framework-free; the React adapter maps\n// rrp's id-keyed layout to/from these arrays. The dragged boundary index is passed\n// in rather than inferred, so a cascading min-size resize can't fool the snap onto\n// the wrong boundary.\n\nconst DEFAULT_SNAP_THRESHOLD = 4;\n// Round grid positions so equal targets from different sources (step 25 vs\n// divisions 4) dedupe and float drift (100/3) compares cleanly.\nconst TARGET_PRECISION = 1e6;\n\nconst addMultiples = (targets: Set<number>, increment: number): void => {\n if (increment <= 0) {\n return;\n }\n for (let position = increment; position < 100; position += increment) {\n const rounded = Math.round(position * TARGET_PRECISION) / TARGET_PRECISION;\n if (rounded < 100) {\n targets.add(rounded);\n }\n }\n};\n\n// The grid the boundary can snap to: the union of the fixed `step` grid and the\n// even-`divisions` grid (multiples of 100/d, where d is the number or, for\n// \"panels\", the row's panel count). Positions strictly inside 0..100.\nconst resolveSnapTargets = (config: SnapConfig, panelCount: number): Array<number> => {\n const targets = new Set<number>();\n if (config.step !== undefined && config.step > 0) {\n addMultiples(targets, config.step);\n }\n if (config.divisions !== undefined) {\n const divisions = config.divisions === \"panels\" ? panelCount : config.divisions;\n if (divisions >= 2) {\n addMultiples(targets, 100 / divisions);\n }\n }\n return [...targets].toSorted((a, b) => a - b);\n};\n\n// Whether a config produces any snap grid at all — used to gate the resize\n// listeners so a non-snapping layout pays nothing per pointer move.\nconst snapEnabled = (config: SnapConfig | null): boolean =>\n config !== null &&\n ((config.step ?? 0) > 0 ||\n config.divisions === \"panels\" ||\n (typeof config.divisions === \"number\" && config.divisions >= 2));\n\nconst nearestTarget = (position: number, targets: Array<number>): number | undefined =>\n targets.reduce<number | undefined>((best, target) => {\n if (best === undefined || Math.abs(target - position) < Math.abs(best - position)) {\n return target;\n }\n return best;\n }, undefined);\n\ntype SnapResult = { sizes: Array<number>; snapped: boolean };\n\n// Snap the dragged boundary (between panel `boundaryIndex` and the next) to the\n// nearest grid target within the threshold, moving only that pair so siblings keep\n// their sizes. Returns the input unchanged when snapping is off, nothing is within\n// reach, the index is out of range, or the correction would drive a panel negative\n// (rrp re-clamps real px minimums on the next frame).\nconst snapSizes = (sizes: Array<number>, boundaryIndex: number, config: SnapConfig): SnapResult => {\n const threshold = config.threshold ?? DEFAULT_SNAP_THRESHOLD;\n const left = sizes[boundaryIndex];\n const right = sizes[boundaryIndex + 1];\n if (boundaryIndex < 0 || left === undefined || right === undefined) {\n return { sizes, snapped: false };\n }\n\n const targets = resolveSnapTargets(config, sizes.length);\n if (targets.length === 0) {\n return { sizes, snapped: false };\n }\n\n let position = 0;\n for (let index = 0; index <= boundaryIndex; index++) {\n position += sizes[index] ?? 0;\n }\n\n const target = nearestTarget(position, targets);\n if (target === undefined || Math.abs(target - position) > threshold) {\n return { sizes, snapped: false };\n }\n\n const delta = target - position;\n if (left + delta < 0 || right - delta < 0) {\n return { sizes, snapped: false };\n }\n\n const next = [...sizes];\n next[boundaryIndex] = left + delta;\n next[boundaryIndex + 1] = right - delta;\n return { sizes: next, snapped: true };\n};\n\nexport { DEFAULT_SNAP_THRESHOLD, resolveSnapTargets, snapEnabled, snapSizes };\nexport type { SnapResult };\n","import type { Dashfoo, FloatNode, RowNode, TabsetNode } from \"./schema\";\nimport { collectTabsets } from \"./tree\";\n\nconst clampSelected = (length: number, selected: number): number => {\n if (length === 0) {\n return 0;\n }\n // coerce to a non-negative integer first to match the schema's z.number().int():\n // a persisted 1.5 or NaN must not survive as a fractional/NaN index.\n const base = Number.isFinite(selected) ? Math.trunc(selected) : 0;\n if (base < 0) {\n return 0;\n }\n if (base > length - 1) {\n return length - 1;\n }\n return base;\n};\n\nconst normalizeTabset = (tabset: TabsetNode): TabsetNode => ({\n ...tabset,\n selected: clampSelected(tabset.children.length, tabset.selected),\n});\n\n// Drop empty tabsets and empty rows, recurse into child rows, and simplify a\n// single-child row by lifting its lone child (which inherits the lifted row's\n// weight so sizing is preserved).\nconst normalizeRowChildren = (children: RowNode[\"children\"]): RowNode[\"children\"] => {\n const out: RowNode[\"children\"] = [];\n\n for (const child of children) {\n if (child.type === \"tabset\") {\n if (child.children.length > 0) {\n out.push(normalizeTabset(child));\n }\n continue;\n }\n\n const grandchildren = normalizeRowChildren(child.children);\n if (grandchildren.length === 0) {\n continue;\n }\n if (grandchildren.length === 1) {\n const only = grandchildren[0];\n if (only !== undefined) {\n out.push(child.weight === undefined ? only : { ...only, weight: child.weight });\n }\n continue;\n }\n out.push({ ...child, children: grandchildren });\n }\n\n return out;\n};\n\nconst rowContainsTabset = (row: RowNode): boolean =>\n row.children.some((child) => (child.type === \"tabset\" ? true : rowContainsTabset(child)));\n\n// The root is always a row; if it reduces to a single child that is itself a\n// row, absorb that row (adopt its children + orientation) to avoid redundant\n// nesting.\nconst normalizeLayout = (root: RowNode): RowNode => {\n let children = normalizeRowChildren(root.children);\n let orientation = root.orientation;\n\n let inner = children[0];\n while (children.length === 1 && inner?.type === \"row\") {\n children = inner.children;\n orientation = inner.orientation;\n inner = children[0];\n }\n\n return { ...root, children, orientation };\n};\n\n// Self-healing pass run after every action so the tree stays canonical: no empty\n// tabsets or rows, no redundant single-child rows, selected indices in range,\n// and active/maximized ids that always point at an existing tabset.\nconst normalize = (model: Dashfoo): Dashfoo => {\n const layout = normalizeLayout(model.layout);\n\n // Heal each float's own layout, then drop any float that emptied out (its last\n // tab closed/moved away) — the float equivalent of empty-tabset cleanup.\n const healedFloats: Array<FloatNode> = [];\n for (const float of model.floats ?? []) {\n const floatLayout = normalizeLayout(float.layout);\n if (rowContainsTabset(floatLayout)) {\n healedFloats.push({ ...float, layout: floatLayout });\n }\n }\n const floats = healedFloats.length > 0 ? healedFloats : undefined;\n\n const withRoots: Dashfoo = { ...model, floats, layout };\n\n const tabsetIds = new Set(collectTabsets(withRoots).map((tabset) => tabset.id));\n const firstTabsetId = collectTabsets(withRoots)[0]?.id;\n\n const activeTabsetId =\n model.activeTabsetId !== undefined && tabsetIds.has(model.activeTabsetId)\n ? model.activeTabsetId\n : firstTabsetId;\n\n const maximizedTabsetId =\n model.maximizedTabsetId !== undefined && tabsetIds.has(model.maximizedTabsetId)\n ? model.maximizedTabsetId\n : undefined;\n\n return { ...withRoots, activeTabsetId, maximizedTabsetId };\n};\n\nexport { normalize };\n","import { createNodeId } from \"../model/ids\";\nimport type { Dashfoo, RowNode, TabNode, TabsetNode } from \"../model/schema\";\nimport { findRootContaining, findTabset, findTabsetParent } from \"../model/tree\";\n\nimport type { DockLocation } from \"./actions\";\n\n// In-place tree-surgery helpers shared by the reducer and the float operations:\n// removing/placing tabsets and tabs across any root. Each mutates the draft model\n// the reducer deep-cloned, so they never touch the caller's input.\n\nconst removeTabset = (row: RowNode, tabsetId: string): boolean => {\n const index = row.children.findIndex((child) => child.type === \"tabset\" && child.id === tabsetId);\n if (index !== -1) {\n row.children.splice(index, 1);\n return true;\n }\n for (const child of row.children) {\n if (child.type === \"row\" && removeTabset(child, tabsetId)) {\n return true;\n }\n }\n return false;\n};\n\n// Detach a tabset from the tree and return it (for moving a whole tabset).\nconst removeTabsetReturning = (row: RowNode, tabsetId: string): TabsetNode | undefined => {\n const index = row.children.findIndex((child) => child.type === \"tabset\" && child.id === tabsetId);\n if (index !== -1) {\n const [removed] = row.children.splice(index, 1);\n return removed?.type === \"tabset\" ? removed : undefined;\n }\n for (const child of row.children) {\n if (child.type === \"row\") {\n const found = removeTabsetReturning(child, tabsetId);\n if (found) {\n return found;\n }\n }\n }\n return undefined;\n};\n\nconst splitOrientation = (location: DockLocation): \"column\" | \"row\" =>\n location === \"split-left\" || location === \"split-right\" ? \"row\" : \"column\";\n\nconst splitsBefore = (location: DockLocation): boolean =>\n location === \"split-left\" || location === \"split-top\";\n\n// Place an (already-detached) tabset beside the target for a split-* location:\n// reuse the parent row when the orientation already matches, else wrap the target\n// in a new row. Shared by insertTab (a fresh tabset), moveTabset (an existing one),\n// and dockFloat. Splits the target's space in half.\nconst placeBesideTarget = (\n draft: Dashfoo,\n placed: TabsetNode,\n targetId: string,\n location: DockLocation,\n): void => {\n const targetTabset = findTabset(draft, targetId);\n // Operate within whichever root holds the target (main layout or a float), so a\n // split docked inside a floated panel stays in that float.\n const targetRoot = findRootContaining(draft, targetId) ?? draft.layout;\n const found = findTabsetParent(targetRoot, targetId);\n if (!targetTabset || !found) {\n return;\n }\n\n const orientation = splitOrientation(location);\n const before = splitsBefore(location);\n\n if (found.parent.orientation === orientation) {\n const targetWeight = targetTabset.weight ?? 100;\n targetTabset.weight = targetWeight / 2;\n placed.weight = targetWeight / 2;\n found.parent.children.splice(before ? found.index : found.index + 1, 0, placed);\n } else {\n const targetWeight = targetTabset.weight;\n targetTabset.weight = 50;\n placed.weight = 50;\n const newRow: RowNode = {\n children: before ? [placed, targetTabset] : [targetTabset, placed],\n id: createNodeId(\"row\"),\n orientation,\n type: \"row\",\n };\n if (targetWeight !== undefined) {\n newRow.weight = targetWeight;\n }\n found.parent.children.splice(found.index, 1, newRow);\n }\n\n draft.activeTabsetId = placed.id;\n};\n\n// Insert a tab into the model at a dock target. center stacks it into the target\n// tabset; split-* creates a new tabset beside the target.\ntype DropTarget = { id: string; index?: number; location: DockLocation };\n\nconst insertTab = (draft: Dashfoo, tab: TabNode, target: DropTarget): void => {\n const { id: targetId, index, location } = target;\n const targetTabset = findTabset(draft, targetId);\n if (!targetTabset) {\n return;\n }\n\n if (location === \"center\") {\n const at = index ?? targetTabset.children.length;\n targetTabset.children.splice(at, 0, tab);\n targetTabset.selected = at;\n return;\n }\n\n const newTabset: TabsetNode = {\n children: [tab],\n id: createNodeId(\"tabset\"),\n selected: 0,\n type: \"tabset\",\n weight: 50,\n };\n placeBesideTarget(draft, newTabset, targetId, location);\n};\n\nconst tabsetsInRow = (row: RowNode, acc: Array<TabsetNode>): void => {\n for (const child of row.children) {\n if (child.type === \"tabset\") {\n acc.push(child);\n } else {\n tabsetsInRow(child, acc);\n }\n }\n};\n\n// Wrap a detached node in the row → tabset scaffolding a float's layout needs.\nconst wrapTabInLayout = (tab: TabNode): RowNode => ({\n children: [{ children: [tab], id: createNodeId(\"tabset\"), selected: 0, type: \"tabset\" }],\n id: createNodeId(\"row\"),\n orientation: \"row\",\n type: \"row\",\n});\n\nconst wrapTabsetInLayout = (tabset: TabsetNode): RowNode => ({\n children: [tabset],\n id: createNodeId(\"row\"),\n orientation: \"row\",\n type: \"row\",\n});\n\nexport {\n insertTab,\n placeBesideTarget,\n removeTabset,\n removeTabsetReturning,\n tabsetsInRow,\n wrapTabInLayout,\n wrapTabsetInLayout,\n};\nexport type { DropTarget };\n","import { createNodeId } from \"../model/ids\";\nimport type { Dashfoo, FloatNode, Geometry, RowNode, TabsetNode } from \"../model/schema\";\nimport { findRootContaining } from \"../model/tree\";\n\nimport type { DockLocation } from \"./actions\";\nimport {\n placeBesideTarget,\n removeTabsetReturning,\n tabsetsInRow,\n wrapTabsetInLayout,\n} from \"./surgery\";\n\n// Float operations: floating a tabset out, docking it back, and naming. Floats are\n// a second set of roots, so these lean on the same surgery helpers as the main\n// layout. Split out of the reducer to keep each file focused (and under the cap).\n\n// Default float rect when the caller doesn't measure the source (e.g. a\n// programmatic float). The React layer normally supplies a rect over the panel.\nconst DEFAULT_FLOAT_GEOMETRY: Geometry = { height: 360, left: 80, top: 80, width: 480 };\n\n// A unique window name: `base` if free among the floats, else `base 1`, `base 2`, …\n// Floats are auto-named \"Panel\" and renames are deduped through this, so two floats\n// never share a title.\nconst uniqueFloatName = (base: string, floats: Array<FloatNode>): string => {\n const used = new Set(floats.map((float) => float.name));\n if (!used.has(base)) {\n return base;\n }\n let index = 1;\n while (used.has(`${base} ${index}`)) {\n index += 1;\n }\n return `${base} ${index}`;\n};\n\n// Append a new floating panel holding `layout`, and move focus to its first tabset\n// so active-tabset/keyboard logic tracks the floated panel. `floatId` is supplied\n// when the caller minted the id up front, so the model node and any UI agree.\nconst pushFloat = (\n draft: Dashfoo,\n layout: RowNode,\n geometry: Geometry | undefined,\n floatId: string | undefined,\n): void => {\n const float: FloatNode = {\n geometry: geometry ?? DEFAULT_FLOAT_GEOMETRY,\n id: floatId ?? createNodeId(\"float\"),\n layout,\n name: uniqueFloatName(\"Panel\", draft.floats ?? []),\n type: \"float\",\n };\n draft.floats = [...(draft.floats ?? []), float];\n\n const tabsets: Array<TabsetNode> = [];\n tabsetsInRow(layout, tabsets);\n const first = tabsets[0];\n if (first) {\n draft.activeTabsetId = first.id;\n }\n};\n\nconst floatTabsetById = (\n draft: Dashfoo,\n tabsetId: string,\n geometry: Geometry | undefined,\n floatId: string | undefined,\n): void => {\n const root = findRootContaining(draft, tabsetId);\n if (!root) {\n return;\n }\n const detached = removeTabsetReturning(root, tabsetId);\n if (detached) {\n pushFloat(draft, wrapTabsetInLayout(detached), geometry, floatId);\n }\n};\n\n// Dock-back targets the MAIN layout only (never another float): prefer an explicit\n// target, then the active tabset, then the first main tabset.\nconst resolveMainTarget = (\n draft: Dashfoo,\n targetId: string | undefined,\n): TabsetNode | undefined => {\n const mainTabsets: Array<TabsetNode> = [];\n tabsetsInRow(draft.layout, mainTabsets);\n if (targetId) {\n const explicit = mainTabsets.find((tabset) => tabset.id === targetId);\n if (explicit) {\n return explicit;\n }\n }\n if (draft.activeTabsetId !== undefined) {\n const active = mainTabsets.find((tabset) => tabset.id === draft.activeTabsetId);\n if (active) {\n return active;\n }\n }\n return mainTabsets[0];\n};\n\nconst dockFloat = (\n draft: Dashfoo,\n floatId: string,\n targetId: string | undefined,\n location: DockLocation | undefined,\n): void => {\n const floats = draft.floats ?? [];\n const index = floats.findIndex((float) => float.id === floatId);\n if (index === -1) {\n return;\n }\n const [float] = floats.splice(index, 1);\n draft.floats = floats;\n if (!float) {\n return;\n }\n\n const tabsets: Array<TabsetNode> = [];\n tabsetsInRow(float.layout, tabsets);\n const tabs = tabsets.flatMap((tabset) => tabset.children);\n if (tabs.length === 0) {\n return;\n }\n\n // Carry over which tab the user had selected in the float. The float's first\n // tabset leads the flattened list (the common single-tabset float), so its\n // clamped `selected` is the offset of the focused tab — clamp against the\n // tabset's own length, like the moveTabset center merge, so a stale index can't\n // resolve to the wrong tab.\n const leadTabset = tabsets[0];\n const selectedOffset = leadTabset\n ? Math.min(Math.max(leadTabset.selected, 0), leadTabset.children.length - 1)\n : 0;\n\n const target = resolveMainTarget(draft, targetId);\n if (!target) {\n // Nothing left in the main layout to dock into — promote the float's own layout\n // to be the main layout so its tabs aren't lost.\n draft.layout = float.layout;\n draft.activeTabsetId = leadTabset?.id;\n return;\n }\n\n // An explicit `center` (e.g. a drag dropped onto a tab strip) merges the float's\n // tabs into the target. The default dock-back, though, restores the float as its\n // OWN panel beside the target — bringing all its tabs back as a group rather than\n // flattening them into another tabset.\n if (location === \"center\") {\n const mergeStart = target.children.length;\n target.children.push(...tabs);\n target.selected = mergeStart + selectedOffset;\n draft.activeTabsetId = target.id;\n return;\n }\n\n const where = location ?? \"split-right\";\n // A single-tabset float (the common case) re-docks that exact tabset, preserving\n // its id, tabs, and selected index; a split float collapses to one new tabset.\n const placed: TabsetNode =\n tabsets.length === 1 && leadTabset\n ? leadTabset\n : { children: tabs, id: createNodeId(\"tabset\"), selected: selectedOffset, type: \"tabset\" };\n placed.weight = 50;\n placeBesideTarget(draft, placed, target.id, where);\n};\n\nexport { dockFloat, floatTabsetById, pushFloat, uniqueFloatName };\n","import { normalize } from \"../model/invariants\";\nimport type { Dashfoo } from \"../model/schema\";\nimport {\n findAttributedNode,\n findFloat,\n findRootContaining,\n findRow,\n findTab,\n findTabset,\n} from \"../model/tree\";\n\nimport type { Action } from \"./actions\";\nimport { dockFloat, floatTabsetById, pushFloat, uniqueFloatName } from \"./floats\";\nimport {\n insertTab,\n placeBesideTarget,\n removeTabset,\n removeTabsetReturning,\n wrapTabInLayout,\n} from \"./surgery\";\n\nconst assertNever = (value: never): never => {\n throw new Error(`Unhandled action: ${JSON.stringify(value)}`);\n};\n\nconst applyAction = (draft: Dashfoo, action: Action): void => {\n switch (action.type) {\n case \"addNode\": {\n insertTab(draft, action.tab, {\n id: action.targetId,\n index: action.index,\n location: action.location,\n });\n return;\n }\n case \"adjustSplit\": {\n const root = findRootContaining(draft, action.rowId) ?? draft.layout;\n const row = findRow(root, action.rowId);\n if (!row) {\n return;\n }\n for (let index = 0; index < action.weights.length; index++) {\n const child = row.children[index];\n const weight = action.weights[index];\n if (!child || weight === undefined) {\n continue;\n }\n child.weight = weight;\n }\n return;\n }\n case \"deleteTab\": {\n const location = findTab(draft, action.tabId);\n if (location) {\n location.container.children.splice(location.index, 1);\n }\n return;\n }\n case \"deleteTabset\": {\n const root = findRootContaining(draft, action.tabsetId);\n if (root) {\n removeTabset(root, action.tabsetId);\n }\n return;\n }\n case \"dockFloat\": {\n dockFloat(draft, action.floatId, action.targetId, action.location);\n return;\n }\n case \"floatTab\": {\n const location = findTab(draft, action.tabId);\n if (!location) {\n return;\n }\n const [removed] = location.container.children.splice(location.index, 1);\n if (removed) {\n pushFloat(draft, wrapTabInLayout(removed), action.geometry, action.floatId);\n }\n return;\n }\n case \"floatTabset\": {\n floatTabsetById(draft, action.tabsetId, action.geometry, action.floatId);\n return;\n }\n case \"moveFloat\": {\n const float = findFloat(draft, action.floatId);\n if (float) {\n float.geometry = action.geometry;\n }\n return;\n }\n case \"moveNode\": {\n const source = findTab(draft, action.sourceId);\n if (!source) {\n return;\n }\n // Remove the source first; action.index is the destination slot measured\n // against the tabs that remain (the drag adapter excludes the dragged tab),\n // so it indexes the post-removal array directly — no reorder adjustment.\n const [removed] = source.container.children.splice(source.index, 1);\n if (!removed) {\n return;\n }\n insertTab(draft, removed, {\n id: action.targetId,\n index: action.index,\n location: action.location,\n });\n return;\n }\n case \"moveTabset\": {\n if (action.sourceId === action.targetId) {\n return;\n }\n const source = findTabset(draft, action.sourceId);\n if (!source) {\n return;\n }\n if (action.location === \"center\") {\n const target = findTabset(draft, action.targetId);\n if (target) {\n const mergeStart = target.children.length;\n // Clamp the source's selection against the SOURCE's own tab count before\n // offsetting. normalize's clampSelected only bounds against the FINAL\n // merged length, so a stale/out-of-range source.selected would otherwise\n // resolve to a valid-but-wrong merged index (an original target tab, or\n // the wrong source tab) that normalize cannot catch. Clamp here so the\n // merged selection always lands on a tab that came from the source.\n const sourceSelected = Math.min(Math.max(source.selected, 0), source.children.length - 1);\n target.children.push(...source.children);\n target.selected = mergeStart + sourceSelected;\n const sourceRoot = findRootContaining(draft, action.sourceId);\n if (sourceRoot) {\n removeTabset(sourceRoot, action.sourceId);\n }\n }\n return;\n }\n // split-* moves the whole tabset beside the target.\n if (action.location.startsWith(\"split-\")) {\n const sourceRoot = findRootContaining(draft, action.sourceId);\n const detached = sourceRoot\n ? removeTabsetReturning(sourceRoot, action.sourceId)\n : undefined;\n if (detached) {\n placeBesideTarget(draft, detached, action.targetId, action.location);\n }\n }\n return;\n }\n case \"renameFloat\": {\n const float = findFloat(draft, action.floatId);\n if (float) {\n // Dedupe against the other floats so two windows never share a title.\n const others = (draft.floats ?? []).filter((other) => other.id !== action.floatId);\n float.name = uniqueFloatName(action.name, others);\n }\n return;\n }\n case \"renameTab\": {\n const location = findTab(draft, action.tabId);\n if (location) {\n location.tab.name = action.name;\n }\n return;\n }\n case \"selectTab\": {\n const tabset = findTabset(draft, action.tabsetId);\n if (tabset) {\n tabset.selected = action.index;\n }\n return;\n }\n case \"setActiveTabset\": {\n if (findTabset(draft, action.tabsetId)) {\n draft.activeTabsetId = action.tabsetId;\n }\n return;\n }\n case \"setFloatMinimized\": {\n const float = findFloat(draft, action.floatId);\n if (float) {\n float.minimized = action.minimized;\n }\n return;\n }\n case \"setMaximizedTabset\": {\n draft.maximizedTabsetId = action.tabsetId ?? undefined;\n return;\n }\n case \"updateGlobalAttributes\": {\n Object.assign(draft.global, action.attrs);\n return;\n }\n case \"updateNodeAttributes\": {\n const node = findAttributedNode(draft, action.nodeId);\n if (node) {\n Object.assign(node, action.attrs);\n }\n return;\n }\n default: {\n assertNever(action);\n }\n }\n};\n\n// The canonical engine: deep-copy the model (so the input is never mutated), apply\n// one action to the copy, then run the self-healing invariants so the result is\n// always a valid, canonical model.\nconst reducer = (model: Dashfoo, action: Action): Dashfoo => {\n const draft = structuredClone(model);\n applyAction(draft, action);\n return normalize(draft);\n};\n\nexport { reducer };\n","import type { Dashfoo } from \"../model/schema\";\n\nimport type { Action } from \"./actions\";\nimport { reducer } from \"./reducer\";\n\n// past/present/future snapshots. Each committed action is its own undo step:\n// rrp v4's onLayoutChanged fires one adjustSplit per release, so there is no\n// per-frame burst to coalesce.\ntype History = {\n future: Array<Dashfoo>;\n past: Array<Dashfoo>;\n present: Dashfoo;\n};\n\n// Snapshots are full model clones, so an unbounded past grows memory for the\n// life of the session (every action — even a tab click — is one step). 100\n// steps is far beyond practical undo depth while keeping memory flat.\nconst HISTORY_LIMIT = 100;\n\nconst createHistory = (present: Dashfoo): History => ({\n future: [],\n past: [],\n present,\n});\n\nconst canUndo = (history: History): boolean => history.past.length > 0;\nconst canRedo = (history: History): boolean => history.future.length > 0;\n\nconst dispatch = (history: History, action: Action): History => {\n const present = reducer(history.present, action);\n return { future: [], past: [...history.past, history.present].slice(-HISTORY_LIMIT), present };\n};\n\nconst undo = (history: History): History => {\n const previous = history.past.at(-1);\n if (previous === undefined) {\n return history;\n }\n return {\n future: [history.present, ...history.future],\n past: history.past.slice(0, -1),\n present: previous,\n };\n};\n\nconst redo = (history: History): History => {\n const [next, ...rest] = history.future;\n if (next === undefined) {\n return history;\n }\n return {\n future: rest,\n past: [...history.past, history.present].slice(-HISTORY_LIMIT),\n present: next,\n };\n};\n\nexport { canRedo, canUndo, createHistory, dispatch, HISTORY_LIMIT, redo, undo };\nexport type { History };\n","import { assign, setup } from \"xstate\";\n\nimport type { Dashfoo } from \"../model/schema\";\nimport type { Action } from \"../state/actions\";\nimport type { History } from \"../state/history\";\nimport { createHistory, dispatch, redo, undo } from \"../state/history\";\n\ntype DashfooContext = { history: History };\n\ntype DashfooEvent =\n | { action: Action; type: \"DISPATCH\" }\n | { model: Dashfoo; type: \"SET_MODEL\" }\n | { type: \"REDO\" }\n | { type: \"UNDO\" };\n\ntype DashfooInput = { model: Dashfoo };\n\n// The document actor: it owns the undo/redo history (whose `present` is the live\n// model) and processes document mutations by invoking the pure reducer via the\n// history helpers. It has no finite states beyond `ready` — the document is data,\n// not a lifecycle — so every mutation is an event handled with assign.\nconst dashfooMachine = setup({\n types: {\n context: {} as DashfooContext,\n events: {} as DashfooEvent,\n input: {} as DashfooInput,\n },\n}).createMachine({\n context: ({ input }) => ({ history: createHistory(input.model) }),\n id: \"dashfoo\",\n initial: \"ready\",\n states: {\n ready: {\n on: {\n DISPATCH: {\n actions: assign({\n history: ({ context, event }) => dispatch(context.history, event.action),\n }),\n },\n REDO: {\n actions: assign({ history: ({ context }) => redo(context.history) }),\n },\n SET_MODEL: {\n actions: assign({ history: ({ event }) => createHistory(event.model) }),\n },\n UNDO: {\n actions: assign({ history: ({ context }) => undo(context.history) }),\n },\n },\n },\n },\n});\n\nexport { dashfooMachine };\nexport type { DashfooContext, DashfooEvent, DashfooInput };\n","import { assign, emit, setup } from \"xstate\";\n\nimport type { TabNode } from \"../model/schema\";\nimport type { Action, DropIntent } from \"../state/actions\";\n\n// Internal subjects reference a node already in the document; an external\n// subject carries the TabNode to insert on drop (a widget dragged in from\n// outside the layout), so its id never has to exist in the model.\ntype DragSubject =\n | { id: string; kind: \"tab\" | \"tabset\" }\n | { id: string; kind: \"external\"; tab: TabNode };\n\ntype DragContext = { intent: DropIntent | null; subject: DragSubject | null };\n\ntype DragEvent =\n | { intent: DropIntent | null; type: \"OVER\" }\n | { subject: DragSubject; type: \"START\" }\n | { type: \"CANCEL\" }\n | { type: \"DROP\" };\n\ntype DragEmitted = { action: Action; type: \"COMMIT\" };\n\nconst requireDrop = (context: DragContext): { intent: DropIntent; subject: DragSubject } => {\n if (context.subject === null || context.intent === null) {\n throw new Error(\"drop requires a subject and a drop intent\");\n }\n return { intent: context.intent, subject: context.subject };\n};\n\n// The drag/dock interaction lifecycle, driven by abstract events the dnd-kit\n// adapter maps from pointer/keyboard input. It owns transient drag state only and\n// never touches the document — on a valid drop it emits a COMMIT carrying the\n// resulting action (moveNode/moveTabset, or addNode for an external subject),\n// which the React layer forwards to the document machine.\nconst dragDockMachine = setup({\n guards: {\n hasValidDrop: ({ context }) => context.subject !== null && context.intent !== null,\n },\n types: {\n context: {} as DragContext,\n emitted: {} as DragEmitted,\n events: {} as DragEvent,\n },\n}).createMachine({\n context: { intent: null, subject: null },\n id: \"dragDock\",\n initial: \"idle\",\n states: {\n dragging: {\n on: {\n CANCEL: { target: \"idle\" },\n DROP: [\n {\n actions: emit(({ context }) => {\n const { intent, subject } = requireDrop(context);\n const action: Action =\n subject.kind === \"external\"\n ? {\n index: intent.index,\n location: intent.location,\n tab: subject.tab,\n targetId: intent.targetId,\n type: \"addNode\",\n }\n : {\n index: intent.index,\n location: intent.location,\n sourceId: subject.id,\n targetId: intent.targetId,\n type: subject.kind === \"tabset\" ? \"moveTabset\" : \"moveNode\",\n };\n return { action, type: \"COMMIT\" };\n }),\n guard: \"hasValidDrop\",\n target: \"idle\",\n },\n { target: \"idle\" },\n ],\n OVER: { actions: assign({ intent: ({ event }) => event.intent }) },\n },\n },\n idle: {\n entry: assign({ intent: null, subject: null }),\n on: {\n START: { actions: assign({ subject: ({ event }) => event.subject }), target: \"dragging\" },\n },\n },\n },\n});\n\nexport { dragDockMachine };\nexport type { DragContext, DragEmitted, DragEvent, DragSubject };\n","import { normalize } from \"./invariants\";\nimport type { Dashfoo } from \"./schema\";\nimport { dashfooSchema } from \"./schema\";\nimport { findDuplicateIds } from \"./tree\";\n\n// Validate an untrusted value against the schema and return a normalized,\n// canonical model. Throws if the value is not a valid model — including a\n// payload whose `version` is not the pinned `1`; warns (does not throw) on\n// duplicate ids, which corrupt React keys and the plumbing.\nconst parseModel = (value: unknown): Dashfoo => {\n const model = normalize(dashfooSchema.parse(value));\n const duplicates = findDuplicateIds(model);\n if (duplicates.length > 0) {\n // oxlint-disable-next-line no-console\n console.warn(`[dashfoo] duplicate node ids in the loaded layout: ${duplicates.join(\", \")}`);\n }\n return model;\n};\n\nconst toJSON = (model: Dashfoo): string => JSON.stringify(model);\n\nconst fromJSON = (json: string): Dashfoo => parseModel(JSON.parse(json));\n\nexport { fromJSON, parseModel, toJSON };\n","import { normalize } from \"./invariants\";\nimport type { Dashfoo, Orientation, TabsetNode } from \"./schema\";\nimport { collectTabsetsInRow } from \"./tree\";\n\n// Flatten the MAIN layout into a single row (default a column) of all its\n// tabsets, in document order, each with equal weight, so nothing is lost on a\n// narrow screen; maximize is cleared. Detached windows are independent frames, so\n// `windows` passes through untouched — pulling their tabsets into the main layout\n// would duplicate panels already rendered in their popups. The building block for\n// a mobile breakpoint: `stackModel(desktopModel)`.\nconst stackModel = (model: Dashfoo, orientation: Orientation = \"column\"): Dashfoo => {\n // Equal weight so stacked panels share the space evenly. A loop (not map) so we\n // create fresh nodes without mutating the shared input tabsets.\n const mainTabsets: Array<TabsetNode> = [];\n collectTabsetsInRow(model.layout, mainTabsets);\n const children: Array<TabsetNode> = [];\n for (const tabset of mainTabsets) {\n children.push({ ...tabset, weight: 1 });\n }\n\n return normalize({\n ...model,\n layout: { children, id: model.layout.id, orientation, type: \"row\" },\n maximizedTabsetId: undefined,\n });\n};\n\nexport { stackModel };\n"],"mappings":";;;;AAMA,MAAM,kBAAwC,EAAE,WAC9C,EAAE,MAAM;CACN,EAAE,OAAO;CACT,EAAE,OAAO;CACT,EAAE,QAAQ;CACV,EAAE,KAAK;CACP,EAAE,MAAM,eAAe;CACvB,EAAE,OAAO,EAAE,OAAO,GAAG,eAAe;AACtC,CAAC,CACH;AAEA,MAAM,aAAa,EAAE,KAAK;CAAC;CAAO;CAAU;CAAQ;AAAO,CAAC;AAC5D,MAAM,aAAa,EAAE,KAAK;CAAC;CAAM;CAAK;CAAM;CAAO;CAAM;AAAI,CAAC;AAC9D,MAAM,oBAAoB,EAAE,KAAK,CAAC,OAAO,QAAQ,CAAC;AAElD,MAAM,kBAAkB,EAAE,OAAO;CAC/B,MAAM;CACN,OAAO,EAAE,OAAO;AAClB,CAAC;AASD,MAAM,aAAa,EAAE,OAAO;CAC1B,WAAW,EAAE,MAAM,CAAC,EAAE,OAAO,EAAE,SAAS,GAAG,EAAE,QAAQ,QAAQ,CAAC,CAAC,EAAE,SAAS;CAC1E,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS;CACjC,WAAW,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS;AAC5C,CAAC;AAED,MAAM,gBAAgB,EAAE,OAAO;CAC7B,WAAW,EAAE,OAAO;CACpB,QAAQ,gBAAgB,SAAS;CACjC,aAAa,EAAE,QAAQ,EAAE,SAAS;CAClC,YA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AAM,cAAc,OAAgB,cAA2B,aAAsB;CAGnF,MAAM,cAAiC,CAAC;CACxC,oBAAoB,MAAM,QAAQ,WAAW;CAC7C,MAAM,WAA8B,CAAC;CACrC,KAAK,MAAM,UAAU,aACnB,SAAS,KAAK;EAAE,GAAG;EAAQ,QAAQ;CAAE,CAAC;CAGxC,OAAO,UAAU;EACf,GAAG;EACH,QAAQ;GAAE;GAAU,IAAI,MAAM,OAAO;GAAI;GAAa,MAAM;EAAM;EAClE,mBAAmB;CACrB,CAAC;AACH"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dashfoo/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "Headless docking-layout engine: model, actions, reducer, serialization, geometry, and the XState actor system. No React.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Pedro Filho <pedro@filho.me>",
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"typescript": "^6.0.3",
|
|
33
33
|
"vitest": "^4.1.8",
|
|
34
|
-
"@repo/
|
|
35
|
-
"@repo/config
|
|
34
|
+
"@repo/config-vitest": "0.0.0",
|
|
35
|
+
"@repo/typescript-config": "0.0.0"
|
|
36
36
|
},
|
|
37
37
|
"scripts": {
|
|
38
38
|
"build": "tsdown",
|