@dashfoo/core 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -2
- package/dist/index.d.ts +44 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -204,6 +204,29 @@ matching inner corner. The two functions share the band default, so a map
|
|
|
204
204
|
painted from the polygons always agrees with the live hit-test — use it to
|
|
205
205
|
visualize drop zones or to build custom drop indicators.
|
|
206
206
|
|
|
207
|
+
## Snapping
|
|
208
|
+
|
|
209
|
+
Pure math for magnetic split-resize snapping, over ordered percentage arrays so
|
|
210
|
+
it stays framework-free; the React adapter maps rrp's id-keyed layout to/from
|
|
211
|
+
these arrays and supplies the dragged boundary index.
|
|
212
|
+
|
|
213
|
+
```ts
|
|
214
|
+
resolveSnapTargets(config: SnapConfig, panelCount: number): number[]; // grid positions inside 0..100
|
|
215
|
+
snapSizes(sizes: number[], boundaryIndex: number, config: SnapConfig): { sizes: number[]; snapped: boolean };
|
|
216
|
+
snapEnabled(config: SnapConfig | null): boolean;
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
`resolveSnapTargets` builds the grid for a row from its config and panel count: the
|
|
220
|
+
union of the `step` grid (multiples of a fixed percent) and the `divisions` grid
|
|
221
|
+
(even splits — multiples of `100/d`, where `d` is the number or, for `"panels"`,
|
|
222
|
+
the panel count). `snapSizes` snaps the boundary between panel `boundaryIndex` and
|
|
223
|
+
the next onto the nearest target within `threshold` (default `4`), moving only that
|
|
224
|
+
pair so siblings keep their size. It is a no-op when the grid is empty, the index
|
|
225
|
+
is out of range, or the correction would drive a panel negative. `snapEnabled`
|
|
226
|
+
reports whether a config produces any grid. `SnapConfig` is the
|
|
227
|
+
`{ step?, divisions?, threshold? }` shape carried by `global.snap` and
|
|
228
|
+
`RowNode.snap`.
|
|
229
|
+
|
|
207
230
|
## History (undo / redo)
|
|
208
231
|
|
|
209
232
|
A small `past` / `present` / `future` structure that wraps the reducer. `present`
|
|
@@ -285,10 +308,10 @@ layout, carrying the `TabNode` to insert), which the React layer forwards to
|
|
|
285
308
|
## Public exports
|
|
286
309
|
|
|
287
310
|
`schema` — `dashfooSchema`, `rowNodeSchema`, `tabsetNodeSchema`, `tabNodeSchema`,
|
|
288
|
-
`dimensionSchema`, `edgeSchema`, `unitSchema`,
|
|
311
|
+
`dimensionSchema`, `snapSchema`, `edgeSchema`, `unitSchema`,
|
|
289
312
|
`orientationSchema`, `globalAttributesSchema`,
|
|
290
313
|
`jsonValueSchema`; types `Dashfoo`, `RowNode`, `TabsetNode`, `TabNode`,
|
|
291
|
-
`Dimension`, `Edge`, `Unit`, `Orientation`,
|
|
314
|
+
`Dimension`, `SnapConfig`, `Edge`, `Unit`, `Orientation`,
|
|
292
315
|
`GlobalAttributes`, `Node`, `Json`.
|
|
293
316
|
|
|
294
317
|
`builders` — `model`, `row`, `tabset`, `tab`; option types `ModelOptions`,
|
|
@@ -308,6 +331,9 @@ types `AttributedNode`, `TabContainer`, `TabLocation`.
|
|
|
308
331
|
`geometry` — `resolveDockTarget`, `dockZonePolygons`, `zoneRect`; types
|
|
309
332
|
`DockTarget`, `DockZone`, `BandOptions`, `Point`, `Rect`.
|
|
310
333
|
|
|
334
|
+
`snap` — `resolveSnapTargets`, `snapSizes`, `snapEnabled`, `DEFAULT_SNAP_THRESHOLD`;
|
|
335
|
+
type `SnapResult`.
|
|
336
|
+
|
|
311
337
|
`history` — `createHistory`, `dispatch`, `undo`, `redo`, `canUndo`, `canRedo`;
|
|
312
338
|
type `History`.
|
|
313
339
|
|
package/dist/index.d.ts
CHANGED
|
@@ -109,6 +109,11 @@ declare const mutableNodeAttrsSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
109
109
|
row: "row";
|
|
110
110
|
column: "column";
|
|
111
111
|
}>>;
|
|
112
|
+
snap: z.ZodOptional<z.ZodOptional<z.ZodObject<{
|
|
113
|
+
divisions: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"panels">]>>;
|
|
114
|
+
step: z.ZodOptional<z.ZodNumber>;
|
|
115
|
+
threshold: z.ZodOptional<z.ZodNumber>;
|
|
116
|
+
}, z.core.$strip>>>;
|
|
112
117
|
weight: z.ZodOptional<z.ZodNumber>;
|
|
113
118
|
}, z.core.$strip>]>;
|
|
114
119
|
declare const dockLocationSchema: z.ZodEnum<{
|
|
@@ -344,6 +349,11 @@ declare const actionSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
344
349
|
row: "row";
|
|
345
350
|
column: "column";
|
|
346
351
|
}>>;
|
|
352
|
+
snap: z.ZodOptional<z.ZodOptional<z.ZodObject<{
|
|
353
|
+
divisions: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"panels">]>>;
|
|
354
|
+
step: z.ZodOptional<z.ZodNumber>;
|
|
355
|
+
threshold: z.ZodOptional<z.ZodNumber>;
|
|
356
|
+
}, z.core.$strip>>>;
|
|
347
357
|
weight: z.ZodOptional<z.ZodNumber>;
|
|
348
358
|
}, z.core.$strip>]>;
|
|
349
359
|
nodeId: z.ZodString;
|
|
@@ -352,6 +362,11 @@ declare const actionSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
352
362
|
attrs: z.ZodObject<{
|
|
353
363
|
enableSplitDock: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
|
|
354
364
|
enableSplitResize: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
|
|
365
|
+
snap: z.ZodOptional<z.ZodOptional<z.ZodObject<{
|
|
366
|
+
divisions: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"panels">]>>;
|
|
367
|
+
step: z.ZodOptional<z.ZodNumber>;
|
|
368
|
+
threshold: z.ZodOptional<z.ZodNumber>;
|
|
369
|
+
}, z.core.$strip>>>;
|
|
355
370
|
splitterSize: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
|
|
356
371
|
tabEnableClose: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
|
|
357
372
|
tabEnableDrag: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
|
|
@@ -409,6 +424,11 @@ declare const dimensionSchema: z.ZodObject<{
|
|
|
409
424
|
}>;
|
|
410
425
|
value: z.ZodNumber;
|
|
411
426
|
}, z.core.$strip>;
|
|
427
|
+
declare const snapSchema: z.ZodObject<{
|
|
428
|
+
divisions: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"panels">]>>;
|
|
429
|
+
step: z.ZodOptional<z.ZodNumber>;
|
|
430
|
+
threshold: z.ZodOptional<z.ZodNumber>;
|
|
431
|
+
}, z.core.$strip>;
|
|
412
432
|
declare const tabNodeSchema: z.ZodObject<{
|
|
413
433
|
component: z.ZodString;
|
|
414
434
|
config: z.ZodOptional<z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>>;
|
|
@@ -466,6 +486,7 @@ type RowNode = {
|
|
|
466
486
|
max?: z.infer<typeof dimensionSchema>;
|
|
467
487
|
min?: z.infer<typeof dimensionSchema>;
|
|
468
488
|
orientation: z.infer<typeof orientationSchema>;
|
|
489
|
+
snap?: z.infer<typeof snapSchema>;
|
|
469
490
|
type: "row";
|
|
470
491
|
weight?: number;
|
|
471
492
|
};
|
|
@@ -473,6 +494,11 @@ declare const rowNodeSchema: z.ZodType<RowNode>;
|
|
|
473
494
|
declare const globalAttributesSchema: z.ZodObject<{
|
|
474
495
|
enableSplitDock: z.ZodOptional<z.ZodBoolean>;
|
|
475
496
|
enableSplitResize: z.ZodOptional<z.ZodBoolean>;
|
|
497
|
+
snap: z.ZodOptional<z.ZodObject<{
|
|
498
|
+
divisions: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"panels">]>>;
|
|
499
|
+
step: z.ZodOptional<z.ZodNumber>;
|
|
500
|
+
threshold: z.ZodOptional<z.ZodNumber>;
|
|
501
|
+
}, z.core.$strip>>;
|
|
476
502
|
splitterSize: z.ZodOptional<z.ZodNumber>;
|
|
477
503
|
tabEnableClose: z.ZodOptional<z.ZodBoolean>;
|
|
478
504
|
tabEnableDrag: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -490,6 +516,11 @@ declare const dashfooSchema: z.ZodObject<{
|
|
|
490
516
|
global: z.ZodObject<{
|
|
491
517
|
enableSplitDock: z.ZodOptional<z.ZodBoolean>;
|
|
492
518
|
enableSplitResize: z.ZodOptional<z.ZodBoolean>;
|
|
519
|
+
snap: z.ZodOptional<z.ZodObject<{
|
|
520
|
+
divisions: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"panels">]>>;
|
|
521
|
+
step: z.ZodOptional<z.ZodNumber>;
|
|
522
|
+
threshold: z.ZodOptional<z.ZodNumber>;
|
|
523
|
+
}, z.core.$strip>>;
|
|
493
524
|
splitterSize: z.ZodOptional<z.ZodNumber>;
|
|
494
525
|
tabEnableClose: z.ZodOptional<z.ZodBoolean>;
|
|
495
526
|
tabEnableDrag: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -511,6 +542,7 @@ type Edge = z.infer<typeof edgeSchema>;
|
|
|
511
542
|
type Unit = z.infer<typeof unitSchema>;
|
|
512
543
|
type Orientation = z.infer<typeof orientationSchema>;
|
|
513
544
|
type Dimension = z.infer<typeof dimensionSchema>;
|
|
545
|
+
type SnapConfig = z.infer<typeof snapSchema>;
|
|
514
546
|
type TabNode = z.infer<typeof tabNodeSchema>;
|
|
515
547
|
type TabsetNode = z.infer<typeof tabsetNodeSchema>;
|
|
516
548
|
type GlobalAttributes = z.infer<typeof globalAttributesSchema>;
|
|
@@ -542,6 +574,7 @@ type RowOptions = {
|
|
|
542
574
|
max?: number | Dimension;
|
|
543
575
|
min?: number | Dimension;
|
|
544
576
|
orientation?: RowNode["orientation"];
|
|
577
|
+
snap?: SnapConfig;
|
|
545
578
|
weight?: number;
|
|
546
579
|
};
|
|
547
580
|
declare const row: (children: RowNode["children"], options?: RowOptions) => RowNode;
|
|
@@ -580,6 +613,16 @@ declare const resolveDockTarget: (pointer: Point, rect: Rect, opts?: BandOptions
|
|
|
580
613
|
declare const dockZonePolygons: (rect: Rect, opts?: BandOptions) => Array<DockZone>;
|
|
581
614
|
declare const zoneRect: (rect: Rect, location: DockLocation) => Rect;
|
|
582
615
|
//#endregion
|
|
616
|
+
//#region src/geometry/snap.d.ts
|
|
617
|
+
declare const DEFAULT_SNAP_THRESHOLD = 4;
|
|
618
|
+
declare const resolveSnapTargets: (config: SnapConfig, panelCount: number) => Array<number>;
|
|
619
|
+
declare const snapEnabled: (config: SnapConfig | null) => boolean;
|
|
620
|
+
type SnapResult = {
|
|
621
|
+
sizes: Array<number>;
|
|
622
|
+
snapped: boolean;
|
|
623
|
+
};
|
|
624
|
+
declare const snapSizes: (sizes: Array<number>, boundaryIndex: number, config: SnapConfig) => SnapResult;
|
|
625
|
+
//#endregion
|
|
583
626
|
//#region src/state/history.d.ts
|
|
584
627
|
type History = {
|
|
585
628
|
future: Array<Dashfoo>;
|
|
@@ -716,5 +759,5 @@ declare const findTabsetParent: (row: RowNode, tabsetId: string) => {
|
|
|
716
759
|
} | undefined;
|
|
717
760
|
declare const findDuplicateIds: (model: Dashfoo) => Array<string>;
|
|
718
761
|
//#endregion
|
|
719
|
-
export { type Action, type AttributedNode, type BandOptions, type Dashfoo, type DashfooContext, type DashfooEvent, type DashfooInput, type Dimension, type DockLocation, type DockTarget, type DockZone, type DragContext, type DragEmitted, type DragEvent, type DragSubject, type DropIntent, type Edge, type GlobalAttributes, HISTORY_LIMIT, type History, type Json, type ModelOptions, type MutableNodeAttrs, type Node, type Orientation, type Point, type Rect, type RowNode, type RowOptions, type TabContainer, type TabLocation, type TabNode, type TabOptions, type TabsetNode, type TabsetOptions, type Unit, actionSchema, canRedo, canUndo, collectTabsets, createHistory, createNodeId, createTabId, dashfooMachine, dashfooSchema, dimensionSchema, dispatch, dockLocationSchema, dockZonePolygons, dragDockMachine, edgeSchema, findAttributedNode, findDuplicateIds, findRow, findTab, findTabset, findTabsetParent, fromJSON, getFirstTabset, globalAttributesSchema, jsonValueSchema, model, mutableNodeAttrsSchema, normalize, orientationSchema, parseModel, redo, reducer, resolveDockTarget, row, rowNodeSchema, stackModel, tab, tabNodeSchema, tabset, tabsetNodeSchema, toJSON, undo, unitSchema, zoneRect };
|
|
762
|
+
export { type Action, type AttributedNode, type BandOptions, DEFAULT_SNAP_THRESHOLD, type Dashfoo, type DashfooContext, type DashfooEvent, type DashfooInput, type Dimension, type DockLocation, type DockTarget, type DockZone, type DragContext, type DragEmitted, type DragEvent, type DragSubject, type DropIntent, type Edge, type GlobalAttributes, HISTORY_LIMIT, type History, type Json, type ModelOptions, type MutableNodeAttrs, type Node, type Orientation, type Point, type Rect, type RowNode, type RowOptions, type SnapConfig, type SnapResult, type TabContainer, type TabLocation, type TabNode, type TabOptions, type TabsetNode, type TabsetOptions, type Unit, actionSchema, canRedo, canUndo, collectTabsets, createHistory, createNodeId, createTabId, dashfooMachine, dashfooSchema, dimensionSchema, dispatch, dockLocationSchema, dockZonePolygons, dragDockMachine, edgeSchema, findAttributedNode, findDuplicateIds, findRow, findTab, findTabset, findTabsetParent, fromJSON, getFirstTabset, globalAttributesSchema, jsonValueSchema, model, mutableNodeAttrsSchema, normalize, orientationSchema, parseModel, redo, reducer, resolveDockTarget, resolveSnapTargets, row, rowNodeSchema, snapEnabled, snapSchema, snapSizes, stackModel, tab, tabNodeSchema, tabset, tabsetNodeSchema, toJSON, undo, unitSchema, zoneRect };
|
|
720
763
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/state/actions.ts","../src/model/schema.ts","../src/model/builders.ts","../src/geometry/geometry.ts","../src/state/history.ts","../src/model/ids.ts","../src/model/invariants.ts","../src/machines/dashfoo-machine.ts","../src/machines/drag-dock-machine.ts","../src/state/reducer.ts","../src/model/serialize.ts","../src/model/stack.ts","../src/model/tree.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/state/actions.ts","../src/model/schema.ts","../src/model/builders.ts","../src/geometry/geometry.ts","../src/geometry/snap.ts","../src/state/history.ts","../src/model/ids.ts","../src/model/invariants.ts","../src/machines/dashfoo-machine.ts","../src/machines/drag-dock-machine.ts","../src/state/reducer.ts","../src/model/serialize.ts","../src/model/stack.ts","../src/model/tree.ts"],"mappings":";;;cA0CM,sBAAA,EAAsB,CAAA,CAAA,QAAA,WAAA,CAAA,CAAA,SAAA;;+CAI1B,gBAAA;EAAA;IAAA,wEAAA,gBAAA,0BAAA;EAAA;IAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAKI,kBAAA,EAAkB,CAAA,CAAA,OAAA;;;;;;;cAQlB,YAAA,EAAY,CAAA,CAAA,qBAAA,EAAA,CAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAyCb,YAAA,GAAe,CAAA,CAAE,KAAK,QAAQ,kBAAA;AAAA,KAC9B,gBAAA,GAAmB,CAAA,CAAE,KAAK,QAAQ,sBAAA;AAAA,KAClC,MAAA,GAAS,CAAA,CAAE,KAAK,QAAQ,YAAA;AAAA,KAKxB,UA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,GAAa,WAAA,KAAyB,OAAA;;;KCLrE,YAAA,GAAe,UAAU;AAAA,KACzB,WAAA;EAAgB,SAAA,EAAW,YAAA;EAAc,KAAA;EAAe,GAAA,EAAK,OAAO;AAAA;AAAA,cAanE,cAAA,GAAkB,KAAA,EAAO,OAAA,KAAU,KAAA,CAAM,UAAA;AAAA,cAMzC,cAAA,GAAkB,KAAA,EAAO,OAAA,KAAU,UAAU;AAAA,cAE7C,UAAA,GAAc,KAAA,EAAO,OAAA,EAAS,QAAA,aAAmB,UAAU;AAAA,cAmB3D,OAAA,GAAW,KAAA,EAAO,OAAA,EAAS,KAAA,aAAgB,WAAW;AAAA,KAWvD,cAAA,GAAiB,OAAA,GAAU,OAAA,GAAU,UAAA;AAAA,cAGpC,OAAA,GAAW,GAAA,EAAK,OAAA,EAAS,EAAA,aAAa,OAAO;AAAA,cA0C7C,kBAAA,GAAsB,KAAA,EAAO,OAAA,EAAS,EAAA,aAAa,cAAc;AAAA,cAIjE,gBAAA,GACJ,GAAA,EAAK,OAAA,EACL,QAAA;EACG,KAAA;EAAe,MAAA,EAAQ,OAAO;AAAA;AAAA,cAiC7B,gBAAA,GAAoB,KAAA,EAAO,OAAA,KAAU,KAAK"}
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{z as e}from"zod";import{assign as t,emit as n,setup as r}from"xstate";const i=e.lazy(()=>e.union([e.string(),e.number(),e.boolean(),e.null(),e.array(i),e.record(e.string(),i)])),a=e.enum([`top`,`bottom`,`left`,`right`]),o=e.enum([`px`,`%`,`em`,`rem`,`vh`,`vw`]),s=e.enum([`row`,`column`]),c=e.object({unit:o,value:e.number()}),l=e.object({component:e.string(),config:i.optional(),enableClose:e.boolean().optional(),enableDrag:e.boolean().optional(),enableRename:e.boolean().optional(),id:e.string(),name:e.string(),type:e.literal(`tab`)}),u=e.object({children:e.array(l),enableClose:e.boolean().optional(),enableMaximize:e.boolean().optional(),id:e.string(),max:c.optional(),min:c.optional(),name:e.string().optional(),selected:e.number().int(),type:e.literal(`tabset`),weight:e.number().optional()}),d=e.lazy(()=>e.object({children:e.array(e.union([d,u])),id:e.string(),max:c.optional(),min:c.optional(),orientation:s,type:e.literal(`row`),weight:e.number().optional()})),f=e.object({enableSplitDock:e.boolean().optional(),enableSplitResize:e.boolean().optional(),splitterSize:e.number().optional(),tabEnableClose:e.boolean().optional(),tabEnableDrag:e.boolean().optional(),tabEnableRename:e.boolean().optional(),tabLocation:e.enum([`top`,`bottom`]).optional(),tabSetEnableMaximize:e.boolean().optional(),tabSetEnableTabStrip:e.boolean().optional(),tabSetMinSize:e.number().optional()}),p=e.object({activeTabsetId:e.string().optional(),global:f,layout:d,maximizedTabsetId:e.string().optional(),version:e.literal(1)}),m=l.pick({config:!0,enableClose:!0,enableDrag:!0,enableRename:!0,name:!0}).partial(),h=u.pick({enableClose:!0,enableMaximize:!0,max:!0,min:!0,selected:!0,weight:!0}).partial(),g=e.object({max:c.optional(),min:c.optional(),orientation:s,weight:e.number()}).partial(),_=e.union([m,h,g]),v=e.enum([`center`,`split-bottom`,`split-left`,`split-right`,`split-top`]),y=e.discriminatedUnion(`type`,[e.object({index:e.number().int().optional(),location:v,tab:l,targetId:e.string(),type:e.literal(`addNode`)}),e.object({index:e.number().int().optional(),location:v,sourceId:e.string(),targetId:e.string(),type:e.literal(`moveNode`)}),e.object({index:e.number().int().optional(),location:v,sourceId:e.string(),targetId:e.string(),type:e.literal(`moveTabset`)}),e.object({index:e.number().int(),tabsetId:e.string(),type:e.literal(`selectTab`)}),e.object({tabsetId:e.string(),type:e.literal(`setActiveTabset`)}),e.object({tabsetId:e.string().nullable(),type:e.literal(`setMaximizedTabset`)}),e.object({name:e.string(),tabId:e.string(),type:e.literal(`renameTab`)}),e.object({tabId:e.string(),type:e.literal(`deleteTab`)}),e.object({tabsetId:e.string(),type:e.literal(`deleteTabset`)}),e.object({rowId:e.string(),type:e.literal(`adjustSplit`),weights:e.array(e.number())}),e.object({attrs:_,nodeId:e.string(),type:e.literal(`updateNodeAttributes`)}),e.object({attrs:f.partial(),type:e.literal(`updateGlobalAttributes`)})]),b=(e=`node`)=>`${e}-${crypto.randomUUID()}`,ee=()=>b(`tab`),x=(e,t)=>{for(let n of e.children)n.type===`tabset`?t.push(n):x(n,t)},S=e=>{let t=[];return x(e.layout,t),t},C=e=>S(e)[0],w=(e,t)=>S(e).find(e=>e.id===t),T=(e,t)=>{let n=e.children.findIndex(e=>e.id===t);if(n===-1)return;let r=e.children[n];if(r)return{container:e,index:n,tab:r}},E=(e,t)=>{for(let n of S(e)){let e=T(n,t);if(e)return e}},D=(e,t)=>{if(e.id===t)return e;for(let n of e.children)if(n.type===`row`){let e=D(n,t);if(e)return e}},O=(e,t)=>{if(e.id===t)return e;for(let n of e.children){if(n.type===`row`){let e=O(n,t);if(e)return e;continue}if(n.id===t)return n;let e=n.children.find(e=>e.id===t);if(e)return e}},k=(e,t)=>O(e.layout,t),A=(e,t)=>{let n=e.children.findIndex(e=>e.type===`tabset`&&e.id===t);if(n!==-1)return{index:n,parent:e};for(let n of e.children)if(n.type===`row`){let e=A(n,t);if(e)return e}},j=(e,t)=>{t.push(e.id);for(let n of e.children)if(n.type===`row`)j(n,t);else{t.push(n.id);for(let e of n.children)t.push(e.id)}},M=e=>{let t=[];j(e.layout,t);let n=new Set,r=new Set;for(let e of t)n.has(e)&&r.add(e),n.add(e);return[...r]},N=e=>typeof e==`number`?{unit:`px`,value:e}:e,P=(e,t,n={})=>({component:e,name:t,type:`tab`,...n,id:n.id??e}),te=(e,t={})=>{let{max:n,min:r,...i}=t;return{children:e,type:`tabset`,...i,...n===void 0?{}:{max:N(n)},...r===void 0?{}:{min:N(r)},id:t.id??b(`tabset`),selected:t.selected??0}},ne=(e,t={})=>{let{max:n,min:r,...i}=t;return{children:e,type:`row`,...i,...n===void 0?{}:{max:N(n)},...r===void 0?{}:{min:N(r)},id:t.id??b(`row`),orientation:t.orientation??`row`}},re=(e,t={})=>{let n={layout:e,version:1,...t,global:t.global??{}},r=M(n);return r.length>0&&console.warn(`[dashfoo] builder produced duplicate node ids: ${r.join(`, `)} — pass explicit ids when reusing a component`),n},F=.22,ie=(e,t)=>{let n=(e.x-t.x)/t.width,r=(e.y-t.y)/t.height;return{bottom:1-r,left:n,right:1-n,top:r}},ae=e=>{let t=Math.min(e.left,e.right,e.top,e.bottom);return t===e.left?`left`:t===e.right?`right`:t===e.top?`top`:`bottom`},oe=(e,t,n)=>{let r=n?.bandFraction??F;if(t.width<=0||t.height<=0)return{kind:`tab`};let i=ie(e,t);return Math.min(i.left,i.right,i.top,i.bottom)>r?{kind:`tab`}:{edge:ae(i),kind:`split`}},se=(e,t)=>{let{height:n,width:r,x:i,y:a}=e,o={x:i,y:a},s={x:i+r,y:a},c={x:i+r,y:a+n},l={x:i,y:a+n};if(r<=0||n<=0)return[{location:`center`,points:[o,s,c,l]}];let u=t?.bandFraction??F,d=u*r,f=u*n,p={x:i+d,y:a+f},m={x:i+r-d,y:a+f},h={x:i+r-d,y:a+n-f},g={x:i+d,y:a+n-f};return[{location:`center`,points:[p,m,h,g]},{location:`split-left`,points:[o,p,g,l]},{location:`split-right`,points:[s,c,h,m]},{location:`split-top`,points:[o,s,m,p]},{location:`split-bottom`,points:[l,g,h,c]}]},ce=(e,t)=>{let n=e.width/2,r=e.height/2;switch(t){case`split-bottom`:return{height:r,width:e.width,x:e.x,y:e.y+r};case`split-left`:return{height:e.height,width:n,x:e.x,y:e.y};case`split-right`:return{height:e.height,width:n,x:e.x+n,y:e.y};case`split-top`:return{height:r,width:e.width,x:e.x,y:e.y};default:return e}},I=(e,t)=>{if(e===0)return 0;let n=Number.isFinite(t)?Math.trunc(t):0;return n<0?0:n>e-1?e-1:n},L=e=>({...e,selected:I(e.children.length,e.selected)}),R=e=>{let t=[];for(let n of e){if(n.type===`tabset`){n.children.length>0&&t.push(L(n));continue}let e=R(n.children);if(e.length!==0){if(e.length===1){let r=e[0];r!==void 0&&t.push(n.weight===void 0?r:{...r,weight:n.weight});continue}t.push({...n,children:e})}}return t},z=e=>{let t=R(e.children),n=e.orientation,r=t[0];for(;t.length===1&&r?.type===`row`;)t=r.children,n=r.orientation,r=t[0];return{...e,children:t,orientation:n}},B=e=>{let t=z(e.layout),n={...e,layout:t},r=new Set(S(n).map(e=>e.id)),i=S(n)[0]?.id,a=e.activeTabsetId!==void 0&&r.has(e.activeTabsetId)?e.activeTabsetId:i,o=e.maximizedTabsetId!==void 0&&r.has(e.maximizedTabsetId)?e.maximizedTabsetId:void 0;return{...n,activeTabsetId:a,maximizedTabsetId:o}},V=e=>{throw Error(`Unhandled action: ${JSON.stringify(e)}`)},H=(e,t)=>{let n=e.children.findIndex(e=>e.type===`tabset`&&e.id===t);if(n!==-1)return e.children.splice(n,1),!0;for(let n of e.children)if(n.type===`row`&&H(n,t))return!0;return!1},U=(e,t)=>{let n=e.children.findIndex(e=>e.type===`tabset`&&e.id===t);if(n!==-1){let[t]=e.children.splice(n,1);return t?.type===`tabset`?t:void 0}for(let n of e.children)if(n.type===`row`){let e=U(n,t);if(e)return e}},W=e=>e===`split-left`||e===`split-right`?`row`:`column`,le=e=>e===`split-left`||e===`split-top`,G=(e,t,n,r)=>{let i=w(e,n),a=A(e.layout,n);if(!i||!a)return;let o=W(r),s=le(r);if(a.parent.orientation===o){let e=i.weight??100;i.weight=e/2,t.weight=e/2,a.parent.children.splice(s?a.index:a.index+1,0,t)}else{let e=i.weight;i.weight=50,t.weight=50;let n={children:s?[t,i]:[i,t],id:b(`row`),orientation:o,type:`row`};e!==void 0&&(n.weight=e),a.parent.children.splice(a.index,1,n)}e.activeTabsetId=t.id},K=(e,t,n)=>{let{id:r,index:i,location:a}=n,o=w(e,r);if(o){if(a===`center`){let e=i??o.children.length;o.children.splice(e,0,t),o.selected=e;return}G(e,{children:[t],id:b(`tabset`),selected:0,type:`tabset`,weight:50},r,a)}},ue=(e,t)=>{switch(t.type){case`addNode`:K(e,t.tab,{id:t.targetId,index:t.index,location:t.location});return;case`adjustSplit`:{let n=D(e.layout,t.rowId);if(!n)return;for(let e=0;e<t.weights.length;e++){let r=n.children[e],i=t.weights[e];!r||i===void 0||(r.weight=i)}return}case`deleteTab`:{let n=E(e,t.tabId);n&&n.container.children.splice(n.index,1);return}case`deleteTabset`:H(e.layout,t.tabsetId);return;case`moveNode`:{let n=E(e,t.sourceId);if(!n)return;let[r]=n.container.children.splice(n.index,1);if(!r)return;K(e,r,{id:t.targetId,index:t.index,location:t.location});return}case`moveTabset`:{if(t.sourceId===t.targetId)return;let n=w(e,t.sourceId);if(!n)return;if(t.location===`center`){let r=w(e,t.targetId);r&&(r.children.push(...n.children),H(e.layout,t.sourceId));return}if(t.location.startsWith(`split-`)){let n=U(e.layout,t.sourceId);n&&G(e,n,t.targetId,t.location)}return}case`renameTab`:{let n=E(e,t.tabId);n&&(n.tab.name=t.name);return}case`selectTab`:{let n=w(e,t.tabsetId);n&&(n.selected=t.index);return}case`setActiveTabset`:w(e,t.tabsetId)&&(e.activeTabsetId=t.tabsetId);return;case`setMaximizedTabset`:e.maximizedTabsetId=t.tabsetId??void 0;return;case`updateGlobalAttributes`:Object.assign(e.global,t.attrs);return;case`updateNodeAttributes`:{let n=k(e,t.nodeId);n&&Object.assign(n,t.attrs);return}default:V(t)}},q=(e,t)=>{let n=structuredClone(e);return ue(n,t),B(n)},de=100,J=e=>({future:[],past:[],present:e}),fe=e=>e.past.length>0,pe=e=>e.future.length>0,Y=(e,t)=>{let n=q(e.present,t);return{future:[],past:[...e.past,e.present].slice(-100),present:n}},X=e=>{let t=e.past.at(-1);return t===void 0?e:{future:[e.present,...e.future],past:e.past.slice(0,-1),present:t}},Z=e=>{let[t,...n]=e.future;return t===void 0?e:{future:n,past:[...e.past,e.present].slice(-100),present:t}},me=r({types:{context:{},events:{},input:{}}}).createMachine({context:({input:e})=>({history:J(e.model)}),id:`dashfoo`,initial:`ready`,states:{ready:{on:{DISPATCH:{actions:t({history:({context:e,event:t})=>Y(e.history,t.action)})},REDO:{actions:t({history:({context:e})=>Z(e.history)})},SET_MODEL:{actions:t({history:({event:e})=>J(e.model)})},UNDO:{actions:t({history:({context:e})=>X(e.history)})}}}}}),he=e=>{if(e.subject===null||e.intent===null)throw Error(`drop requires a subject and a drop intent`);return{intent:e.intent,subject:e.subject}},ge=r({guards:{hasValidDrop:({context:e})=>e.subject!==null&&e.intent!==null},types:{context:{},emitted:{},events:{}}}).createMachine({context:{intent:null,subject:null},id:`dragDock`,initial:`idle`,states:{dragging:{on:{CANCEL:{target:`idle`},DROP:[{actions:n(({context:e})=>{let{intent:t,subject:n}=he(e);return{action:n.kind===`external`?{index:t.index,location:t.location,tab:n.tab,targetId:t.targetId,type:`addNode`}:{index:t.index,location:t.location,sourceId:n.id,targetId:t.targetId,type:n.kind===`tabset`?`moveTabset`:`moveNode`},type:`COMMIT`}}),guard:`hasValidDrop`,target:`idle`},{target:`idle`}],OVER:{actions:t({intent:({event:e})=>e.intent})}}},idle:{entry:t({intent:null,subject:null}),on:{START:{actions:t({subject:({event:e})=>e.subject}),target:`dragging`}}}}}),Q=e=>{let t=B(p.parse(e)),n=M(t);return n.length>0&&console.warn(`[dashfoo] duplicate node ids in the loaded layout: ${n.join(`, `)}`),t},$=e=>JSON.stringify(e),_e=e=>Q(JSON.parse(e)),ve=(e,t=`column`)=>{let n=[];for(let t of S(e))n.push({...t,weight:1});return B({...e,layout:{children:n,id:e.layout.id,orientation:t,type:`row`},maximizedTabsetId:void 0})};export{de as HISTORY_LIMIT,y as actionSchema,pe as canRedo,fe as canUndo,S as collectTabsets,J as createHistory,b as createNodeId,ee as createTabId,me as dashfooMachine,p as dashfooSchema,c as dimensionSchema,Y as dispatch,v as dockLocationSchema,se as dockZonePolygons,ge as dragDockMachine,a as edgeSchema,k as findAttributedNode,M as findDuplicateIds,D as findRow,E as findTab,w as findTabset,A as findTabsetParent,_e as fromJSON,C as getFirstTabset,f as globalAttributesSchema,i as jsonValueSchema,re as model,_ as mutableNodeAttrsSchema,B as normalize,s as orientationSchema,Q as parseModel,Z as redo,q as reducer,oe as resolveDockTarget,ne as row,d as rowNodeSchema,ve as stackModel,P as tab,l as tabNodeSchema,te as tabset,u as tabsetNodeSchema,$ as toJSON,X as undo,o as unitSchema,ce as zoneRect};
|
|
1
|
+
import{z as e}from"zod";import{assign as t,emit as n,setup as r}from"xstate";const i=e.lazy(()=>e.union([e.string(),e.number(),e.boolean(),e.null(),e.array(i),e.record(e.string(),i)])),a=e.enum([`top`,`bottom`,`left`,`right`]),o=e.enum([`px`,`%`,`em`,`rem`,`vh`,`vw`]),s=e.enum([`row`,`column`]),c=e.object({unit:o,value:e.number()}),l=e.object({divisions:e.union([e.number().positive(),e.literal(`panels`)]).optional(),step:e.number().min(0).optional(),threshold:e.number().positive().optional()}),u=e.object({component:e.string(),config:i.optional(),enableClose:e.boolean().optional(),enableDrag:e.boolean().optional(),enableRename:e.boolean().optional(),id:e.string(),name:e.string(),type:e.literal(`tab`)}),d=e.object({children:e.array(u),enableClose:e.boolean().optional(),enableMaximize:e.boolean().optional(),id:e.string(),max:c.optional(),min:c.optional(),name:e.string().optional(),selected:e.number().int(),type:e.literal(`tabset`),weight:e.number().optional()}),f=e.lazy(()=>e.object({children:e.array(e.union([f,d])),id:e.string(),max:c.optional(),min:c.optional(),orientation:s,snap:l.optional(),type:e.literal(`row`),weight:e.number().optional()})),p=e.object({enableSplitDock:e.boolean().optional(),enableSplitResize:e.boolean().optional(),snap:l.optional(),splitterSize:e.number().optional(),tabEnableClose:e.boolean().optional(),tabEnableDrag:e.boolean().optional(),tabEnableRename:e.boolean().optional(),tabLocation:e.enum([`top`,`bottom`]).optional(),tabSetEnableMaximize:e.boolean().optional(),tabSetEnableTabStrip:e.boolean().optional(),tabSetMinSize:e.number().optional()}),m=e.object({activeTabsetId:e.string().optional(),global:p,layout:f,maximizedTabsetId:e.string().optional(),version:e.literal(1)}),h=u.pick({config:!0,enableClose:!0,enableDrag:!0,enableRename:!0,name:!0}).partial(),g=d.pick({enableClose:!0,enableMaximize:!0,max:!0,min:!0,selected:!0,weight:!0}).partial(),ee=e.object({max:c.optional(),min:c.optional(),orientation:s,snap:l.optional(),weight:e.number()}).partial(),_=e.union([h,g,ee]),v=e.enum([`center`,`split-bottom`,`split-left`,`split-right`,`split-top`]),y=e.discriminatedUnion(`type`,[e.object({index:e.number().int().optional(),location:v,tab:u,targetId:e.string(),type:e.literal(`addNode`)}),e.object({index:e.number().int().optional(),location:v,sourceId:e.string(),targetId:e.string(),type:e.literal(`moveNode`)}),e.object({index:e.number().int().optional(),location:v,sourceId:e.string(),targetId:e.string(),type:e.literal(`moveTabset`)}),e.object({index:e.number().int(),tabsetId:e.string(),type:e.literal(`selectTab`)}),e.object({tabsetId:e.string(),type:e.literal(`setActiveTabset`)}),e.object({tabsetId:e.string().nullable(),type:e.literal(`setMaximizedTabset`)}),e.object({name:e.string(),tabId:e.string(),type:e.literal(`renameTab`)}),e.object({tabId:e.string(),type:e.literal(`deleteTab`)}),e.object({tabsetId:e.string(),type:e.literal(`deleteTabset`)}),e.object({rowId:e.string(),type:e.literal(`adjustSplit`),weights:e.array(e.number())}),e.object({attrs:_,nodeId:e.string(),type:e.literal(`updateNodeAttributes`)}),e.object({attrs:p.partial(),type:e.literal(`updateGlobalAttributes`)})]),b=(e=`node`)=>`${e}-${crypto.randomUUID()}`,te=()=>b(`tab`),x=(e,t)=>{for(let n of e.children)n.type===`tabset`?t.push(n):x(n,t)},S=e=>{let t=[];return x(e.layout,t),t},ne=e=>S(e)[0],C=(e,t)=>S(e).find(e=>e.id===t),re=(e,t)=>{let n=e.children.findIndex(e=>e.id===t);if(n===-1)return;let r=e.children[n];if(r)return{container:e,index:n,tab:r}},w=(e,t)=>{for(let n of S(e)){let e=re(n,t);if(e)return e}},T=(e,t)=>{if(e.id===t)return e;for(let n of e.children)if(n.type===`row`){let e=T(n,t);if(e)return e}},E=(e,t)=>{if(e.id===t)return e;for(let n of e.children){if(n.type===`row`){let e=E(n,t);if(e)return e;continue}if(n.id===t)return n;let e=n.children.find(e=>e.id===t);if(e)return e}},D=(e,t)=>E(e.layout,t),O=(e,t)=>{let n=e.children.findIndex(e=>e.type===`tabset`&&e.id===t);if(n!==-1)return{index:n,parent:e};for(let n of e.children)if(n.type===`row`){let e=O(n,t);if(e)return e}},k=(e,t)=>{t.push(e.id);for(let n of e.children)if(n.type===`row`)k(n,t);else{t.push(n.id);for(let e of n.children)t.push(e.id)}},A=e=>{let t=[];k(e.layout,t);let n=new Set,r=new Set;for(let e of t)n.has(e)&&r.add(e),n.add(e);return[...r]},j=e=>typeof e==`number`?{unit:`px`,value:e}:e,M=(e,t,n={})=>({component:e,name:t,type:`tab`,...n,id:n.id??e}),ie=(e,t={})=>{let{max:n,min:r,...i}=t;return{children:e,type:`tabset`,...i,...n===void 0?{}:{max:j(n)},...r===void 0?{}:{min:j(r)},id:t.id??b(`tabset`),selected:t.selected??0}},ae=(e,t={})=>{let{max:n,min:r,...i}=t;return{children:e,type:`row`,...i,...n===void 0?{}:{max:j(n)},...r===void 0?{}:{min:j(r)},id:t.id??b(`row`),orientation:t.orientation??`row`}},oe=(e,t={})=>{let n={layout:e,version:1,...t,global:t.global??{}},r=A(n);return r.length>0&&console.warn(`[dashfoo] builder produced duplicate node ids: ${r.join(`, `)} — pass explicit ids when reusing a component`),n},N=.22,se=(e,t)=>{let n=(e.x-t.x)/t.width,r=(e.y-t.y)/t.height;return{bottom:1-r,left:n,right:1-n,top:r}},ce=e=>{let t=Math.min(e.left,e.right,e.top,e.bottom);return t===e.left?`left`:t===e.right?`right`:t===e.top?`top`:`bottom`},le=(e,t,n)=>{let r=n?.bandFraction??N;if(t.width<=0||t.height<=0)return{kind:`tab`};let i=se(e,t);return Math.min(i.left,i.right,i.top,i.bottom)>r?{kind:`tab`}:{edge:ce(i),kind:`split`}},ue=(e,t)=>{let{height:n,width:r,x:i,y:a}=e,o={x:i,y:a},s={x:i+r,y:a},c={x:i+r,y:a+n},l={x:i,y:a+n};if(r<=0||n<=0)return[{location:`center`,points:[o,s,c,l]}];let u=t?.bandFraction??N,d=u*r,f=u*n,p={x:i+d,y:a+f},m={x:i+r-d,y:a+f},h={x:i+r-d,y:a+n-f},g={x:i+d,y:a+n-f};return[{location:`center`,points:[p,m,h,g]},{location:`split-left`,points:[o,p,g,l]},{location:`split-right`,points:[s,c,h,m]},{location:`split-top`,points:[o,s,m,p]},{location:`split-bottom`,points:[l,g,h,c]}]},de=(e,t)=>{let n=e.width/2,r=e.height/2;switch(t){case`split-bottom`:return{height:r,width:e.width,x:e.x,y:e.y+r};case`split-left`:return{height:e.height,width:n,x:e.x,y:e.y};case`split-right`:return{height:e.height,width:n,x:e.x+n,y:e.y};case`split-top`:return{height:r,width:e.width,x:e.x,y:e.y};default:return e}},fe=4,P=1e6,F=(e,t)=>{if(!(t<=0))for(let n=t;n<100;n+=t){let t=Math.round(n*P)/P;t<100&&e.add(t)}},I=(e,t)=>{let n=new Set;if(e.step!==void 0&&e.step>0&&F(n,e.step),e.divisions!==void 0){let r=e.divisions===`panels`?t:e.divisions;r>=2&&F(n,100/r)}return[...n].toSorted((e,t)=>e-t)},L=e=>e!==null&&((e.step??0)>0||e.divisions===`panels`||typeof e.divisions==`number`&&e.divisions>=2),R=(e,t)=>t.reduce((t,n)=>t===void 0||Math.abs(n-e)<Math.abs(t-e)?n:t,void 0),z=(e,t,n)=>{let r=n.threshold??4,i=e[t],a=e[t+1];if(t<0||i===void 0||a===void 0)return{sizes:e,snapped:!1};let o=I(n,e.length);if(o.length===0)return{sizes:e,snapped:!1};let s=0;for(let n=0;n<=t;n++)s+=e[n]??0;let c=R(s,o);if(c===void 0||Math.abs(c-s)>r)return{sizes:e,snapped:!1};let l=c-s;if(i+l<0||a-l<0)return{sizes:e,snapped:!1};let u=[...e];return u[t]=i+l,u[t+1]=a-l,{sizes:u,snapped:!0}},B=(e,t)=>{if(e===0)return 0;let n=Number.isFinite(t)?Math.trunc(t):0;return n<0?0:n>e-1?e-1:n},V=e=>({...e,selected:B(e.children.length,e.selected)}),H=e=>{let t=[];for(let n of e){if(n.type===`tabset`){n.children.length>0&&t.push(V(n));continue}let e=H(n.children);if(e.length!==0){if(e.length===1){let r=e[0];r!==void 0&&t.push(n.weight===void 0?r:{...r,weight:n.weight});continue}t.push({...n,children:e})}}return t},pe=e=>{let t=H(e.children),n=e.orientation,r=t[0];for(;t.length===1&&r?.type===`row`;)t=r.children,n=r.orientation,r=t[0];return{...e,children:t,orientation:n}},U=e=>{let t=pe(e.layout),n={...e,layout:t},r=new Set(S(n).map(e=>e.id)),i=S(n)[0]?.id,a=e.activeTabsetId!==void 0&&r.has(e.activeTabsetId)?e.activeTabsetId:i,o=e.maximizedTabsetId!==void 0&&r.has(e.maximizedTabsetId)?e.maximizedTabsetId:void 0;return{...n,activeTabsetId:a,maximizedTabsetId:o}},me=e=>{throw Error(`Unhandled action: ${JSON.stringify(e)}`)},W=(e,t)=>{let n=e.children.findIndex(e=>e.type===`tabset`&&e.id===t);if(n!==-1)return e.children.splice(n,1),!0;for(let n of e.children)if(n.type===`row`&&W(n,t))return!0;return!1},G=(e,t)=>{let n=e.children.findIndex(e=>e.type===`tabset`&&e.id===t);if(n!==-1){let[t]=e.children.splice(n,1);return t?.type===`tabset`?t:void 0}for(let n of e.children)if(n.type===`row`){let e=G(n,t);if(e)return e}},he=e=>e===`split-left`||e===`split-right`?`row`:`column`,ge=e=>e===`split-left`||e===`split-top`,K=(e,t,n,r)=>{let i=C(e,n),a=O(e.layout,n);if(!i||!a)return;let o=he(r),s=ge(r);if(a.parent.orientation===o){let e=i.weight??100;i.weight=e/2,t.weight=e/2,a.parent.children.splice(s?a.index:a.index+1,0,t)}else{let e=i.weight;i.weight=50,t.weight=50;let n={children:s?[t,i]:[i,t],id:b(`row`),orientation:o,type:`row`};e!==void 0&&(n.weight=e),a.parent.children.splice(a.index,1,n)}e.activeTabsetId=t.id},q=(e,t,n)=>{let{id:r,index:i,location:a}=n,o=C(e,r);if(o){if(a===`center`){let e=i??o.children.length;o.children.splice(e,0,t),o.selected=e;return}K(e,{children:[t],id:b(`tabset`),selected:0,type:`tabset`,weight:50},r,a)}},_e=(e,t)=>{switch(t.type){case`addNode`:q(e,t.tab,{id:t.targetId,index:t.index,location:t.location});return;case`adjustSplit`:{let n=T(e.layout,t.rowId);if(!n)return;for(let e=0;e<t.weights.length;e++){let r=n.children[e],i=t.weights[e];!r||i===void 0||(r.weight=i)}return}case`deleteTab`:{let n=w(e,t.tabId);n&&n.container.children.splice(n.index,1);return}case`deleteTabset`:W(e.layout,t.tabsetId);return;case`moveNode`:{let n=w(e,t.sourceId);if(!n)return;let[r]=n.container.children.splice(n.index,1);if(!r)return;q(e,r,{id:t.targetId,index:t.index,location:t.location});return}case`moveTabset`:{if(t.sourceId===t.targetId)return;let n=C(e,t.sourceId);if(!n)return;if(t.location===`center`){let r=C(e,t.targetId);if(r){let i=r.children.length,a=Math.min(Math.max(n.selected,0),n.children.length-1);r.children.push(...n.children),r.selected=i+a,W(e.layout,t.sourceId)}return}if(t.location.startsWith(`split-`)){let n=G(e.layout,t.sourceId);n&&K(e,n,t.targetId,t.location)}return}case`renameTab`:{let n=w(e,t.tabId);n&&(n.tab.name=t.name);return}case`selectTab`:{let n=C(e,t.tabsetId);n&&(n.selected=t.index);return}case`setActiveTabset`:C(e,t.tabsetId)&&(e.activeTabsetId=t.tabsetId);return;case`setMaximizedTabset`:e.maximizedTabsetId=t.tabsetId??void 0;return;case`updateGlobalAttributes`:Object.assign(e.global,t.attrs);return;case`updateNodeAttributes`:{let n=D(e,t.nodeId);n&&Object.assign(n,t.attrs);return}default:me(t)}},J=(e,t)=>{let n=structuredClone(e);return _e(n,t),U(n)},ve=100,Y=e=>({future:[],past:[],present:e}),ye=e=>e.past.length>0,be=e=>e.future.length>0,X=(e,t)=>{let n=J(e.present,t);return{future:[],past:[...e.past,e.present].slice(-100),present:n}},Z=e=>{let t=e.past.at(-1);return t===void 0?e:{future:[e.present,...e.future],past:e.past.slice(0,-1),present:t}},Q=e=>{let[t,...n]=e.future;return t===void 0?e:{future:n,past:[...e.past,e.present].slice(-100),present:t}},xe=r({types:{context:{},events:{},input:{}}}).createMachine({context:({input:e})=>({history:Y(e.model)}),id:`dashfoo`,initial:`ready`,states:{ready:{on:{DISPATCH:{actions:t({history:({context:e,event:t})=>X(e.history,t.action)})},REDO:{actions:t({history:({context:e})=>Q(e.history)})},SET_MODEL:{actions:t({history:({event:e})=>Y(e.model)})},UNDO:{actions:t({history:({context:e})=>Z(e.history)})}}}}}),Se=e=>{if(e.subject===null||e.intent===null)throw Error(`drop requires a subject and a drop intent`);return{intent:e.intent,subject:e.subject}},Ce=r({guards:{hasValidDrop:({context:e})=>e.subject!==null&&e.intent!==null},types:{context:{},emitted:{},events:{}}}).createMachine({context:{intent:null,subject:null},id:`dragDock`,initial:`idle`,states:{dragging:{on:{CANCEL:{target:`idle`},DROP:[{actions:n(({context:e})=>{let{intent:t,subject:n}=Se(e);return{action:n.kind===`external`?{index:t.index,location:t.location,tab:n.tab,targetId:t.targetId,type:`addNode`}:{index:t.index,location:t.location,sourceId:n.id,targetId:t.targetId,type:n.kind===`tabset`?`moveTabset`:`moveNode`},type:`COMMIT`}}),guard:`hasValidDrop`,target:`idle`},{target:`idle`}],OVER:{actions:t({intent:({event:e})=>e.intent})}}},idle:{entry:t({intent:null,subject:null}),on:{START:{actions:t({subject:({event:e})=>e.subject}),target:`dragging`}}}}}),$=e=>{let t=U(m.parse(e)),n=A(t);return n.length>0&&console.warn(`[dashfoo] duplicate node ids in the loaded layout: ${n.join(`, `)}`),t},we=e=>JSON.stringify(e),Te=e=>$(JSON.parse(e)),Ee=(e,t=`column`)=>{let n=[];for(let t of S(e))n.push({...t,weight:1});return U({...e,layout:{children:n,id:e.layout.id,orientation:t,type:`row`},maximizedTabsetId:void 0})};export{fe as DEFAULT_SNAP_THRESHOLD,ve as HISTORY_LIMIT,y as actionSchema,be as canRedo,ye as canUndo,S as collectTabsets,Y as createHistory,b as createNodeId,te as createTabId,xe as dashfooMachine,m as dashfooSchema,c as dimensionSchema,X as dispatch,v as dockLocationSchema,ue as dockZonePolygons,Ce as dragDockMachine,a as edgeSchema,D as findAttributedNode,A as findDuplicateIds,T as findRow,w as findTab,C as findTabset,O as findTabsetParent,Te as fromJSON,ne as getFirstTabset,p as globalAttributesSchema,i as jsonValueSchema,oe as model,_ as mutableNodeAttrsSchema,U as normalize,s as orientationSchema,$ as parseModel,Q as redo,J as reducer,le as resolveDockTarget,I as resolveSnapTargets,ae as row,f as rowNodeSchema,L as snapEnabled,l as snapSchema,z as snapSizes,Ee as stackModel,M as tab,u as tabNodeSchema,ie as tabset,d as tabsetNodeSchema,we as toJSON,Z as undo,o as unitSchema,de as zoneRect};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
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/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\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 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 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 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 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 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 TabNode,\n TabsetNode,\n Unit,\n};\n","import { z } from \"zod\";\n\nimport {\n dimensionSchema,\n globalAttributesSchema,\n orientationSchema,\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 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 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 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 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 { 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 target.children.push(...source.children);\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: { children, id: model.layout.id, orientation, type: \"row\" },\n maximizedTabsetId: undefined,\n });\n};\n\nexport { stackModel };\n"],"mappings":"6EAMA,MAAM,EAAwC,EAAE,SAC9C,EAAE,MAAM,CACN,EAAE,OAAO,EACT,EAAE,OAAO,EAC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,CAAE,OAAQ,KAAM,QAAS,IAAK,CAAC,EAC7C,GAAI,CACF,MAAO,CAAE,QAAS,EAAO,CAAE,SAAU,CAAE,WAAY,EAAM,OAAQ,CAAC,EAAG,OAAQ,UAAW,CAC1F,CACF,CACF,CACF,CAAC,EC/EK,EAAc,GAA4B,CAC9C,IAAM,EAAQ,EAAU,EAAc,MAAM,CAAK,CAAC,EAC5C,EAAa,EAAiB,CAAK,EAKzC,OAJI,EAAW,OAAS,GAEtB,QAAQ,KAAK,sDAAsD,EAAW,KAAK,IAAI,GAAG,EAErF,CACT,EAEM,EAAU,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/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: { children, id: model.layout.id, orientation, type: \"row\" },\n maximizedTabsetId: undefined,\n });\n};\n\nexport { stackModel };\n"],"mappings":"6EAMA,MAAM,EAAwC,EAAE,SAC9C,EAAE,MAAM,CACN,EAAE,OAAO,EACT,EAAE,OAAO,EACT,EAAE,QAAQ,EACV,EAAE,KAAK,EACP,EAAE,MAAM,CAAe,EACvB,EAAE,OAAO,EAAE,OAAO,EAAG,CAAe,CACtC,CAAC,CACH,EAEM,EAAa,EAAE,KAAK,CAAC,MAAO,SAAU,OAAQ,OAAO,CAAC,EACtD,EAAa,EAAE,KAAK,CAAC,KAAM,IAAK,KAAM,MAAO,KAAM,IAAI,CAAC,EACxD,EAAoB,EAAE,KAAK,CAAC,MAAO,QAAQ,CAAC,EAE5C,EAAkB,EAAE,OAAO,CAC/B,KAAM,EACN,MAAO,EAAE,OAAO,CAClB,CAAC,EASK,EAAa,EAAE,OAAO,CAC1B,UAAW,EAAE,MAAM,CAAC,EAAE,OAAO,EAAE,SAAS,EAAG,EAAE,QAAQ,QAAQ,CAAC,CAAC,EAAE,SAAS,EAC1E,KAAM,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS,EACjC,UAAW,EAAE,OAAO,EAAE,SAAS,EAAE,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,EAAO,SACjB,KAAM,EAAQ,OAAS,SAAW,aAAe,UACnD,EACW,KAAM,QAAS,CAClC,CAAC,EACD,MAAO,eACP,OAAQ,MACV,EACA,CAAE,OAAQ,MAAO,CACnB,EACA,KAAM,CAAE,QAAS,EAAO,CAAE,QAAS,CAAE,WAAY,EAAM,MAAO,CAAC,CAAE,CACnE,CACF,EACA,KAAM,CACJ,MAAO,EAAO,CAAE,OAAQ,KAAM,QAAS,IAAK,CAAC,EAC7C,GAAI,CACF,MAAO,CAAE,QAAS,EAAO,CAAE,SAAU,CAAE,WAAY,EAAM,OAAQ,CAAC,EAAG,OAAQ,UAAW,CAC1F,CACF,CACF,CACF,CAAC,EC/EK,EAAc,GAA4B,CAC9C,IAAM,EAAQ,EAAU,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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dashfoo/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
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>",
|