dsh-panel-dock 0.0.0-stage → 1.0.42
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/LICENSE +21 -0
- package/README.md +231 -2
- package/client.js +1868 -0
- package/cordis.patch.yml +7 -0
- package/dock-core.js +104 -0
- package/index.js +2 -0
- package/package.json +48 -4
package/cordis.patch.yml
ADDED
package/dock-core.js
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
// Pure model of the band placement rules that client.js implements at runtime.
|
|
2
|
+
//
|
|
3
|
+
// client.js is the single source of truth (it runs inside the web client and cannot
|
|
4
|
+
// import this file), so this module exists to make those rules testable and to guard
|
|
5
|
+
// against silent drift: test/dock.test.js asserts both the behaviour below and that
|
|
6
|
+
// the constants still match the ones literally written in client.js.
|
|
7
|
+
//
|
|
8
|
+
// Since 0.6.0 there is no user-resizable width, no collapse flag and no persisted
|
|
9
|
+
// layout: the band is planned from what the window can afford on every frame.
|
|
10
|
+
|
|
11
|
+
export const GAP = 6
|
|
12
|
+
export const MIN_WIDTH_FLOOR = 120
|
|
13
|
+
export const MAX_COVER_RATIO = 0.5
|
|
14
|
+
export const MAX_PANEL_WIDTH = 480
|
|
15
|
+
export const DEFAULT_MIN_WIDTH = 280
|
|
16
|
+
|
|
17
|
+
// A view that hides its splitter keeps the element in the DOM at 0x0. Measuring it
|
|
18
|
+
// yields left/right = 0, which once dragged the band to the window corner; anchors
|
|
19
|
+
// only count when they have real area.
|
|
20
|
+
export function isVisibleAnchor(rect) {
|
|
21
|
+
return Boolean(rect) && rect.width > 0 && rect.height > 0
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// The turn rail is a column of buttons. Short conversations have few of them, but
|
|
25
|
+
// they still share one x; a single stray button (轨迹/看板 leave one floating) must
|
|
26
|
+
// not be mistaken for the rail.
|
|
27
|
+
export function railColumn(marks) {
|
|
28
|
+
const list = Array.isArray(marks) ? marks.filter((m) => m && Number.isFinite(m.left)) : []
|
|
29
|
+
if (!list.length) return null
|
|
30
|
+
const groups = []
|
|
31
|
+
for (const mark of list) {
|
|
32
|
+
const group = groups.find((g) => Math.abs(g.left - mark.left) <= 2)
|
|
33
|
+
if (group) {
|
|
34
|
+
group.count += 1
|
|
35
|
+
group.right = Math.max(group.right, mark.right || mark.left)
|
|
36
|
+
} else {
|
|
37
|
+
groups.push({ left: mark.left, right: mark.right || mark.left, count: 1 })
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
const columns = groups.filter((g) => g.count >= 4).sort((x, y) => (y.count - x.count) || (x.left - y.left))
|
|
41
|
+
if (columns.length) return columns[0]
|
|
42
|
+
const short = groups.filter((g) => g.count >= 2).sort((x, y) => (y.count - x.count) || (x.left - y.left))
|
|
43
|
+
return short.length ? short[0] : null
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// A main-area page (Memory, settings, a plugin panel, 轨迹/看板) has no conversation
|
|
47
|
+
// column to measure, so the band is laid out against the page content boundary.
|
|
48
|
+
export function pagePlan(anchors, required, top, options) {
|
|
49
|
+
const opts = options || {}
|
|
50
|
+
const vw = Number.isFinite(opts.vw) ? opts.vw : 0
|
|
51
|
+
const last = Number.isFinite(opts.lastWidth) ? opts.lastWidth : 0
|
|
52
|
+
const limit = Math.min(vw, anchors && anchors.areaRight ? anchors.areaRight : vw) - GAP
|
|
53
|
+
const desired = Math.min(MAX_PANEL_WIDTH, Math.max(required, last || required))
|
|
54
|
+
let width = desired
|
|
55
|
+
const contentRight = anchors && Number.isFinite(anchors.pageRight) ? anchors.pageRight : null
|
|
56
|
+
if (contentRight !== null) {
|
|
57
|
+
const gutter = vw - contentRight - GAP * 2
|
|
58
|
+
if (gutter >= required) width = Math.min(desired, gutter)
|
|
59
|
+
}
|
|
60
|
+
return { mode: 'page', top, rightEdge: limit, width, limit }
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function planBand(anchors, required, options) {
|
|
64
|
+
const opts = options || {}
|
|
65
|
+
const vw = Number.isFinite(opts.vw) ? opts.vw : 0
|
|
66
|
+
const limit = Math.min(vw, anchors && anchors.areaRight ? anchors.areaRight : vw) - GAP
|
|
67
|
+
const hasSurface = Boolean(anchors) && (
|
|
68
|
+
anchors.tabsSeen === true
|
|
69
|
+
|| Number.isFinite(anchors.handleRight)
|
|
70
|
+
|| Number.isFinite(anchors.areaRight)
|
|
71
|
+
|| Number.isFinite(anchors.railRight)
|
|
72
|
+
)
|
|
73
|
+
if (!hasSurface) return pagePlan(anchors, required, (anchors && anchors.pageTop) || 56, opts)
|
|
74
|
+
const hasRail = Boolean(anchors) && Number.isFinite(anchors.railRight)
|
|
75
|
+
// 轨迹 / 看板 are conversation views with tabs but no turn rail: stay on the same
|
|
76
|
+
// right edge, at the conversation own top, with the familiar width.
|
|
77
|
+
if (!hasRail && anchors && anchors.tabsSeen === true) {
|
|
78
|
+
return pagePlan(anchors, required, anchors.top || 8, opts)
|
|
79
|
+
}
|
|
80
|
+
const innerRight = anchors && Number.isFinite(anchors.right) ? anchors.right : limit
|
|
81
|
+
const inner = anchors && Number.isFinite(anchors.left) ? innerRight - anchors.left : null
|
|
82
|
+
if (inner !== null && inner >= required) {
|
|
83
|
+
return { mode: 'inner', left: anchors.left, width: Math.min(inner, MAX_PANEL_WIDTH), limit }
|
|
84
|
+
}
|
|
85
|
+
const outer = hasRail ? limit - (anchors.railRight + GAP) : null
|
|
86
|
+
if (outer !== null && outer >= required) {
|
|
87
|
+
return { mode: 'outer', rightEdge: limit, width: Math.min(outer, MAX_PANEL_WIDTH), limit }
|
|
88
|
+
}
|
|
89
|
+
// No whitespace fits: take the minimum out of the transcript, but never cover more
|
|
90
|
+
// than half of the conversation column -- past that the card belongs in the sidebar.
|
|
91
|
+
const column = anchors && anchors.areaRight && anchors.areaLeft
|
|
92
|
+
? Math.max(1, anchors.areaRight - anchors.areaLeft)
|
|
93
|
+
: Math.max(1, vw - 2 * GAP)
|
|
94
|
+
if (required > column * MAX_COVER_RATIO) return { mode: 'fallback', width: 0, limit }
|
|
95
|
+
return { mode: 'intrude', rightEdge: limit, width: required, limit }
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Effective side: the panel declares a preference, the user can move it, and a
|
|
99
|
+
// band that cannot exist (fallback) sends right-preferring cards to the left stack.
|
|
100
|
+
export function sideOf(preferred, userSide, fallback) {
|
|
101
|
+
const base = userSide === 'left' || userSide === 'right' ? userSide : preferred
|
|
102
|
+
if (base === 'right' && fallback) return 'left'
|
|
103
|
+
return base === 'left' ? 'left' : 'right'
|
|
104
|
+
}
|
package/index.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,50 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-panel-dock",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.0.42",
|
|
4
|
+
"description": "One owner for plugin panels: a real right-hand column beside the conversation, plus a managed left stack.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"author": "Awenforever",
|
|
8
|
+
"homepage": "https://github.com/Awenforever/dsh-panel-dock#readme",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/Awenforever/dsh-panel-dock.git"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"dsh",
|
|
15
|
+
"dsh-plugin",
|
|
16
|
+
"deepseek-harness",
|
|
17
|
+
"panel",
|
|
18
|
+
"dock",
|
|
19
|
+
"layout"
|
|
20
|
+
],
|
|
21
|
+
"exports": {
|
|
22
|
+
".": "./index.js",
|
|
23
|
+
"./client": "./client.js",
|
|
24
|
+
"./dock-core": "./dock-core.js",
|
|
25
|
+
"./package.json": "./package.json"
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"index.js",
|
|
29
|
+
"client.js",
|
|
30
|
+
"dock-core.js",
|
|
31
|
+
"cordis.patch.yml",
|
|
32
|
+
"README.md",
|
|
33
|
+
"LICENSE"
|
|
34
|
+
],
|
|
35
|
+
"engines": {
|
|
36
|
+
"dsh": ">=0.2.2-rc.1 <0.3.0-0"
|
|
37
|
+
},
|
|
38
|
+
"scripts": {
|
|
39
|
+
"test": "node --test test/dock.test.js"
|
|
40
|
+
},
|
|
41
|
+
"dsh": {
|
|
42
|
+
"bundle": {
|
|
43
|
+
"patch": "./cordis.patch.yml"
|
|
44
|
+
},
|
|
45
|
+
"client": {
|
|
46
|
+
"platform": "web",
|
|
47
|
+
"immediately": true
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|