@n-uf/docking 0.0.0-stage → 26.11.54

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,98 @@
1
+ # @n-uf/docking
2
+
3
+ Versions are calendar versions, `YY.M.R` (year, month of the release, counter within the month), shared with
4
+ `@n-uf/motion` and `@n-uf/placement`: the packages carry the same version, and a release bumps them all. Before this
5
+ package, the docking model shipped as `@n-uf/placement/scene` and `/scene/cases`; their history is in
6
+ [placement's CHANGELOG](https://github.com/n-uf/motion/blob/main/packages/placement/CHANGELOG.md).
7
+
8
+ ## 26.11.54
9
+
10
+ The first release. The window's docking model moves here from `@n-uf/placement/scene`, and its conformance rows from
11
+ `@n-uf/placement/scene/cases` to `@n-uf/docking/testing`. Behavior is unchanged: for the same input, `solve`,
12
+ `targets`, `refusals`, `stops` and `lanes` give the same answers as `@n-uf/placement/scene` at its last state (26.11.53
13
+ and the fix below, unreleased there), and a stored state reads back to the same layout: the one exception is in form,
14
+ not in frames (a stored `floatSize` becomes `floatSizes`, see Removed). Each edge is fitted by `@n-uf/placement/stack`,
15
+ now this package's one dependency.
16
+
17
+ Fixed since `./scene` 26.11.53, on its release line when the model moved:
18
+ - **`endReach` only adds** (fix). With any `endReach` and an empty bar across a compact rail's end, the rail's end
19
+ target shrank to the reach strip past the stage and its own end third was refused; with an inset (rail outside it, or
20
+ the bar inside it) the predicted `entry` also stopped at the two-thirds line. A reach strip cut off from its zone's own
21
+ room now takes no slot line and joins the zone's outermost slot (past a drawn bar it stops at the bar), and an edge's
22
+ reach never takes another edge's own span. A column's footer gap under an empty bar no longer vanishes with reach:
23
+ the panel bodies' cut places its line within the column's drawn ends, as the tiler does. The start side and both rails
24
+ alike. New tests `rail-end-reach` and `end-reach-targets`; the pinned marks fixture's rail and bar boxes now run to
25
+ the edge's end.
26
+
27
+ Host notes: install `@n-uf/docking`, change the imports, and apply the renames below (each a rename only, with the
28
+ same shape and meaning). A stored state from `storeScene` reads back with `readDockState` unchanged (the stored form
29
+ and its version are the same), but for one field: a stored `floatSize` reads back as `floatSizes` (see `floatSize`
30
+ under Removed). `@n-uf/docking/testing`'s types name `@n-uf/motion/drag`'s: `@n-uf/motion` is an optional peer
31
+ dependency, needed only by a suite that runs the landing rows. The edge-id error's prefix is `docking:` (it was
32
+ `placement:`): a host that matches the message changes the prefix.
33
+
34
+ Entries:
35
+ - `@n-uf/placement/scene` → `@n-uf/docking`.
36
+ - `@n-uf/placement/scene/cases` → `@n-uf/docking/testing`.
37
+
38
+ The model's types:
39
+ - `Scene` → `DockState`; `Edge` → `DockEdge`; `SceneItem` → `DockItem`; `SceneFloat` → `DockFloat`.
40
+ - `SceneChrome` → `KeepClear`, and the dock state's field `chrome` → `keepClear` (same rects, same `for` scope).
41
+ - The fields 26.11.52 added keep their names on the renamed types: `DockItem.pushable`, `DockItem.floatSizes`,
42
+ `DockItemLayout.axis`.
43
+ - Added: **`DockItemLayout.tiers`**, the chosen form's `StackForm.tiers` (`@n-uf/placement/stack`'s `controlLadder`
44
+ sets them), beside `hidden`: each shown control's tier by id, so a host draws each control at `tiers[id]` without
45
+ knowing the ladder's order. Absent for a hand-written form, a `fold`, a `menu` and a » menu entry.
46
+ - Removed: **`SceneItem.floatSize`**, deprecated in 26.11.52. `floatSize` → `floatSizes[orient]`: declare the size for
47
+ the orient the item floats in (both orients where it floats either way). A state stored with it still reads, and
48
+ `storeDockState` writes `floatSizes` only. `readDockState` takes a stored `floatSize` as:
49
+ - on an item the store docks: `floatSizes[floatOrientOf(item)]`, unless the store sizes that orient itself, so the
50
+ user's float size survives the upgrade for the next float-out (a float target, `floatAt` with no rect);
51
+ - on a float whose store gives `floatSizes`: the size for the orient the float is in, unless the store sizes it;
52
+ - on a float whose store gives no `floatSizes`: nothing. It is dropped (`item:<id>:floatSize`), and the float stays
53
+ framed at its stored rect, as before (a size there would replace that frame).
54
+ - `floatSizeOf(item, orient?)` and `floatSizesOf(item)` lose the orient the old size was set in (it was the legacy
55
+ `floatSize`'s).
56
+ - `SceneLayout` → `DockLayout`; `SceneItemLayout` → `DockItemLayout`; `SceneEdgeLayout` → `DockEdgeLayout`;
57
+ `SceneRailLayout` → `DockRailLayout`; `SceneNote` → `DockNote`; `SceneNoteCode` → `DockNoteCode`.
58
+ - `StoredScene` → `StoredDockState`; `StoredSceneEdge` → `StoredDockStateEdge`; `StoredSceneFloat` →
59
+ `StoredDockStateFloat`; `StoredSceneItem` → `StoredDockStateItem`; `SceneRead` → `DockStateRead`, whose field
60
+ `scene` is now `state` (`readDockState(data, base).state`).
61
+
62
+ Targets and lanes:
63
+ - `SceneTarget` → `DockDrop`; `SceneTargetOptions` → `DockDropOptions`; `ScenePlace` → `DropPlace`; `SceneAfter` →
64
+ `DropResult`, whose field `scene` is now `state` (`after(point, grab).state`).
65
+ - `SceneRefusal` → `DockRefusal`; `SceneRefusalTarget` → `DockRefusalTarget`.
66
+ - `Regions` → `DockRegions`; `Lane` → `DockLane`; `LaneSpot` → `DockSpot`; `LaneMark` → `DockMark`; `LaneOptions` →
67
+ `DockLaneOptions`. `LaneRefusal` and `LaneSlide` keep their names, and `Lane.entry` and `Lane.corners` are
68
+ `DockLane.entry` and `DockLane.corners`.
69
+
70
+ Functions:
71
+ - `storeScene` → `storeDockState`; `readScene` → `readDockState`.
72
+ - `fold` → `foldItem`; `use` → `markUsed`; `keep` → `keepItem`; `open` → `openItem`; `close` → `closeItem`; `lift` →
73
+ `liftItem`; `raise` → `raiseFloat`; `orient` → `orientFloat`.
74
+ - `resize` splits in two by what it resizes: `resize(state, edgeId, size)` → `resizeEdge(state, edgeId, size)`, and
75
+ `resize(state, floatId, rect, moving?)` → `resizeFloat(state, floatId, rect, moving?)`.
76
+ - `fitFloat` and `FloatFit` are no longer re-exported here: import them from `@n-uf/placement/stack`.
77
+
78
+ What the model reads of a form: the form flags `body`, `folded` and `compact` from `@n-uf/placement/stack` (each
79
+ defaulting from the kind as before: `open`; `header` and `fold`; `icons`). A host that sets none sees no change.
80
+
81
+ Testing (`@n-uf/docking/testing`):
82
+ - `createSceneHost` → `createReferenceHost`; `SceneHost` → `ReferenceHost`, whose method `scene()` is now `state()`;
83
+ `SceneHostOptions` → `ReferenceHostOptions`.
84
+ - `resizeStep(state, start, layout, gesture)` returns `{ state, start }` (its field `scene` is now `state`).
85
+ - `mapScene` → `mapState`; `winScene` → `winState`.
86
+ - A row's field `scene` → `state` (`CaseRow.state`, `LandingCase.state`), and a `CaseHost` loads with
87
+ `load(state, settings)`. `CaseRequires.railDrop`'s one value is now `"state"`.
88
+ - Added: **`AssertLanding<R>`**, a type that compiles only while `R` fits `@n-uf/motion/drag`'s `LandingRegions`
89
+ (`AssertLanding<DockRegions>` is checked in this package's tests). A type only: no runtime import of motion.
90
+ - Removed: `pickTarget`, the deprecated default pick. Pass `@n-uf/motion/drag`'s `targetAt` as `pick` (the reference
91
+ host's default stays the same rule).
92
+ - Kept as 26.11.52 shipped them: the hand rule (`handBound`, `HAND_TRAIL`, `HAND_TRAIL_BEFORE_HOP`, `HAND_MARGIN`,
93
+ `HAND_FAST`, a row's `moving.hand`) and the Near guides' rule (`nearGuideIssues`, `NEAR_REACH`, a row's
94
+ `moving.nearGuides` and `moving.guideSwitches`, `end.pending`, `end.landing`, `LandingCaseFrame.pending`).
95
+ - Removed: the release bookkeeping, `LANES_SINCE`, `GRAB_SINCE`, `GRIP_SINCE`, `ROOM_SINCE`, `STEP_SINCE`, `NEAR_SINCE`, `LAST_WITHOUT_LANES`,
96
+ `LANES_DEADLINE` and `lanesRatchet`, with `CaseRequires.lanes` (`requires.lanes.since`), `LandingCaseHost.version`
97
+ and `createLandingHost`'s `version` option. Every landing row runs on every host: drop the ratchet from your suite
98
+ and assert that no row fails.
package/LICENSE ADDED
@@ -0,0 +1,129 @@
1
+ # PolyForm Perimeter License 1.0.1
2
+
3
+ Required Notice: Copyright (c) 2026 n-uf
4
+
5
+ ## Acceptance
6
+
7
+ In order to get any license under these terms, you must agree
8
+ to them as both strict obligations and conditions to all
9
+ your licenses.
10
+
11
+ ## Copyright License
12
+
13
+ The licensor grants you a copyright license for the
14
+ software to do everything you might do with the software
15
+ that would otherwise infringe the licensor's copyright
16
+ in it for any permitted purpose. However, you may
17
+ only distribute the software according to [Distribution
18
+ License](#distribution-license) and make changes or new works
19
+ based on the software according to [Changes and New Works
20
+ License](#changes-and-new-works-license).
21
+
22
+ ## Distribution License
23
+
24
+ The licensor grants you an additional copyright license
25
+ to distribute copies of the software. Your license
26
+ to distribute covers distributing the software with
27
+ changes and new works permitted by [Changes and New Works
28
+ License](#changes-and-new-works-license).
29
+
30
+ ## Notices
31
+
32
+ You must ensure that anyone who gets a copy of any part of
33
+ the software from you also gets a copy of these terms or the
34
+ URL for them above, as well as copies of any plain-text lines
35
+ beginning with `Required Notice:` that the licensor provided
36
+ with the software. For example:
37
+
38
+ > Required Notice: Copyright Yoyodyne, Inc. (http://example.com)
39
+
40
+ ## Changes and New Works License
41
+
42
+ The licensor grants you an additional copyright license to
43
+ make changes and new works based on the software for any
44
+ permitted purpose.
45
+
46
+ ## Patent License
47
+
48
+ The licensor grants you a patent license for the software that
49
+ covers patent claims the licensor can license, or becomes able
50
+ to license, that you would infringe by using the software.
51
+
52
+ ## Noncompete
53
+
54
+ Any purpose is a permitted purpose, except for providing to
55
+ others any product that competes with the software.
56
+
57
+ ## Competition
58
+
59
+ If you use this software to market a product as a substitute
60
+ for the functionality or value of the software, it competes
61
+ with the software. A product may compete regardless how it
62
+ is designed or deployed. For example, a product may compete
63
+ even if it provides its functionality via any kind of interface
64
+ (including services, libraries or plug-ins), even if it is
65
+ ported to a different platform or programming language, and
66
+ even if it is provided free of charge.
67
+
68
+ ## Fair Use
69
+
70
+ You may have "fair use" rights for the software under the
71
+ law. These terms do not limit them.
72
+
73
+ ## No Other Rights
74
+
75
+ These terms do not allow you to sublicense or transfer any of
76
+ your licenses to anyone else, or prevent the licensor from
77
+ granting licenses to anyone else. These terms do not imply
78
+ any other licenses.
79
+
80
+ ## Patent Defense
81
+
82
+ If you make any written claim that the software infringes or
83
+ contributes to infringement of any patent, your patent license
84
+ for the software granted under these terms ends immediately. If
85
+ your company makes such a claim, your patent license ends
86
+ immediately for work on behalf of your company.
87
+
88
+ ## Violations
89
+
90
+ The first time you are notified in writing that you have
91
+ violated any of these terms, or done anything with the software
92
+ not covered by your licenses, your licenses can nonetheless
93
+ continue if you come into full compliance with these terms,
94
+ and take practical steps to correct past violations, within
95
+ 32 days of receiving notice. Otherwise, all your licenses
96
+ end immediately.
97
+
98
+ ## No Liability
99
+
100
+ ***As far as the law allows, the software comes as is, without
101
+ any warranty or condition, and the licensor will not be liable
102
+ to you for any damages arising out of these terms or the use
103
+ or nature of the software, under any kind of legal claim.***
104
+
105
+ ## Definitions
106
+
107
+ The **licensor** is the individual or entity offering these
108
+ terms, and the **software** is the software the licensor makes
109
+ available under these terms.
110
+
111
+ A **product** can be a good or service, or a combination
112
+ of them.
113
+
114
+ **You** refers to the individual or entity agreeing to these
115
+ terms.
116
+
117
+ **Your company** is any legal entity, sole proprietorship,
118
+ or other kind of organization that you work for, plus all
119
+ organizations that have control over, are under the control of,
120
+ or are under common control with that organization. **Control**
121
+ means ownership of substantially all the assets of an entity,
122
+ or the power to direct its management and policies by vote,
123
+ contract, or otherwise. Control can be direct or indirect.
124
+
125
+ **Your licenses** are all the licenses granted to you for the
126
+ software under these terms.
127
+
128
+ **Use** means anything you do with the software requiring one
129
+ of your licenses.
package/README.md CHANGED
@@ -1,3 +1,97 @@
1
- # Temporary Holding Version
1
+ # @n-uf/docking
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ > [!CAUTION]
4
+ > ## Not yet stable
5
+ >
6
+ > **@n-uf/docking is young and still changing. Its API (the dock state and its solver, the drop targets and lanes, the conformance rows) is not final.**
7
+ >
8
+ > Version numbers are dates (YY.M.R), not semantic versions, so any release may break things. Pin an exact version and read the [CHANGELOG](https://github.com/n-uf/motion/blob/main/packages/docking/CHANGELOG.md) before you upgrade.
9
+
10
+ Where panels and toolbars dock. A window's edges (bars, rails and columns), items and floats are one plain-data model, a dock state, solved into a layout; every drag gets its drop targets, refusals and lanes, each target carrying the state and layout a release there makes, so the preview is the result. Pure functions over plain data, with no DOM, no framework and no motion; one dependency, [`@n-uf/placement`](https://www.npmjs.com/package/@n-uf/placement), which fits each edge. Rendering stays in the app: it draws the rects, measures its items and feeds pointer samples to a drag intent.
11
+
12
+ ```sh
13
+ npm i @n-uf/docking @n-uf/placement
14
+ ```
15
+
16
+ ## Entry points
17
+
18
+ | Entry | What it gives |
19
+ |---|---|
20
+ | `@n-uf/docking` | One model of a whole window: `solve` for every rect, `targets` and `refusals` for every drag, `lanes` for a landing model, pure changes (`moveTo`, `foldItem`, `floatAt`, `resizeEdge`, ...) and a stored form (`storeDockState`, `readDockState`). |
21
+ | `@n-uf/docking/testing` | Conformance rows (`CASES`, `LANDING_CASES`), runners (`runCase`, `runLandingCases`) and reference hosts (`createReferenceHost`, `createLandingHost`) that a host's test suite plays against the model, and `AssertLanding`, a type check that the lanes fit `@n-uf/motion/drag`'s landing model. |
22
+
23
+ Items declare their forms in `@n-uf/placement/stack`'s vocabulary (`StackForm`).
24
+
25
+ ## A window
26
+
27
+ A dock state is the stage, its edges, the items with their forms, the floats and the rects they keep clear of. `solve` gives every rect to draw; `targets` gives every drop target for one item, and a drop's `after()` is the state to store and the layout to draw.
28
+
29
+ ```ts
30
+ import { readDockState, solve, storeDockState, targets, type DockItem, type DockState } from "@n-uf/docking";
31
+ import type { StackForm } from "@n-uf/placement/stack";
32
+
33
+ const f = (kind: StackForm["kind"], min: number, natural: number, cross: number, more: Partial<StackForm> = {}): StackForm => ({ kind, main: { min, natural }, cross: { natural: cross }, ...more });
34
+ const panel = (id: string, used: number): DockItem => ({
35
+ id, kind: "panel", used,
36
+ forms: { column: [f("open", 120, 240, 260, { main: { min: 120, natural: 240, grows: true }, cross: { natural: 260, min: 180 } }), f("header", 28, 28, 260, { cross: { natural: 260, min: 60 } }), f("rail", 28, 28, 30), f("menu", 0, 0, 0)] },
37
+ });
38
+ const group = (id: string, used: number, align?: "end"): DockItem => ({
39
+ id, kind: "group", used, ...(align ? { align } : {}),
40
+ forms: { row: [f("row", 180, 200, 28), f("icons", 84, 84, 28), f("menu", 0, 0, 0)], column: [f("stacked", 96, 96, 84), f("icons", 84, 84, 28), f("menu", 0, 0, 0)] },
41
+ });
42
+ const fixed = (id: string, kind: string, form: StackForm, align?: "center" | "end"): DockItem => ({ id, kind, used: 0, fixed: true, forms: { row: [form] }, ...(align ? { align } : {}) });
43
+ const bar = { accepts: ["group"], cross: { min: 36, max: 36, rail: 36 }, gap: 4, pad: { start: 8, end: 8 } };
44
+ const column = { accepts: ["panel", "group"], cross: { min: 160, max: 480, rail: 30 } };
45
+ const items = [
46
+ fixed("title", "title", f("row", 80, 160, 32, { main: { min: 80, natural: 160, grows: true } })),
47
+ fixed("controls", "controls", f("row", 84, 84, 32), "end"),
48
+ fixed("readout", "readout", f("row", 72, 72, 28), "center"),
49
+ panel("pages", 1), panel("findings", 2), panel("notes", 3),
50
+ group("views", 4), group("tools", 5), group("zoom", 6, "end"), group("search", 7, "end"), group("marks", 8),
51
+ ];
52
+ const state: DockState = {
53
+ stage: { x: 0, y: 0, width: 1200, height: 800 },
54
+ edges: [
55
+ { id: "titlebar", side: "top", ring: 0, accepts: ["group"], items: ["title", "controls"], cross: { min: 32, max: 32, rail: 32 } },
56
+ { id: "toolbar", side: "top", ring: 1, items: ["views", "tools", "zoom"], ...bar },
57
+ { id: "status", side: "bottom", ring: 0, span: "between", items: ["readout", "search"], ...bar, cross: { min: 28, max: 28, rail: 28 } },
58
+ { id: "left", side: "left", ring: 0, items: ["pages"], ...column },
59
+ { id: "right", side: "right", ring: 0, items: ["findings", "marks"], ...column },
60
+ ],
61
+ items: Object.fromEntries(items.map((it) => [it.id, it])),
62
+ floats: [{ id: "notes", rect: { x: 500, y: 200, width: 280, height: 320 } }],
63
+ floatKinds: ["panel", "group"],
64
+ };
65
+ const layout = solve(state);
66
+ console.log(layout.content); // { x: 260, y: 68, width: 680, height: 704 }
67
+ const drops = targets(state, "views", { previous: layout });
68
+ const drop = drops.find((t) => t.id === "gap:right:start:2")!.after({ x: 0, y: 0 });
69
+ console.log(JSON.stringify(solve(drop.state, { previous: layout })) === JSON.stringify(drop.layout)); // true
70
+ console.log(readDockState(JSON.parse(JSON.stringify(storeDockState(drop.state))), state).dropped); // []
71
+ ```
72
+
73
+ ## Testing a host
74
+
75
+ ```ts
76
+ import { targetAt } from "@n-uf/motion/drag";
77
+ import { CASES, createReferenceHost, runCases } from "@n-uf/docking/testing";
78
+
79
+ const results = runCases(CASES, () => createReferenceHost({ pick: targetAt })); // a page's host plays the same rows
80
+ ```
81
+
82
+ The landing rows (`LANDING_CASES`, `runLandingCases`) check a host that drags with `@n-uf/motion/drag`'s landing model,
83
+ the hand rule included: while a lane holds, the landing is the nearest in its lane to the pointer, within
84
+ `handBound(g)` = `max(48, g / 2 + 6)` px of it ([decision 0001](https://github.com/n-uf/motion/blob/main/docs/decisions/0001-the-hand-rule.md)).
85
+
86
+ ## Documentation
87
+
88
+ - [Design page](https://github.com/n-uf/motion/blob/main/docs/docking.md): the concept, the parts, the rules a consumer relies on, and the SDK entry by entry.
89
+ - [Reference](https://github.com/n-uf/motion/blob/main/docs/docking-reference.md): every rule, id, option and longer examples.
90
+ - [CHANGELOG](https://github.com/n-uf/motion/blob/main/packages/docking/CHANGELOG.md): what changed, and how to move from `@n-uf/placement/scene`.
91
+ - Site and live demos: [motion.n-uf.com](https://motion.n-uf.com)
92
+
93
+ Its siblings: [`@n-uf/placement`](https://www.npmjs.com/package/@n-uf/placement) fits one edge, [`@n-uf/motion`](https://www.npmjs.com/package/@n-uf/motion) owns how things move.
94
+
95
+ ## License
96
+
97
+ [PolyForm Perimeter 1.0.1](https://github.com/n-uf/motion/blob/main/LICENSE).