@fish-under-sea/dsh-client-ui-task-board-fish 0.0.0-stage → 0.5.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/LICENSE +202 -0
- package/README.i18n.yaml +6 -0
- package/README.md +202 -2
- package/README.zh.md +203 -0
- package/cordis.patch.yml +12 -0
- package/icon.svg +3 -0
- package/lib/client.js +12941 -0
- package/lib/client.js.map +1 -0
- package/lib/index.js +10471 -0
- package/lib/types/client/PluginSettingsCard.d.ts +144 -0
- package/lib/types/client/TaskBoardSettingsCard.d.ts +92 -0
- package/lib/types/client/apply-guard.d.ts +25 -0
- package/lib/types/client/board/ClampedMarkdown.d.ts +3 -0
- package/lib/types/client/board/ConfirmDialog.d.ts +15 -0
- package/lib/types/client/board/EditTaskModal.d.ts +17 -0
- package/lib/types/client/board/LinkSubtaskModal.d.ts +14 -0
- package/lib/types/client/board/NewTaskModal.d.ts +26 -0
- package/lib/types/client/board/TagManagerModal.d.ts +26 -0
- package/lib/types/client/board/TaskBoard.d.ts +26 -0
- package/lib/types/client/board/TaskCard.d.ts +36 -0
- package/lib/types/client/board/TaskDetail.d.ts +9 -0
- package/lib/types/client/board/TaskForm.d.ts +72 -0
- package/lib/types/client/board/VerificationReport.d.ts +23 -0
- package/lib/types/client/board/card-view.d.ts +113 -0
- package/lib/types/client/board/icons.d.ts +32 -0
- package/lib/types/client/board/overlay.d.ts +69 -0
- package/lib/types/client/board/parse-model-pref.d.ts +4 -0
- package/lib/types/client/board/preset-label.d.ts +22 -0
- package/lib/types/client/board/status-key.d.ts +19 -0
- package/lib/types/client/board/task-markdown.d.ts +19 -0
- package/lib/types/client/host-api.d.ts +63 -0
- package/lib/types/client/index.d.ts +128 -0
- package/lib/types/client/locales.d.ts +443 -0
- package/lib/types/client/main-session.d.ts +32 -0
- package/lib/types/client/native-panel.d.ts +48 -0
- package/lib/types/client/plugin-card-seat.d.ts +108 -0
- package/lib/types/client/schedule-presets.d.ts +10 -0
- package/lib/types/client/schedule-zone.d.ts +97 -0
- package/lib/types/client/seats.d.ts +18 -0
- package/lib/types/client/service.d.ts +32 -0
- package/lib/types/client/settings-entry-form.d.ts +49 -0
- package/lib/types/client/settings-form.d.ts +213 -0
- package/lib/types/core/controller.d.ts +373 -0
- package/lib/types/core/degraded-reason.d.ts +46 -0
- package/lib/types/core/extension.d.ts +283 -0
- package/lib/types/core/freeze-snapshot.d.ts +71 -0
- package/lib/types/core/handover.d.ts +70 -0
- package/lib/types/core/issue-form.d.ts +16 -0
- package/lib/types/core/package-name.d.ts +9 -0
- package/lib/types/core/poll-cadence.d.ts +31 -0
- package/lib/types/core/schedule.d.ts +124 -0
- package/lib/types/core/session-reuse.d.ts +24 -0
- package/lib/types/core/store.d.ts +64 -0
- package/lib/types/core/subtask.d.ts +141 -0
- package/lib/types/core/tasks.d.ts +601 -0
- package/lib/types/core/use-cases/task-archive.d.ts +20 -0
- package/lib/types/core/use-cases/task-create.d.ts +27 -0
- package/lib/types/core/use-cases/task-delete.d.ts +27 -0
- package/lib/types/core/use-cases/task-parent.d.ts +21 -0
- package/lib/types/core/use-cases/task-schedule.d.ts +96 -0
- package/lib/types/core/use-cases/task-tag.d.ts +48 -0
- package/lib/types/core/use-cases/task-update.d.ts +56 -0
- package/lib/types/core/verification-budget.d.ts +52 -0
- package/lib/types/core/verification.d.ts +753 -0
- package/lib/types/core/workspace-target.d.ts +41 -0
- package/lib/types/dsh-home.d.ts +16 -0
- package/lib/types/host/agent-tools.d.ts +27 -0
- package/lib/types/host/extension-registry.d.ts +111 -0
- package/lib/types/host/llm-dispatch.d.ts +63 -0
- package/lib/types/host/verification-gate.d.ts +95 -0
- package/lib/types/host/verification-runner.d.ts +139 -0
- package/lib/types/host/workspace-evidence.d.ts +53 -0
- package/lib/types/host-ai.d.ts +51 -0
- package/lib/types/host-ledger.d.ts +385 -0
- package/lib/types/host-routes.d.ts +36 -0
- package/lib/types/host-runner.d.ts +252 -0
- package/lib/types/host-service.d.ts +379 -0
- package/lib/types/http.d.ts +59 -0
- package/lib/types/index.d.ts +322 -0
- package/lib/types/loopback.d.ts +24 -0
- package/lib/types/mount-once.d.ts +55 -0
- package/lib/types/power-inhibitor.d.ts +73 -0
- package/lib/types/protocol.d.ts +212 -0
- package/lib/types/tool-surface.d.ts +71 -0
- package/package.json +107 -4
- package/src/client/PluginSettingsCard.tsx +564 -0
- package/src/client/TaskBoardSettingsCard.tsx +539 -0
- package/src/client/apply-guard.ts +35 -0
- package/src/client/board/ClampedMarkdown.tsx +69 -0
- package/src/client/board/ConfirmDialog.tsx +44 -0
- package/src/client/board/EditTaskModal.tsx +110 -0
- package/src/client/board/LinkSubtaskModal.tsx +97 -0
- package/src/client/board/NewTaskModal.tsx +718 -0
- package/src/client/board/TagManagerModal.tsx +235 -0
- package/src/client/board/TaskBoard.tsx +558 -0
- package/src/client/board/TaskCard.tsx +315 -0
- package/src/client/board/TaskDetail.tsx +985 -0
- package/src/client/board/TaskForm.tsx +264 -0
- package/src/client/board/VerificationReport.tsx +322 -0
- package/src/client/board/card-view.ts +220 -0
- package/src/client/board/icons.tsx +89 -0
- package/src/client/board/overlay.tsx +189 -0
- package/src/client/board/parse-model-pref.ts +35 -0
- package/src/client/board/preset-label.ts +44 -0
- package/src/client/board/status-key.ts +41 -0
- package/src/client/board/task-markdown.module.css +137 -0
- package/src/client/board/task-markdown.tsx +106 -0
- package/src/client/board-settings.module.css +66 -0
- package/src/client/board.module.css +1837 -0
- package/src/client/css-modules.d.ts +5 -0
- package/src/client/host-api.ts +336 -0
- package/src/client/index.ts +501 -0
- package/src/client/locales.ts +905 -0
- package/src/client/main-session.ts +43 -0
- package/src/client/native-panel.tsx +140 -0
- package/src/client/plugin-card-seat.ts +199 -0
- package/src/client/schedule-presets.ts +13 -0
- package/src/client/schedule-zone.ts +233 -0
- package/src/client/seats.tsx +58 -0
- package/src/client/service.ts +94 -0
- package/src/client/settings-card.module.css +444 -0
- package/src/client/settings-entry-form.ts +142 -0
- package/src/client/settings-form.ts +468 -0
- package/src/core/controller.ts +871 -0
- package/src/core/degraded-reason.ts +81 -0
- package/src/core/extension.ts +376 -0
- package/src/core/freeze-snapshot.ts +213 -0
- package/src/core/handover.ts +132 -0
- package/src/core/issue-form.ts +19 -0
- package/src/core/package-name.ts +9 -0
- package/src/core/poll-cadence.ts +41 -0
- package/src/core/schedule.ts +363 -0
- package/src/core/session-reuse.ts +40 -0
- package/src/core/store.ts +371 -0
- package/src/core/subtask.ts +341 -0
- package/src/core/tasks.ts +843 -0
- package/src/core/use-cases/task-archive.ts +91 -0
- package/src/core/use-cases/task-create.ts +110 -0
- package/src/core/use-cases/task-delete.ts +43 -0
- package/src/core/use-cases/task-parent.ts +65 -0
- package/src/core/use-cases/task-schedule.ts +251 -0
- package/src/core/use-cases/task-tag.ts +110 -0
- package/src/core/use-cases/task-update.ts +126 -0
- package/src/core/verification-budget.ts +115 -0
- package/src/core/verification.ts +1594 -0
- package/src/core/workspace-target.ts +59 -0
- package/src/dsh-home.ts +42 -0
- package/src/host/agent-tools.ts +762 -0
- package/src/host/extension-registry.ts +509 -0
- package/src/host/llm-dispatch.ts +87 -0
- package/src/host/verification-gate.ts +487 -0
- package/src/host/verification-runner.ts +702 -0
- package/src/host/workspace-evidence.ts +176 -0
- package/src/host-ai.ts +158 -0
- package/src/host-ledger.ts +1826 -0
- package/src/host-routes.ts +306 -0
- package/src/host-runner.ts +755 -0
- package/src/host-service.ts +1112 -0
- package/src/http.ts +127 -0
- package/src/index.ts +722 -0
- package/src/loopback.ts +63 -0
- package/src/mount-once.ts +142 -0
- package/src/power-inhibitor.ts +321 -0
- package/src/protocol.ts +591 -0
- package/src/tool-surface.ts +95 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { type ScheduleRule, type ScheduleStopReason } from '../core/tasks.ts';
|
|
2
|
+
import { type TaskBoardKey } from './locales.ts';
|
|
3
|
+
/** One selectable zone, in the order the picker shows it. */
|
|
4
|
+
export interface ZoneChoice {
|
|
5
|
+
/** Canonical IANA id, or `''` for the Host-zone entry. */
|
|
6
|
+
id: string;
|
|
7
|
+
/** Display label. */
|
|
8
|
+
label: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Zones offered by the picker: the Host zone first (the default, and the entry
|
|
12
|
+
* a rule with no stored zone follows), then the runtime's own inventory.
|
|
13
|
+
*
|
|
14
|
+
* The Host entry is always present, even before the Host snapshot reports a
|
|
15
|
+
* zone: it is the entry that stores no zone, so dropping it would leave a rule
|
|
16
|
+
* unable to express "follow the Host" and would let the control silently
|
|
17
|
+
* display an unrelated zone.
|
|
18
|
+
*
|
|
19
|
+
* A stored zone the inventory does not list (a rule written on another machine
|
|
20
|
+
* or under a different ICU build) is appended, so opening the editor can never
|
|
21
|
+
* silently rewrite the rule's zone.
|
|
22
|
+
* @param hostTimeZone - zone the Host reported for this deployment, when known.
|
|
23
|
+
* @param storedTimeZone - zone the edited rule already stores, when any.
|
|
24
|
+
* @returns the de-duplicated choice list.
|
|
25
|
+
*/
|
|
26
|
+
export declare function zoneChoices(hostTimeZone: string | undefined, storedTimeZone?: string): ZoneChoice[];
|
|
27
|
+
/**
|
|
28
|
+
* The relative half of a next-run label: how far away the instant is, or how
|
|
29
|
+
* far past it the board is running. `now` is passed in rather than sampled so
|
|
30
|
+
* callers can share one clock reading across a row, and tests stay
|
|
31
|
+
* deterministic.
|
|
32
|
+
* @param targetMs - the instant being described.
|
|
33
|
+
* @param now - the reference instant.
|
|
34
|
+
* @returns localized relative wording.
|
|
35
|
+
*/
|
|
36
|
+
export declare function relativeTimeLabel(targetMs: number, now: number): string;
|
|
37
|
+
/**
|
|
38
|
+
* The `datetime-local` input value for an instant, read in an explicit zone:
|
|
39
|
+
* `YYYY-MM-DDTHH:mm`. Uses the shared engine's zone reader, so the editor
|
|
40
|
+
* shows the same wall clock the Host schedules by.
|
|
41
|
+
* @param epochMs - the instant to render.
|
|
42
|
+
* @param timeZone - zone to read it in; absent uses the Host zone.
|
|
43
|
+
* @returns the input value.
|
|
44
|
+
*/
|
|
45
|
+
export declare function zonedInputValue(epochMs: number, timeZone?: string): string;
|
|
46
|
+
/**
|
|
47
|
+
* Parse a `datetime-local` input value back to an instant, read in an explicit
|
|
48
|
+
* zone. Returns undefined when the text is not a whole calendar wall clock or
|
|
49
|
+
* names one the zone skips (a spring-forward gap), so the editor can refuse an
|
|
50
|
+
* unusable instant instead of silently moving it.
|
|
51
|
+
* @param value - the input text.
|
|
52
|
+
* @param timeZone - zone to interpret it in; absent uses the Host zone.
|
|
53
|
+
* @returns the instant, or undefined when it is not a usable wall clock.
|
|
54
|
+
*/
|
|
55
|
+
export declare function parseZonedInput(value: string, timeZone?: string): number | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* The default instant a new one-shot editor opens on: the next whole hour,
|
|
58
|
+
* rendered in the zone the rule will be read in.
|
|
59
|
+
* @param now - reference instant.
|
|
60
|
+
* @param timeZone - zone the rule is read in.
|
|
61
|
+
* @returns the input value for a near-future default.
|
|
62
|
+
*/
|
|
63
|
+
export declare function defaultZonedInputValue(now: number, timeZone?: string): string;
|
|
64
|
+
/**
|
|
65
|
+
* The editor's run-cap option for a stored cap: the two named presets, the
|
|
66
|
+
* unlimited entry, or a custom value the editor shows in its own field.
|
|
67
|
+
* @param maxRuns - the stored cap, when any.
|
|
68
|
+
* @returns the select option value.
|
|
69
|
+
*/
|
|
70
|
+
export declare function runCapOption(maxRuns: number | undefined): string;
|
|
71
|
+
/** The locale key describing why a rule stopped or skipped an occurrence. */
|
|
72
|
+
export declare function stopReasonKey(reason: ScheduleStopReason): TaskBoardKey;
|
|
73
|
+
/**
|
|
74
|
+
* The run-budget line: how many scheduled executions the Host opened and how
|
|
75
|
+
* many remain. Derived from the counter and the cap rather than stored, so the
|
|
76
|
+
* display cannot drift from the ledger.
|
|
77
|
+
* @param rule - the schedule rule.
|
|
78
|
+
* @returns localized wording.
|
|
79
|
+
*/
|
|
80
|
+
export declare function budgetLabel(rule: ScheduleRule): string;
|
|
81
|
+
/** The line describing a rule that stopped itself, or undefined while it may still fire. */
|
|
82
|
+
export declare function endedLabel(rule: ScheduleRule): string | undefined;
|
|
83
|
+
/** The line describing the last skipped occurrence, or undefined when none. */
|
|
84
|
+
export declare function skippedLabel(rule: ScheduleRule): string | undefined;
|
|
85
|
+
/**
|
|
86
|
+
* The full next-run label: the absolute wall clock in the schedule's own zone,
|
|
87
|
+
* plus the relative distance in parentheses. Showing both matters because a
|
|
88
|
+
* rule's zone can differ from the reader's, so the wall clock alone is
|
|
89
|
+
* ambiguous and the distance alone loses the actual moment.
|
|
90
|
+
* @param targetMs - the instant being described.
|
|
91
|
+
* @param timeZone - zone to render the absolute half in.
|
|
92
|
+
* @param formatAbsolute - formatter for the absolute half (keeps Intl caching in the caller).
|
|
93
|
+
* @param now - the reference instant.
|
|
94
|
+
* @param translate - translate function, bound so this module stays dependency-light.
|
|
95
|
+
* @returns the combined label.
|
|
96
|
+
*/
|
|
97
|
+
export declare function nextRunLabel(targetMs: number, timeZone: string | undefined, formatAbsolute: (ms: number, timeZone?: string) => string, now: number): string;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import { type TaskBoardCardDecorationProps, type TaskBoardDetailSectionProps, type TaskBoardSettingsSectionProps } from '../core/extension.ts';
|
|
3
|
+
/** The three provider seats, adapted to plain render functions. */
|
|
4
|
+
export interface TaskBoardSeats {
|
|
5
|
+
detailSection: (props: TaskBoardDetailSectionProps) => ReactNode;
|
|
6
|
+
settingsSection: (props: TaskBoardSettingsSectionProps) => ReactNode;
|
|
7
|
+
cardDecoration: (props: TaskBoardCardDecorationProps) => ReactNode;
|
|
8
|
+
}
|
|
9
|
+
/** Nothing registered: every seat renders empty. */
|
|
10
|
+
export declare const EMPTY_TASK_BOARD_SEATS: TaskBoardSeats;
|
|
11
|
+
/** The framework `renderSlot` binding shape (key + owner props share). */
|
|
12
|
+
export type SlotRenderBinding = (key: string, owner: Record<string, unknown>) => ReactNode;
|
|
13
|
+
/** Adapt one framework renderSlot binding to the board's seat interface. */
|
|
14
|
+
export declare function seatsFromRenderSlot(renderSlot: SlotRenderBinding | undefined): TaskBoardSeats;
|
|
15
|
+
/** Provider the board's registered components wrap their subtree in. */
|
|
16
|
+
export declare const TaskBoardSeatsProvider: import("react").Provider<TaskBoardSeats>;
|
|
17
|
+
/** Read the current seat set (empty when no board registration is above). */
|
|
18
|
+
export declare function useTaskBoardSeats(): TaskBoardSeats;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The board's browser-half extension service (`taskBoard`).
|
|
3
|
+
*
|
|
4
|
+
* It gives a provider's browser half the client capability face from the
|
|
5
|
+
* contract: dispatch over the board's same-origin action channel, card
|
|
6
|
+
* visibility predicates, and a subscription to the board mirror. The board
|
|
7
|
+
* controller is attached and detached as the master switch mounts and unmounts
|
|
8
|
+
* the UI, so the service can be provided before any controller exists.
|
|
9
|
+
*
|
|
10
|
+
* @module dsh-task-board/client/service
|
|
11
|
+
*/
|
|
12
|
+
import type { BoardController } from '../core/controller.ts';
|
|
13
|
+
import type { TaskBoardClientFace, TaskBoardClientMirror, TaskBoardExtensionActionRequest, TaskBoardVisibilityPredicate } from '../core/extension.ts';
|
|
14
|
+
export declare class TaskBoardClientService implements TaskBoardClientFace {
|
|
15
|
+
private controller;
|
|
16
|
+
private enabled;
|
|
17
|
+
private unsubscribeController;
|
|
18
|
+
/** Predicates registered before the controller exists, replayed on attach. */
|
|
19
|
+
private readonly pendingVisibility;
|
|
20
|
+
private readonly listeners;
|
|
21
|
+
/** Bind the live board controller (called when the UI mounts). */
|
|
22
|
+
attach(controller: BoardController): void;
|
|
23
|
+
/** Release the current controller (called when the UI unmounts). */
|
|
24
|
+
detach(): void;
|
|
25
|
+
/** Apply the board's master switch. */
|
|
26
|
+
setEnabled(enabled: boolean): void;
|
|
27
|
+
dispatch(request: TaskBoardExtensionActionRequest): Promise<boolean>;
|
|
28
|
+
registerVisibility(predicate: TaskBoardVisibilityPredicate): () => void;
|
|
29
|
+
subscribe(callback: (mirror: TaskBoardClientMirror) => void): () => void;
|
|
30
|
+
snapshot(): TaskBoardClientMirror;
|
|
31
|
+
private notify;
|
|
32
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Family settings form bound to the profile entry id a Host actually serves.
|
|
3
|
+
*
|
|
4
|
+
* Under the 0.1.7 settings model a form is addressed by PROFILE ENTRY ID, while
|
|
5
|
+
* a family card knows only its own settings namespace. The family binder
|
|
6
|
+
* (`ctx.get('webUiSettings')`, published by dsh-web-settings) resolves one onto
|
|
7
|
+
* the other and is the preferred transport; this module is the fallback for a
|
|
8
|
+
* page that serves no binder — the group plugin is not installed, or its client
|
|
9
|
+
* half has not applied yet (the aggregate mounts its children in order, and a
|
|
10
|
+
* child still waiting on its own injects publishes nothing).
|
|
11
|
+
*
|
|
12
|
+
* The shared describe mirror is the only local evidence of which row id this
|
|
13
|
+
* profile serves, but it answers asynchronously: at plugin activation it usually
|
|
14
|
+
* holds nothing yet. A one-shot guess therefore cannot be right for every
|
|
15
|
+
* deployment, and the form is bound once per session:
|
|
16
|
+
*
|
|
17
|
+
* - binding the bare namespace made every save answer `No configurable plugin
|
|
18
|
+
* entry "<namespace>"` on an aggregate install (the namespace is not an entry
|
|
19
|
+
* id there), which the card reported as "the deployment did not accept these
|
|
20
|
+
* values";
|
|
21
|
+
* - binding the aggregate row id would break a standalone install, whose row id
|
|
22
|
+
* is the namespace or the package's own `ui-*` row.
|
|
23
|
+
*
|
|
24
|
+
* So the fallback starts on the most likely row and REBINDS the moment the
|
|
25
|
+
* mirror names one of this package's rows. Until the mirror answers, the form
|
|
26
|
+
* reports the binding it holds (usually `loading`), which the card renders as an
|
|
27
|
+
* unavailable form rather than a doomed one.
|
|
28
|
+
*/
|
|
29
|
+
import type { ConfigForm, ConfigForms } from '@deepseek-ai/dsh-client-ui-settings/client';
|
|
30
|
+
/** Options of {@link createServedEntryForm}. */
|
|
31
|
+
export interface ServedEntryFormOptions<T> {
|
|
32
|
+
/** The shared configuration forms service (`ctx.configForms`). */
|
|
33
|
+
forms: ConfigForms;
|
|
34
|
+
/**
|
|
35
|
+
* Profile entry ids this package's rows carry, most likely first: the
|
|
36
|
+
* aggregate's generated row, the package's own standalone row, then the bare
|
|
37
|
+
* namespace. The first is the fallback while the mirror has no answer; the
|
|
38
|
+
* last is the answer when the mirror serves none of them.
|
|
39
|
+
*/
|
|
40
|
+
entryIds: readonly string[];
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Create a settings form bound to the profile entry id this Host serves, and
|
|
44
|
+
* rebound whenever the shared describe mirror names a different one of this
|
|
45
|
+
* package's rows.
|
|
46
|
+
* @param options - the shared forms service and this package's candidate row ids.
|
|
47
|
+
* @returns a form delegating to the currently resolved entry's own form.
|
|
48
|
+
*/
|
|
49
|
+
export declare function createServedEntryForm<T>(options: ServedEntryFormOptions<T>): ConfigForm<T>;
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Staged form model behind the plugin settings card. A card stages what the
|
|
3
|
+
* user types and writes it only when they save — the settings write is a
|
|
4
|
+
* durable, revision-fenced document mutation, so staging keeps what is on
|
|
5
|
+
* screen exactly what a save would store. Family-shared slice inlined into
|
|
6
|
+
* each plugin's client bundle; mirrors the official ui-plugin-config
|
|
7
|
+
* card-store pattern.
|
|
8
|
+
*/
|
|
9
|
+
import type { ConfigForm } from '@deepseek-ai/dsh-client-ui-settings/client';
|
|
10
|
+
import type { SnapshotStore } from '@deepseek-ai/dsh-client-store';
|
|
11
|
+
/** The write one field's staged text performs when the card is saved. */
|
|
12
|
+
export type FieldWrite = {
|
|
13
|
+
kind: 'set';
|
|
14
|
+
value: unknown;
|
|
15
|
+
} | {
|
|
16
|
+
kind: 'clear';
|
|
17
|
+
};
|
|
18
|
+
/** How one field converts between its stored value and its draft text. */
|
|
19
|
+
export interface FieldSpec {
|
|
20
|
+
/** Field name inside the namespace section. */
|
|
21
|
+
field: string;
|
|
22
|
+
/**
|
|
23
|
+
* Whether the Host treats this field as a secret and redacts its value from
|
|
24
|
+
* the read-back (role('secret') in the section schema). Redacted secrets are
|
|
25
|
+
* never compared against the draft on save: the Host strips them from every
|
|
26
|
+
* wire view layer, so the settled snapshot carries nothing to read back. A
|
|
27
|
+
* staged secret set is judged by the mutation settling; the rest of its
|
|
28
|
+
* batch, when one exists, is still judged by read-back, and the atomic
|
|
29
|
+
* mutation lands every write or none.
|
|
30
|
+
*/
|
|
31
|
+
secret?: boolean;
|
|
32
|
+
/** Render a stored value as draft text; the empty string when the section carries none. */
|
|
33
|
+
format: (value: unknown) => string;
|
|
34
|
+
/**
|
|
35
|
+
* The write this draft text stages, or undefined when the text is not a
|
|
36
|
+
* value this field accepts — which blocks the save rather than discarding it.
|
|
37
|
+
*/
|
|
38
|
+
parse: (text: string) => FieldWrite | undefined;
|
|
39
|
+
}
|
|
40
|
+
/** One field as the card renders it. */
|
|
41
|
+
export interface FieldState {
|
|
42
|
+
/** Draft text the control renders. */
|
|
43
|
+
text: string;
|
|
44
|
+
/** Whether saving would leave a user-layer entry for this field. */
|
|
45
|
+
overridden: boolean;
|
|
46
|
+
/** Whether the draft is not a value this field accepts, which blocks saving. */
|
|
47
|
+
invalid: boolean;
|
|
48
|
+
}
|
|
49
|
+
/** Form state every plugin settings card shares. */
|
|
50
|
+
export interface CardShell {
|
|
51
|
+
/** False while the namespace is still loading; the card renders nothing. */
|
|
52
|
+
available: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Whether the namespace is actually served to this client. False when the
|
|
55
|
+
* Host deployment does not expose it (e.g. the owning plugin's settings
|
|
56
|
+
* domain is not mounted): the card renders an explanation
|
|
57
|
+
* instead of its form, so a missing namespace never looks like a missing
|
|
58
|
+
* plugin.
|
|
59
|
+
*/
|
|
60
|
+
exposed: boolean;
|
|
61
|
+
/** Whether the Host document accepts writes. */
|
|
62
|
+
writable: boolean;
|
|
63
|
+
/** Whether the form holds edits that a save would write. */
|
|
64
|
+
dirty: boolean;
|
|
65
|
+
/** Whether any staged draft is invalid, which blocks the save. */
|
|
66
|
+
invalid: boolean;
|
|
67
|
+
/** Whether a save is crossing the wire. */
|
|
68
|
+
saving: boolean;
|
|
69
|
+
/** Whether the last save did not land as staged; cleared by the next edit or save. */
|
|
70
|
+
failed: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* The rejection code/message the Host returned for the last failed save,
|
|
73
|
+
* surfaced next to the generic failure text. Undefined while no save has
|
|
74
|
+
* failed (or the failure carried no server reason).
|
|
75
|
+
*/
|
|
76
|
+
failedReason?: string;
|
|
77
|
+
}
|
|
78
|
+
/** The write actions the card's slot entry injects. */
|
|
79
|
+
export interface CardActions {
|
|
80
|
+
/** Stage draft text for one field. */
|
|
81
|
+
edit: (field: string, text: string) => void;
|
|
82
|
+
/** Stage a clear, so saving lets the field re-inherit the composition layer. */
|
|
83
|
+
resetField: (field: string) => void;
|
|
84
|
+
/** Write every staged edit, then re-seed from what the Host accepted. */
|
|
85
|
+
save: () => void;
|
|
86
|
+
/** Drop every staged edit. */
|
|
87
|
+
discard: () => void;
|
|
88
|
+
}
|
|
89
|
+
/** One durable write inside the save's atomic form mutation. */
|
|
90
|
+
export interface BatchedWrite {
|
|
91
|
+
/** Field this entry writes. */
|
|
92
|
+
field: string;
|
|
93
|
+
/** set stores a value; unset drops the leaf. */
|
|
94
|
+
op: 'set' | 'unset';
|
|
95
|
+
/** Value for op set (absent for unset). */
|
|
96
|
+
value?: unknown;
|
|
97
|
+
}
|
|
98
|
+
/** Constraints a numeric field's accepted drafts must satisfy, mirroring the host schema. */
|
|
99
|
+
export interface NumberConstraints {
|
|
100
|
+
/** The accepted value must be a whole number. */
|
|
101
|
+
integer?: boolean;
|
|
102
|
+
/** The accepted value must be at least this. */
|
|
103
|
+
min?: number;
|
|
104
|
+
}
|
|
105
|
+
/** A whole- or decimal-number field. An empty draft clears the field; any other draft that is not a finite number within the constraints blocks the save. */
|
|
106
|
+
export declare function numberField(field: string, constraints?: NumberConstraints): FieldSpec;
|
|
107
|
+
/** A free-text field. An empty draft clears the field. */
|
|
108
|
+
export declare function textField(field: string): FieldSpec;
|
|
109
|
+
/**
|
|
110
|
+
* A free-text field the Host treats as a secret and redacts from the read-back
|
|
111
|
+
* (role('secret') in the section schema). The card still edits it like text,
|
|
112
|
+
* but a save never compares the redacted value back: the staged set is judged
|
|
113
|
+
* by the mutation settling (see {@link FieldSpec.secret}).
|
|
114
|
+
*/
|
|
115
|
+
export declare function secretField(field: string): FieldSpec;
|
|
116
|
+
/** A boolean field, edited through true/false draft text. */
|
|
117
|
+
export declare function booleanField(field: string): FieldSpec;
|
|
118
|
+
/** An enumerated string field; only the listed choices are accepted. An empty draft clears the field. */
|
|
119
|
+
export declare function choiceField(field: string, choices: readonly string[]): FieldSpec;
|
|
120
|
+
/**
|
|
121
|
+
* Stages one card's edits over one settings namespace and writes them on save.
|
|
122
|
+
*
|
|
123
|
+
* The Host is the only authority on whether a value was accepted — its
|
|
124
|
+
* validators own the constraints no schema can express — so the outcome is
|
|
125
|
+
* read back from the section rather than predicted here. A save that did not
|
|
126
|
+
* land keeps its drafts, so the user can correct them instead of retyping.
|
|
127
|
+
*/
|
|
128
|
+
export declare class CardForm<T> {
|
|
129
|
+
private readonly scope;
|
|
130
|
+
private readonly specs;
|
|
131
|
+
private readonly staged;
|
|
132
|
+
private readonly listeners;
|
|
133
|
+
/** The form subscription installed in the constructor; released by dispose(). */
|
|
134
|
+
private readonly disposeForm;
|
|
135
|
+
private disposed;
|
|
136
|
+
private saving;
|
|
137
|
+
/** A save asked for while one was in flight; it runs once the first settles (#1754). */
|
|
138
|
+
private saveQueued;
|
|
139
|
+
private failed;
|
|
140
|
+
private failedReason;
|
|
141
|
+
/** @param scope - the bound configuration form for this card's namespace. */
|
|
142
|
+
constructor(scope: ConfigForm<T>, specs: FieldSpec[]);
|
|
143
|
+
/**
|
|
144
|
+
* Release the form subscription and every bound store listener. The card
|
|
145
|
+
* must call this on teardown; later calls are no-ops.
|
|
146
|
+
*/
|
|
147
|
+
dispose(): void;
|
|
148
|
+
/** Publish a projection of this form, rebuilt whenever the form or a draft changes. */
|
|
149
|
+
bind<S>(project: () => S): SnapshotStore<S>;
|
|
150
|
+
/** Read the card-level state: what the Host serves, and what a save would do. */
|
|
151
|
+
shell(): CardShell;
|
|
152
|
+
/** Read one field's state from the effective section and its staged draft. */
|
|
153
|
+
field(field: string): FieldState;
|
|
154
|
+
/** The actions the card's slot registration injects. */
|
|
155
|
+
actions(): CardActions;
|
|
156
|
+
/**
|
|
157
|
+
* Write every staged edit in one atomic form mutation, then re-seed from
|
|
158
|
+
* what the Host accepted.
|
|
159
|
+
*
|
|
160
|
+
* The whole batch rides one mutate, so cross-field validate hooks
|
|
161
|
+
* (baseURL+model) judge it as a unit: the Host either applies every write
|
|
162
|
+
* or refuses the batch. The form contract answers a refusal or a skipped
|
|
163
|
+
* write with `false` (it recovers with a fresh Host view instead of
|
|
164
|
+
* throwing), so the outcome is judged twice: the answer itself, and then the
|
|
165
|
+
* settled snapshot read back one planned write at a time. One missed write
|
|
166
|
+
* fails the whole save. A transport that rejects instead (the dsh-web bridge
|
|
167
|
+
* controller on a dead connection) reports through the same failure path
|
|
168
|
+
* with its rejection message. A save that did not land keeps its drafts, so
|
|
169
|
+
* the user can correct them instead of retyping.
|
|
170
|
+
* @returns settlement after the mutation and the read-back.
|
|
171
|
+
*/
|
|
172
|
+
/**
|
|
173
|
+
* Run one save, and re-run it once if another was asked for while this one
|
|
174
|
+
* was still in flight.
|
|
175
|
+
*
|
|
176
|
+
* A save is a Host round trip that also drives the profile reconcile, and
|
|
177
|
+
* the Host runs that write inside one exclusive transaction. Answering a
|
|
178
|
+
* press that arrives mid-flight by returning immediately dropped the edit
|
|
179
|
+
* with no explanation, which is the "the save button stops working after a
|
|
180
|
+
* few rounds" report (#1754). Serializing instead means a save pressed while
|
|
181
|
+
* another is still settling runs against the settled state - which is what
|
|
182
|
+
* the operator meant by pressing it again.
|
|
183
|
+
* @returns settlement after the mutation and the read-back.
|
|
184
|
+
*/
|
|
185
|
+
requestSave(): Promise<void>;
|
|
186
|
+
save(): Promise<void>;
|
|
187
|
+
/**
|
|
188
|
+
* Every staged edit a save would write. An entry whose draft is not a value
|
|
189
|
+
* its field accepts carries no write: the form is still dirty, and the save
|
|
190
|
+
* refuses rather than dropping the edit. A staged edit that matches the
|
|
191
|
+
* effective section is not a write at all.
|
|
192
|
+
* @returns the planned writes, in the order the fields were staged.
|
|
193
|
+
*/
|
|
194
|
+
private plan;
|
|
195
|
+
/**
|
|
196
|
+
* Read-back judgment for a planned set: the user layer must hold the
|
|
197
|
+
* intended value once the mutation has settled.
|
|
198
|
+
*/
|
|
199
|
+
private landedSet;
|
|
200
|
+
/**
|
|
201
|
+
* Read-back judgment for a planned unset: the field must be gone from the
|
|
202
|
+
* user layer once the mutation has settled.
|
|
203
|
+
*/
|
|
204
|
+
private landedUnset;
|
|
205
|
+
private stage;
|
|
206
|
+
private specOf;
|
|
207
|
+
private snapshotOf;
|
|
208
|
+
private sectionValue;
|
|
209
|
+
private baseValue;
|
|
210
|
+
private userLayer;
|
|
211
|
+
private stored;
|
|
212
|
+
private publish;
|
|
213
|
+
}
|