@linxin666/dsh-client-ui-task-board 0.4.14 → 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 +2 -2
- package/README.zh.md +2 -2
- package/lib/client.js +3 -253
- package/lib/client.js.map +1 -1
- package/lib/types/client/plugin-card-seat.d.ts +1 -1
- package/lib/types/index.d.ts +1 -1
- package/package.json +28 -28
- package/src/client/index.ts +0 -10
- package/src/client/plugin-card-seat.ts +2 -2
- 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
|
@@ -56,7 +56,7 @@ export interface PluginCardContext {
|
|
|
56
56
|
/** Service lookup; absent on a context double that only models the slots. */
|
|
57
57
|
get?(name: string): unknown;
|
|
58
58
|
/** Event subscription seat; absent on an event-less test double. */
|
|
59
|
-
on?(event:
|
|
59
|
+
on?(event: never, listener: never): unknown;
|
|
60
60
|
}
|
|
61
61
|
/** Owner share of a family list-seat card (that seat supplies nothing). */
|
|
62
62
|
export interface SettingsPluginItemOwnerProps {
|
package/lib/types/index.d.ts
CHANGED
|
@@ -195,7 +195,7 @@ export interface Config {
|
|
|
195
195
|
* config against, before the schema turns volatile fields into live references
|
|
196
196
|
* and applies defaults. Declared separately because the two sides no longer
|
|
197
197
|
* share one shape, so the schema is annotated `z<ConfigInput, Config>` — the
|
|
198
|
-
* same split
|
|
198
|
+
* same split the git-family packages use. The annotation is also what keeps the
|
|
199
199
|
* emitted declaration portable: an unannotated schema holding a nested object
|
|
200
200
|
* array infers a type that cannot be named without reaching into a transitive
|
|
201
201
|
* dependency's own types.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@linxin666/dsh-client-ui-task-board",
|
|
3
3
|
"description": "Host-authoritative task board for the DSH Web GUI with real session execution, Host cron scheduling, and optional cross-platform idle-sleep protection; mounted without DSH source changes.",
|
|
4
|
-
"version": "0.4.
|
|
4
|
+
"version": "0.4.15",
|
|
5
5
|
"icon": "icon.svg",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "lib/index.js",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
},
|
|
23
23
|
"dsh": {
|
|
24
24
|
"engines": {
|
|
25
|
-
"dsh": ">=0.2.
|
|
25
|
+
"dsh": ">=0.2.2-rc.1"
|
|
26
26
|
},
|
|
27
27
|
"bundle": {
|
|
28
28
|
"patch": "./cordis.patch.yml"
|
|
@@ -42,38 +42,38 @@
|
|
|
42
42
|
}
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
|
-
"@deepseek-ai/dsh": ">=0.2.
|
|
45
|
+
"@deepseek-ai/dsh": ">=0.2.2-rc.1",
|
|
46
46
|
"react": "^18.2.0"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@deepseek-ai/schemastery": "^3.
|
|
49
|
+
"@deepseek-ai/schemastery": "^3.19.0",
|
|
50
50
|
"marked": "^18.0.14"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@deepseek-ai/cordis": "^4.0
|
|
54
|
-
"@deepseek-ai/dsh-agent": "^0.2.
|
|
55
|
-
"@deepseek-ai/dsh-agent-preset-registry": "^0.2.
|
|
56
|
-
"@deepseek-ai/dsh-attachment": "^0.2.
|
|
57
|
-
"@deepseek-ai/dsh-api-gateway": "^0.2.
|
|
58
|
-
"@deepseek-ai/dsh-api-remotes": "^0.2.
|
|
59
|
-
"@deepseek-ai/dsh-api-session-controller": "^0.2.
|
|
60
|
-
"@deepseek-ai/dsh-api-workspace-controller": "^0.2.
|
|
61
|
-
"@deepseek-ai/dsh-client-connection": "^0.2.
|
|
62
|
-
"@deepseek-ai/dsh-client-locale": "^0.2.
|
|
63
|
-
"@deepseek-ai/dsh-client-store": "^0.2.
|
|
64
|
-
"@deepseek-ai/dsh-client-ui-layout": "^0.2.
|
|
65
|
-
"@deepseek-ai/dsh-client-ui-renderer": "^0.2.
|
|
66
|
-
"@deepseek-ai/dsh-client-ui-settings": "^0.2.
|
|
67
|
-
"@deepseek-ai/dsh-client-ui-sidebar": "^0.2.
|
|
68
|
-
"@deepseek-ai/dsh-client-ui-slots": "^0.2.
|
|
69
|
-
"@deepseek-ai/dsh-client-ui-workspace": "^0.2.
|
|
70
|
-
"@deepseek-ai/dsh-commands": "^0.2.
|
|
71
|
-
"@deepseek-ai/dsh-host-webserver": "^0.2.
|
|
72
|
-
"@deepseek-ai/dsh-llm": "^0.2.
|
|
73
|
-
"@deepseek-ai/dsh-settings": "^0.2.
|
|
74
|
-
"@deepseek-ai/dsh-system-prompt": "^0.2.
|
|
75
|
-
"@deepseek-ai/dsh-tools": "^0.2.
|
|
76
|
-
"@deepseek-ai/dsh-workspace": "^0.2.
|
|
53
|
+
"@deepseek-ai/cordis": "^4.1.0",
|
|
54
|
+
"@deepseek-ai/dsh-agent": "^0.2.2-rc.1",
|
|
55
|
+
"@deepseek-ai/dsh-agent-preset-registry": "^0.2.2-rc.1",
|
|
56
|
+
"@deepseek-ai/dsh-attachment": "^0.2.2-rc.1",
|
|
57
|
+
"@deepseek-ai/dsh-api-gateway": "^0.2.2-rc.1",
|
|
58
|
+
"@deepseek-ai/dsh-api-remotes": "^0.2.2-rc.1",
|
|
59
|
+
"@deepseek-ai/dsh-api-session-controller": "^0.2.2-rc.1",
|
|
60
|
+
"@deepseek-ai/dsh-api-workspace-controller": "^0.2.2-rc.1",
|
|
61
|
+
"@deepseek-ai/dsh-client-connection": "^0.2.2-rc.1",
|
|
62
|
+
"@deepseek-ai/dsh-client-locale": "^0.2.2-rc.1",
|
|
63
|
+
"@deepseek-ai/dsh-client-store": "^0.2.2-rc.1",
|
|
64
|
+
"@deepseek-ai/dsh-client-ui-layout": "^0.2.2-rc.1",
|
|
65
|
+
"@deepseek-ai/dsh-client-ui-renderer": "^0.2.2-rc.1",
|
|
66
|
+
"@deepseek-ai/dsh-client-ui-settings": "^0.2.2-rc.1",
|
|
67
|
+
"@deepseek-ai/dsh-client-ui-sidebar": "^0.2.2-rc.1",
|
|
68
|
+
"@deepseek-ai/dsh-client-ui-slots": "^0.2.2-rc.1",
|
|
69
|
+
"@deepseek-ai/dsh-client-ui-workspace": "^0.2.2-rc.1",
|
|
70
|
+
"@deepseek-ai/dsh-commands": "^0.2.2-rc.1",
|
|
71
|
+
"@deepseek-ai/dsh-host-webserver": "^0.2.2-rc.1",
|
|
72
|
+
"@deepseek-ai/dsh-llm": "^0.2.2-rc.1",
|
|
73
|
+
"@deepseek-ai/dsh-settings": "^0.2.2-rc.1",
|
|
74
|
+
"@deepseek-ai/dsh-system-prompt": "^0.2.2-rc.1",
|
|
75
|
+
"@deepseek-ai/dsh-tools": "^0.2.2-rc.1",
|
|
76
|
+
"@deepseek-ai/dsh-workspace": "^0.2.2-rc.1",
|
|
77
77
|
"@types/node": "^22.20.0",
|
|
78
78
|
"@types/react": "~18.3.1",
|
|
79
79
|
"@types/react-dom": "^18.3.5",
|
package/src/client/index.ts
CHANGED
|
@@ -32,7 +32,6 @@ import { LocalStorageTaskStore } from '../core/store.ts'
|
|
|
32
32
|
import { hasOpenExecution } from '../core/tasks.ts'
|
|
33
33
|
import { claimTaskboardApply, releaseTaskboardApply } from './apply-guard.ts'
|
|
34
34
|
import { registerTaskBoardPanel } from './native-panel.tsx'
|
|
35
|
-
import { createScheduleRowGuard } from './suppress-schedule-row.ts'
|
|
36
35
|
import { TaskBoardSettingsCard, TaskBoardSettingsCardController, type TaskBoardSettings } from './TaskBoardSettingsCard.tsx'
|
|
37
36
|
import { en, zh, setRuntimeTranslate, type TaskBoardKey } from './locales.ts'
|
|
38
37
|
import { HttpTaskBoardHostTransport } from './host-api.ts'
|
|
@@ -425,12 +424,6 @@ export function apply(ctx: ClientContext): void {
|
|
|
425
424
|
uiDisposer = undefined
|
|
426
425
|
}
|
|
427
426
|
}
|
|
428
|
-
// The board's master switch owns the official automation-tasks entry as
|
|
429
|
-
// well: while the board is on, the shell's duplicate "Automation tasks" row
|
|
430
|
-
// is hidden, and with the board off the official row comes back. The same
|
|
431
|
-
// switch already governs the board's own row, so both scheduling entries
|
|
432
|
-
// appear and disappear together.
|
|
433
|
-
const scheduleRowGuard = createScheduleRowGuard(ctx)
|
|
434
427
|
const syncEnabled = (): void => {
|
|
435
428
|
const snapshot = settingsForm.getSnapshot()
|
|
436
429
|
const enabled = snapshot.status === 'ready'
|
|
@@ -439,10 +432,8 @@ export function apply(ctx: ClientContext): void {
|
|
|
439
432
|
if (enabled) {
|
|
440
433
|
mountUi()
|
|
441
434
|
clientService.setEnabled(true)
|
|
442
|
-
scheduleRowGuard.hide()
|
|
443
435
|
} else {
|
|
444
436
|
clientService.setEnabled(false)
|
|
445
|
-
scheduleRowGuard.show()
|
|
446
437
|
uiDisposer?.()
|
|
447
438
|
}
|
|
448
439
|
}
|
|
@@ -456,7 +447,6 @@ export function apply(ctx: ClientContext): void {
|
|
|
456
447
|
ctx.effect(() => () => {
|
|
457
448
|
unsubscribeSettings()
|
|
458
449
|
uiDisposer?.()
|
|
459
|
-
scheduleRowGuard.dispose()
|
|
460
450
|
}, 'task-board: DOM surfaces')
|
|
461
451
|
syncEnabled()
|
|
462
452
|
}
|
|
@@ -62,7 +62,7 @@ export interface PluginCardContext {
|
|
|
62
62
|
/** Service lookup; absent on a context double that only models the slots. */
|
|
63
63
|
get?(name: string): unknown
|
|
64
64
|
/** Event subscription seat; absent on an event-less test double. */
|
|
65
|
-
on?(event:
|
|
65
|
+
on?(event: never, listener: never): unknown
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
/** Owner share of a family list-seat card (that seat supplies nothing). */
|
|
@@ -193,7 +193,7 @@ export function installPluginCard(ctx: PluginCardContext, seat: PluginCardSeat):
|
|
|
193
193
|
|
|
194
194
|
if (typeof ctx.on === 'function') {
|
|
195
195
|
try {
|
|
196
|
-
ctx.on('slots/changed', () => { reconcile() })
|
|
196
|
+
ctx.on('slots/changed' as never, (() => { reconcile() }) as never)
|
|
197
197
|
} catch {
|
|
198
198
|
// An event seat that refuses the subscription leaves the initial
|
|
199
199
|
// decision in place; the card still renders in the seat chosen below.
|
package/src/index.ts
CHANGED
|
@@ -237,7 +237,7 @@ export interface Config {
|
|
|
237
237
|
* config against, before the schema turns volatile fields into live references
|
|
238
238
|
* and applies defaults. Declared separately because the two sides no longer
|
|
239
239
|
* share one shape, so the schema is annotated `z<ConfigInput, Config>` — the
|
|
240
|
-
* same split
|
|
240
|
+
* same split the git-family packages use. The annotation is also what keeps the
|
|
241
241
|
* emitted declaration portable: an unannotated schema holding a nested object
|
|
242
242
|
* array infers a type that cannot be named without reaching into a transitive
|
|
243
243
|
* dependency's own types.
|
|
@@ -1,86 +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
|
-
import { type StoredEntry } from '@deepseek-ai/dsh-client-ui-slots';
|
|
27
|
-
/**
|
|
28
|
-
* The official automation-tasks panel id.
|
|
29
|
-
*
|
|
30
|
-
* The host `ui-schedule` client half registers its sidebar row and its
|
|
31
|
-
* center-column page under this id; the shell's panel projection addresses
|
|
32
|
-
* both by it.
|
|
33
|
-
*/
|
|
34
|
-
export declare const OFFICIAL_SCHEDULE_PANEL_ID = "schedules";
|
|
35
|
-
/** The slot-service slice the guard reads. */
|
|
36
|
-
export interface PanelSlotReader {
|
|
37
|
-
entriesOfSlot?(key: string): readonly StoredEntry[];
|
|
38
|
-
}
|
|
39
|
-
/** The context slice the guard needs. */
|
|
40
|
-
export interface ScheduleRowGuardContext {
|
|
41
|
-
slots?: PanelSlotReader;
|
|
42
|
-
}
|
|
43
|
-
/** The guard's controls. */
|
|
44
|
-
export interface ScheduleRowGuard {
|
|
45
|
-
/** Hide the official row, and keep it hidden while the board is on. */
|
|
46
|
-
hide(): void;
|
|
47
|
-
/** Restore the official row: the board's master switch is off. */
|
|
48
|
-
show(): void;
|
|
49
|
-
/** Release the listeners and restore the row. */
|
|
50
|
-
dispose(): void;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* The accessible name the shell renders on the official automation-tasks row.
|
|
54
|
-
*
|
|
55
|
-
* The shell projects its panel list with `resolveSlotLabel(options.label) ??
|
|
56
|
-
* id`, and that value becomes the row's accessible name. Reading the same
|
|
57
|
-
* value out of the same ledger is what keeps the DOM match correct in every
|
|
58
|
-
* language.
|
|
59
|
-
* @param entries - the live panel-list ledger.
|
|
60
|
-
* @returns the row's accessible name, or undefined when the official panel is not mounted.
|
|
61
|
-
*/
|
|
62
|
-
export declare function officialScheduleRowLabel(entries: readonly StoredEntry[]): string | undefined;
|
|
63
|
-
/**
|
|
64
|
-
* The shell's button for the panel row carrying this accessible name.
|
|
65
|
-
*
|
|
66
|
-
* Every global panel row renders one slot anchor inside the shell's own
|
|
67
|
-
* button, so the anchor is the row's handle and the button is what the user
|
|
68
|
-
* sees. Rows a plugin owns (they carry the family's own entry hook) are
|
|
69
|
-
* skipped.
|
|
70
|
-
* @param root - the document (or a subtree) to search.
|
|
71
|
-
* @param label - the accessible name to match.
|
|
72
|
-
* @returns the row button, or undefined when no row carries that name.
|
|
73
|
-
*/
|
|
74
|
-
export declare function findPanelRow(root: ParentNode, label: string): HTMLElement | undefined;
|
|
75
|
-
/**
|
|
76
|
-
* Guard the official automation-tasks row against the board's presence.
|
|
77
|
-
*
|
|
78
|
-
* The guard hides the row while the board is enabled and restores it when the
|
|
79
|
-
* board is switched off. It re-applies its write after every DOM change,
|
|
80
|
-
* because the shell owns the row and may mount or replace it at any time (a
|
|
81
|
-
* re-render, a panel-list change, the official plugin arriving late).
|
|
82
|
-
* @param ctx - client context carrying the slot registry.
|
|
83
|
-
* @param root - the document to search; defaults to the ambient one.
|
|
84
|
-
* @returns the guard's controls.
|
|
85
|
-
*/
|
|
86
|
-
export declare function createScheduleRowGuard(ctx: ScheduleRowGuardContext, root?: ParentNode): ScheduleRowGuard;
|
|
@@ -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
|
-
}
|