@linxin666/dsh-client-ui-task-board 0.4.13 → 0.4.15
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.i18n.yaml +2 -2
- package/README.md +4 -4
- package/README.zh.md +4 -4
- package/lib/client.js +244 -264
- package/lib/client.js.map +1 -1
- package/lib/index.js +36 -11
- package/lib/types/client/board/source-group.d.ts +27 -0
- package/lib/types/client/locales.d.ts +1 -0
- package/lib/types/client/pending-verify.d.ts +47 -0
- package/lib/types/client/plugin-card-seat.d.ts +1 -1
- package/lib/types/client/service.d.ts +4 -1
- package/lib/types/core/controller.d.ts +7 -1
- package/lib/types/core/extension.d.ts +14 -0
- package/lib/types/host-routes.d.ts +6 -0
- package/lib/types/index.d.ts +1 -1
- package/package.json +28 -28
- package/src/client/board/TaskBoard.tsx +47 -10
- package/src/client/board/source-group.ts +94 -0
- package/src/client/board.module.css +17 -0
- package/src/client/host-api.ts +7 -0
- package/src/client/index.ts +11 -10
- package/src/client/locales.ts +2 -0
- package/src/client/pending-verify.ts +90 -0
- package/src/client/plugin-card-seat.ts +2 -2
- package/src/client/service.ts +24 -0
- package/src/core/controller.ts +18 -0
- package/src/core/extension.ts +16 -0
- package/src/host-routes.ts +46 -11
- package/src/index.ts +1 -1
- package/lib/types/client/suppress-schedule-row.d.ts +0 -86
- package/src/client/suppress-schedule-row.ts +0 -198
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Hide the official automation-tasks entry while the board is on.
|
|
3
|
-
*
|
|
4
|
-
* The shell mounts two scheduling surfaces side by side in the sidebar: the
|
|
5
|
-
* official `ui-schedule` client half ("Automation tasks" — the Host Schedule
|
|
6
|
-
* service's own page) and this package's board ("Task board" — a Host ledger
|
|
7
|
-
* that runs real DSH sessions). The board is the family's complete surface, so
|
|
8
|
-
* while it is enabled the official row is hidden and the sidebar offers one
|
|
9
|
-
* scheduling entry instead of two.
|
|
10
|
-
*
|
|
11
|
-
* The shell owns that row: it renders the button, the label, the tooltip, the
|
|
12
|
-
* active highlight and the collapsed rail, and the host's own end-to-end suite
|
|
13
|
-
* addresses the row by its accessible name. The row is therefore located the
|
|
14
|
-
* same way — the shell's global panel list seat (`sidebar.panellist`), whose
|
|
15
|
-
* per-row anchor the slot renderer stamps — and it is identified by the label
|
|
16
|
-
* the shell itself resolves for that entry (`resolveSlotLabel`, exactly the
|
|
17
|
-
* call the shell's panel projection makes), so the match follows the active
|
|
18
|
-
* language instead of a hard-coded translation.
|
|
19
|
-
*
|
|
20
|
-
* The write is one inline `display: none` on the shell's own button: the row
|
|
21
|
-
* stays mounted (React keeps owning it) and the official panel keeps working
|
|
22
|
-
* everywhere else it is reachable — only the duplicate sidebar entry goes
|
|
23
|
-
* away. The board's master switch owns the state, exactly as it owns the
|
|
24
|
-
* board's own row: with the board off, the official row comes back.
|
|
25
|
-
*/
|
|
26
|
-
|
|
27
|
-
import { resolveSlotLabel, type StoredEntry } from '@deepseek-ai/dsh-client-ui-slots'
|
|
28
|
-
import { subscribeBodyInvalidations } from './body-mutations.ts'
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* The official automation-tasks panel id.
|
|
32
|
-
*
|
|
33
|
-
* The host `ui-schedule` client half registers its sidebar row and its
|
|
34
|
-
* center-column page under this id; the shell's panel projection addresses
|
|
35
|
-
* both by it.
|
|
36
|
-
*/
|
|
37
|
-
export const OFFICIAL_SCHEDULE_PANEL_ID = 'schedules'
|
|
38
|
-
|
|
39
|
-
/** The shell's global panel list seat; every rendered panel row carries one anchor. */
|
|
40
|
-
const PANEL_LIST_SLOT = 'sidebar.panellist'
|
|
41
|
-
|
|
42
|
-
/** The anchor the slot renderer stamps for each global panel row. */
|
|
43
|
-
const PANEL_ROW_ANCHOR = `[data-slot="${PANEL_LIST_SLOT}"]`
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* The family's own hook on a plugin-owned panel row.
|
|
47
|
-
*
|
|
48
|
-
* A row carrying it belongs to a plugin that owns its entry, never to the
|
|
49
|
-
* official automation-tasks row, so the guard skips those rows: it must not
|
|
50
|
-
* be able to hide the board's own entry.
|
|
51
|
-
*/
|
|
52
|
-
const PLUGIN_ROW_HOOK = '[data-dsh-panel-entry]'
|
|
53
|
-
|
|
54
|
-
/** The slot-service slice the guard reads. */
|
|
55
|
-
export interface PanelSlotReader {
|
|
56
|
-
entriesOfSlot?(key: string): readonly StoredEntry[]
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/** The context slice the guard needs. */
|
|
60
|
-
export interface ScheduleRowGuardContext {
|
|
61
|
-
slots?: PanelSlotReader
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* The live panel-list ledger, or an empty one.
|
|
66
|
-
*
|
|
67
|
-
* A context that serves no slot registry (a capture-only test context, or a
|
|
68
|
-
* shell that never declared the seat) has no official row to hide, and the
|
|
69
|
-
* guard must read that as "nothing to do" instead of failing the page.
|
|
70
|
-
* @param ctx - the client context.
|
|
71
|
-
* @returns the panel-list entries the shell currently projects.
|
|
72
|
-
*/
|
|
73
|
-
function panelEntries(ctx: ScheduleRowGuardContext): readonly StoredEntry[] {
|
|
74
|
-
const reader = ctx.slots
|
|
75
|
-
if (reader === undefined || typeof reader.entriesOfSlot !== 'function') return []
|
|
76
|
-
try {
|
|
77
|
-
return reader.entriesOfSlot(PANEL_LIST_SLOT) ?? []
|
|
78
|
-
} catch {
|
|
79
|
-
return []
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/** The guard's controls. */
|
|
84
|
-
export interface ScheduleRowGuard {
|
|
85
|
-
/** Hide the official row, and keep it hidden while the board is on. */
|
|
86
|
-
hide(): void
|
|
87
|
-
/** Restore the official row: the board's master switch is off. */
|
|
88
|
-
show(): void
|
|
89
|
-
/** Release the listeners and restore the row. */
|
|
90
|
-
dispose(): void
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* The accessible name the shell renders on the official automation-tasks row.
|
|
95
|
-
*
|
|
96
|
-
* The shell projects its panel list with `resolveSlotLabel(options.label) ??
|
|
97
|
-
* id`, and that value becomes the row's accessible name. Reading the same
|
|
98
|
-
* value out of the same ledger is what keeps the DOM match correct in every
|
|
99
|
-
* language.
|
|
100
|
-
* @param entries - the live panel-list ledger.
|
|
101
|
-
* @returns the row's accessible name, or undefined when the official panel is not mounted.
|
|
102
|
-
*/
|
|
103
|
-
export function officialScheduleRowLabel(entries: readonly StoredEntry[]): string | undefined {
|
|
104
|
-
const entry = entries.find(candidate => candidate.options.id === OFFICIAL_SCHEDULE_PANEL_ID)
|
|
105
|
-
if (entry === undefined) return undefined
|
|
106
|
-
try {
|
|
107
|
-
return resolveSlotLabel(entry.options.label) ?? entry.options.id
|
|
108
|
-
} catch {
|
|
109
|
-
// A label thunk that throws must not take the sidebar down with it.
|
|
110
|
-
return undefined
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* The shell's button for the panel row carrying this accessible name.
|
|
116
|
-
*
|
|
117
|
-
* Every global panel row renders one slot anchor inside the shell's own
|
|
118
|
-
* button, so the anchor is the row's handle and the button is what the user
|
|
119
|
-
* sees. Rows a plugin owns (they carry the family's own entry hook) are
|
|
120
|
-
* skipped.
|
|
121
|
-
* @param root - the document (or a subtree) to search.
|
|
122
|
-
* @param label - the accessible name to match.
|
|
123
|
-
* @returns the row button, or undefined when no row carries that name.
|
|
124
|
-
*/
|
|
125
|
-
export function findPanelRow(root: ParentNode, label: string): HTMLElement | undefined {
|
|
126
|
-
for (const anchor of root.querySelectorAll(PANEL_ROW_ANCHOR)) {
|
|
127
|
-
if (anchor.querySelector(PLUGIN_ROW_HOOK) !== null) continue
|
|
128
|
-
const button = anchor.closest('button') as HTMLElement | null
|
|
129
|
-
if (button !== null && button.getAttribute('aria-label') === label) return button
|
|
130
|
-
}
|
|
131
|
-
return undefined
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* Guard the official automation-tasks row against the board's presence.
|
|
136
|
-
*
|
|
137
|
-
* The guard hides the row while the board is enabled and restores it when the
|
|
138
|
-
* board is switched off. It re-applies its write after every DOM change,
|
|
139
|
-
* because the shell owns the row and may mount or replace it at any time (a
|
|
140
|
-
* re-render, a panel-list change, the official plugin arriving late).
|
|
141
|
-
* @param ctx - client context carrying the slot registry.
|
|
142
|
-
* @param root - the document to search; defaults to the ambient one.
|
|
143
|
-
* @returns the guard's controls.
|
|
144
|
-
*/
|
|
145
|
-
export function createScheduleRowGuard(ctx: ScheduleRowGuardContext, root?: ParentNode): ScheduleRowGuard {
|
|
146
|
-
const scope = root ?? (typeof document === 'undefined' ? undefined : document)
|
|
147
|
-
let hidden: HTMLElement | undefined
|
|
148
|
-
let previousDisplay: string | null = null
|
|
149
|
-
let stopWatching: (() => void) | undefined
|
|
150
|
-
|
|
151
|
-
const restoreRow = (): void => {
|
|
152
|
-
if (hidden === undefined) return
|
|
153
|
-
const button = hidden
|
|
154
|
-
hidden = undefined
|
|
155
|
-
if (previousDisplay === null) button.style.removeProperty('display')
|
|
156
|
-
else button.style.setProperty('display', previousDisplay)
|
|
157
|
-
previousDisplay = null
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
const hideRow = (): void => {
|
|
161
|
-
if (scope === undefined) return
|
|
162
|
-
const label = officialScheduleRowLabel(panelEntries(ctx))
|
|
163
|
-
if (label === undefined) return
|
|
164
|
-
const button = findPanelRow(scope, label)
|
|
165
|
-
if (button === undefined) return
|
|
166
|
-
if (hidden === button) return
|
|
167
|
-
restoreRow()
|
|
168
|
-
hidden = button
|
|
169
|
-
previousDisplay = button.style.getPropertyValue('display')
|
|
170
|
-
// The shell's own row rule sets a display value, so the write has to beat
|
|
171
|
-
// it: an inline declaration outranks any author rule that is not itself
|
|
172
|
-
// important, and the important flag also survives a skin's own overrides.
|
|
173
|
-
button.style.setProperty('display', 'none', 'important')
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
const sync = (): void => {
|
|
177
|
-
// A replaced row is a new element: the old write died with it.
|
|
178
|
-
if (hidden !== undefined && !hidden.isConnected) restoreRow()
|
|
179
|
-
hideRow()
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
const hide = (): void => {
|
|
183
|
-
hideRow()
|
|
184
|
-
if (stopWatching === undefined) {
|
|
185
|
-
// The page-wide hub: one body observer for every family consumer, and
|
|
186
|
-
// the row is re-hidden after whatever the shell did to the DOM.
|
|
187
|
-
stopWatching = subscribeBodyInvalidations(sync)
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
const show = (): void => {
|
|
192
|
-
stopWatching?.()
|
|
193
|
-
stopWatching = undefined
|
|
194
|
-
restoreRow()
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
return { hide, show, dispose: show }
|
|
198
|
-
}
|