@morlay/dsh-client-ui-primitives 0.0.4 → 0.0.6
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.md +18 -266
- package/dist/client.cjs +1 -611
- package/dist/client.d.cts +37 -684
- package/dist/client.d.mts +37 -684
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +1 -1
- package/dist/{reference-Dxy9uQYz.mjs → reference-Cjcn21uW.mjs} +0 -1
- package/locale/en.json +1 -1
- package/locale/zh.json +1 -1
- package/package.json +2 -2
- package/src/client/index.ts +7 -9
- package/src/client/schema-form/Editor.tsx +25 -38
- package/src/client/schema-form/SchemaForm.tsx +6 -12
- package/src/client/schema-form/controller.ts +65 -123
- package/src/client/schema-form/draft.ts +55 -138
- package/src/client/schema-form/fields.tsx +5 -14
- package/src/client/schema-form/hints.ts +31 -131
- package/src/client/schema-form/index.ts +15 -20
- package/src/client/schema-form/labels.ts +7 -9
- package/src/client/schema-form/lines.ts +36 -60
- package/src/client/schema-form/locales.ts +6 -8
- package/src/client/schema-form/rows.ts +22 -41
- package/src/client/schema-form/schema-node.ts +87 -150
- package/src/client/schema-form/slot-contract.ts +55 -76
- package/src/client/schema-form/styles.ts +39 -51
- package/src/client/schema-form/testing/fake-describe.ts +3 -9
- package/src/client/schema-form/testing/fake-scope.ts +8 -10
- package/src/client/schema-form/value.tsx +14 -26
- package/src/client/settings-form/SettingsForm.tsx +13 -17
- package/src/client/settings-form/fields.tsx +25 -35
- package/src/client/settings-form/form-model.ts +63 -145
- package/src/client/styling/styled.tsx +3 -5
- package/src/client/theme.generated.ts +6 -7
- package/src/reference-markdown.tsx +1 -1
- package/src/reference.ts +1 -1
package/dist/client.d.mts
CHANGED
|
@@ -9352,7 +9352,7 @@ interface Sheet {
|
|
|
9352
9352
|
contents: string[];
|
|
9353
9353
|
selector: string | undefined;
|
|
9354
9354
|
}
|
|
9355
|
-
declare class Styling {
|
|
9355
|
+
export declare class Styling {
|
|
9356
9356
|
#private;
|
|
9357
9357
|
static create(): Styling;
|
|
9358
9358
|
static toRule(sheet: Sheet): string;
|
|
@@ -9362,7 +9362,7 @@ declare class Styling {
|
|
|
9362
9362
|
className: (...styles: (CSSProps | false | null | undefined)[]) => string;
|
|
9363
9363
|
sheets: () => string[];
|
|
9364
9364
|
}
|
|
9365
|
-
declare const styling: Styling;
|
|
9365
|
+
export declare const styling: Styling;
|
|
9366
9366
|
//#endregion
|
|
9367
9367
|
//#region src/client/styling/token.d.ts
|
|
9368
9368
|
interface CSSVarRef {
|
|
@@ -9372,7 +9372,7 @@ interface CSSVarRef {
|
|
|
9372
9372
|
}
|
|
9373
9373
|
type TokenVars<T> = (T extends string | true ? CSSVarRef : { readonly [K in keyof T]: TokenVars<T[K]>; }) & CSSVarRef;
|
|
9374
9374
|
type Tokens = Record<string, unknown>;
|
|
9375
|
-
declare class Token {
|
|
9375
|
+
export declare class Token {
|
|
9376
9376
|
readonly prefix: string;
|
|
9377
9377
|
static vars<T extends Tokens>(tokens: T, options?: {
|
|
9378
9378
|
prefix?: string;
|
|
@@ -9408,23 +9408,11 @@ declare const sxSymbol: unique symbol;
|
|
|
9408
9408
|
type StyledComponent<T extends ElementType> = ForwardRefExoticComponent<StyledProps<T> & RefAttributes<StyledRef<T>>> & {
|
|
9409
9409
|
readonly [sxSymbol]: CSSProps;
|
|
9410
9410
|
};
|
|
9411
|
-
|
|
9412
|
-
|
|
9413
|
-
* 多个样式对象按顺序深合并(后者覆盖前者),便于把变体叠在基样式上。
|
|
9414
|
-
*/
|
|
9415
|
-
declare function styled<T extends ElementType>(Component: T, defaultProps?: Partial<ComponentProps<T>>): (...styles: CSSProps[]) => StyledComponent<T>;
|
|
9416
|
-
/** 取回 styled 组件携带的样式对象(需要在其之上继续组合时用)。 */
|
|
9417
|
-
declare function styleOf(component: StyledComponent<ElementType>): CSSProps;
|
|
9411
|
+
export declare function styled<T extends ElementType>(Component: T, defaultProps?: Partial<ComponentProps<T>>): (...styles: CSSProps[]) => StyledComponent<T>;
|
|
9412
|
+
export declare function styleOf(component: StyledComponent<ElementType>): CSSProps;
|
|
9418
9413
|
//#endregion
|
|
9419
9414
|
//#region src/client/theme.generated.d.ts
|
|
9420
|
-
|
|
9421
|
-
* 官方主题的 `--dsw-*` token 全集(400 个),由 packages/client/ui-primitives/scripts/gen-design-tokens.mts 生成,勿手改。
|
|
9422
|
-
*
|
|
9423
|
-
* 叶子是该变量的**默认值**(官方 light 主题里首次出现的定义):既是类型推导的来源,也可作 fallback。
|
|
9424
|
-
* `"$"` 键出现在「自身也是 token 的分支」上(命名体系里有 40 个短名同时是长名前缀的 token)。
|
|
9425
|
-
* 消费时只需树形状——`Token.vars()` 生成 `var(--dsw-…)`,不重新定义变量。
|
|
9426
|
-
* 漂移、往返与默认值完整性由 src/__tests__/design-tokens.spec.ts 守卫。 */
|
|
9427
|
-
declare const designTokens: {
|
|
9415
|
+
export declare const designTokens: {
|
|
9428
9416
|
readonly alias: {
|
|
9429
9417
|
readonly bg: {
|
|
9430
9418
|
readonly base: "var(--dsw-static-neutral-bluish-00)";
|
|
@@ -10250,7 +10238,7 @@ declare const designTokens: {
|
|
|
10250
10238
|
};
|
|
10251
10239
|
//#endregion
|
|
10252
10240
|
//#region src/client/theme.d.ts
|
|
10253
|
-
declare const dsw: TokenVars<{
|
|
10241
|
+
export declare const dsw: TokenVars<{
|
|
10254
10242
|
readonly alias: {
|
|
10255
10243
|
readonly bg: {
|
|
10256
10244
|
readonly base: "var(--dsw-static-neutral-bluish-00)";
|
|
@@ -11076,26 +11064,18 @@ declare const dsw: TokenVars<{
|
|
|
11076
11064
|
}>;
|
|
11077
11065
|
//#endregion
|
|
11078
11066
|
//#region src/client/markdown-labels.d.ts
|
|
11079
|
-
type MarkdownCopySeat = (key: "copy" | "copied" | "markdown.footnotes") => string;
|
|
11080
|
-
declare function markdownLabels(t: MarkdownCopySeat): MarkdownLabels;
|
|
11067
|
+
export type MarkdownCopySeat = (key: "copy" | "copied" | "markdown.footnotes") => string;
|
|
11068
|
+
export declare function markdownLabels(t: MarkdownCopySeat): MarkdownLabels;
|
|
11081
11069
|
//#endregion
|
|
11082
11070
|
//#region src/client/settings-form/form-model.d.ts
|
|
11083
|
-
/** What the model reads of one Host entry's form. */
|
|
11084
11071
|
interface SettingsFormScopeSnapshot<T> {
|
|
11085
|
-
/** `ready` while the Host serves the entry to this client; the form renders nothing otherwise. */
|
|
11086
11072
|
status: "loading" | "ready" | "unavailable";
|
|
11087
|
-
/** Last accepted schema-resolved section; undefined before the first acceptance. */
|
|
11088
11073
|
value: T | undefined;
|
|
11089
|
-
/** Composition layer the value resolves over: what a field reverts to once cleared. */
|
|
11090
11074
|
base: unknown;
|
|
11091
|
-
/** Raw user layer as stored; a field's PRESENCE here is what marks it overridden. */
|
|
11092
11075
|
user: unknown;
|
|
11093
|
-
/** Whether the Host document accepts writes. */
|
|
11094
11076
|
writable: boolean;
|
|
11095
|
-
/** Revision the snapshot was read at; a save fences its mutation with the revision its drafts started from. */
|
|
11096
11077
|
revision: number | undefined;
|
|
11097
11078
|
}
|
|
11098
|
-
/** One path edit a save sends, as the shared configuration form's `mutate` accepts it. */
|
|
11099
11079
|
type SettingsFormPathOp = {
|
|
11100
11080
|
op: "set";
|
|
11101
11081
|
path: readonly string[];
|
|
@@ -11104,115 +11084,48 @@ type SettingsFormPathOp = {
|
|
|
11104
11084
|
op: "unset";
|
|
11105
11085
|
path: readonly string[];
|
|
11106
11086
|
};
|
|
11107
|
-
/** The entry form the model stages over: the reads and the atomic write of the form `ui-settings` shares per Host entry. */
|
|
11108
11087
|
interface SettingsFormScope<T> {
|
|
11109
|
-
/** @returns the current sync snapshot. */
|
|
11110
11088
|
getSnapshot(): SettingsFormScopeSnapshot<T>;
|
|
11111
|
-
/**
|
|
11112
|
-
* Observe snapshot replacements.
|
|
11113
|
-
* @param listener - invoked after each snapshot change.
|
|
11114
|
-
* @returns the disposer removing this listener.
|
|
11115
|
-
*/
|
|
11116
11089
|
subscribe(listener: () => void): () => void;
|
|
11117
|
-
/**
|
|
11118
|
-
* Apply ordered field edits in one revision-fenced write.
|
|
11119
|
-
* @param ops - the edits, in staging order.
|
|
11120
|
-
* @param expectedRevision - the revision the drafts were staged against, when known.
|
|
11121
|
-
* @returns true for Host acceptance, false for refusal, after any recovery read.
|
|
11122
|
-
*/
|
|
11123
11090
|
mutate(ops: readonly SettingsFormPathOp[], expectedRevision?: number): Promise<boolean>;
|
|
11124
11091
|
}
|
|
11125
|
-
/** The write one field's staged text performs when the card is saved. */
|
|
11126
11092
|
type SettingsFieldWrite = {
|
|
11127
11093
|
kind: "set";
|
|
11128
11094
|
value: unknown;
|
|
11129
11095
|
} | {
|
|
11130
11096
|
kind: "clear";
|
|
11131
11097
|
};
|
|
11132
|
-
/** How one section field converts between its stored value and its draft text. */
|
|
11133
11098
|
interface SettingsFieldSpec {
|
|
11134
|
-
/** Field name inside the namespace section. */
|
|
11135
11099
|
field: string;
|
|
11136
|
-
/** Render a stored value as draft text; the empty string when the section carries none. */
|
|
11137
11100
|
format: (value: unknown) => string;
|
|
11138
|
-
/**
|
|
11139
|
-
* The write this draft text stages, or undefined when the text is not a
|
|
11140
|
-
* value this field accepts — which blocks the save rather than discarding it.
|
|
11141
|
-
*/
|
|
11142
11101
|
parse: (text: string) => SettingsFieldWrite | undefined;
|
|
11143
11102
|
}
|
|
11144
|
-
/**
|
|
11145
|
-
* A control whose value is written outside the settings section. A credential
|
|
11146
|
-
* literal never rides a response, so its draft has nothing to seed from: it is
|
|
11147
|
-
* blank until typed, and a blank draft writes nothing.
|
|
11148
|
-
*/
|
|
11149
11103
|
interface SettingsSecretSpec {
|
|
11150
|
-
/** Field name addressing this control inside the card's form. */
|
|
11151
11104
|
field: string;
|
|
11152
|
-
/** Write the staged text; resolves to whether the Host accepted it. */
|
|
11153
11105
|
write: (text: string) => Promise<boolean>;
|
|
11154
11106
|
}
|
|
11155
|
-
/** One field as a card's control renders it. */
|
|
11156
11107
|
interface SettingsFieldState {
|
|
11157
|
-
/** Draft text the control renders. */
|
|
11158
11108
|
text: string;
|
|
11159
|
-
/**
|
|
11160
|
-
* Whether saving would leave a user-layer entry for this field. A staged
|
|
11161
|
-
* edit answers for itself, so the badge previews the save rather than
|
|
11162
|
-
* reporting a state the pending edit already contradicts.
|
|
11163
|
-
*/
|
|
11164
11109
|
overridden: boolean;
|
|
11165
|
-
/** Whether the draft is not a value this field accepts, which blocks saving. */
|
|
11166
11110
|
invalid: boolean;
|
|
11167
11111
|
}
|
|
11168
|
-
/** Form state every plugin card shares. */
|
|
11169
11112
|
interface SettingsFormShell {
|
|
11170
|
-
/** False while the namespace is not served to this client; the card renders nothing. */
|
|
11171
11113
|
available: boolean;
|
|
11172
|
-
/** Whether the Host document accepts writes. */
|
|
11173
11114
|
writable: boolean;
|
|
11174
|
-
/** Whether the form holds edits that a save would write. */
|
|
11175
11115
|
dirty: boolean;
|
|
11176
|
-
/** Whether any staged draft is invalid, which blocks the save. */
|
|
11177
11116
|
invalid: boolean;
|
|
11178
|
-
/** Whether a save is crossing the wire. */
|
|
11179
11117
|
saving: boolean;
|
|
11180
|
-
/** Whether the last save did not land as staged; cleared by the next edit or save. */
|
|
11181
11118
|
failed: boolean;
|
|
11182
11119
|
}
|
|
11183
|
-
/** The write actions every plugin card's slot entry injects. */
|
|
11184
11120
|
interface SettingsFormActions {
|
|
11185
|
-
/** Stage draft text for one field. */
|
|
11186
11121
|
edit: (field: string, text: string) => void;
|
|
11187
|
-
/** Stage a clear, so saving lets the field re-inherit the composition layer. */
|
|
11188
11122
|
resetField: (field: string) => void;
|
|
11189
|
-
/** Write every staged edit, then re-seed from what the Host accepted. */
|
|
11190
11123
|
save: () => void;
|
|
11191
|
-
/** Drop every staged edit. */
|
|
11192
11124
|
discard: () => void;
|
|
11193
11125
|
}
|
|
11194
|
-
|
|
11195
|
-
|
|
11196
|
-
|
|
11197
|
-
* @param field - field name inside the namespace section.
|
|
11198
|
-
* @returns the field's conversion spec.
|
|
11199
|
-
*/
|
|
11200
|
-
declare function settingsNumberField(field: string): SettingsFieldSpec;
|
|
11201
|
-
/**
|
|
11202
|
-
* A free-text field. An empty draft clears the field, so emptying the control
|
|
11203
|
-
* and saving is the same gesture as resetting it.
|
|
11204
|
-
* @param field - field name inside the namespace section.
|
|
11205
|
-
* @returns the field's conversion spec.
|
|
11206
|
-
*/
|
|
11207
|
-
declare function settingsTextField(field: string): SettingsFieldSpec;
|
|
11208
|
-
/**
|
|
11209
|
-
* Stages one card's edits over one settings namespace and writes them on save.
|
|
11210
|
-
*
|
|
11211
|
-
* The form publishes through a snapshot store because slot components read
|
|
11212
|
-
* through a snapshot selector, while both the scope and the local drafts
|
|
11213
|
-
* change underneath; every projection is rebuilt from the two together.
|
|
11214
|
-
*/
|
|
11215
|
-
declare class SettingsFormModel<T> {
|
|
11126
|
+
export declare function settingsNumberField(field: string): SettingsFieldSpec;
|
|
11127
|
+
export declare function settingsTextField(field: string): SettingsFieldSpec;
|
|
11128
|
+
export declare class SettingsFormModel<T> {
|
|
11216
11129
|
private readonly scope;
|
|
11217
11130
|
private readonly specs;
|
|
11218
11131
|
private readonly secretSpecs;
|
|
@@ -11222,52 +11135,13 @@ declare class SettingsFormModel<T> {
|
|
|
11222
11135
|
private readonly unsubscribe;
|
|
11223
11136
|
private saving;
|
|
11224
11137
|
private failed;
|
|
11225
|
-
/**
|
|
11226
|
-
* @param scope - the shared configuration form for this card's namespace.
|
|
11227
|
-
* @param specs - the section fields this card edits.
|
|
11228
|
-
* @param secrets - the card's write-only controls, written outside the section.
|
|
11229
|
-
*/
|
|
11230
11138
|
constructor(scope: SettingsFormScope<T>, specs: SettingsFieldSpec[], secrets?: SettingsSecretSpec[]);
|
|
11231
|
-
/**
|
|
11232
|
-
* Publish a projection of this form, rebuilt whenever the scope or a draft changes.
|
|
11233
|
-
* @param project - build the card's state from the form's current reads.
|
|
11234
|
-
* @returns the store the card's component reads through its bound selector.
|
|
11235
|
-
*/
|
|
11236
11139
|
bind<S>(project: () => S): SnapshotStore<S>;
|
|
11237
|
-
/**
|
|
11238
|
-
* Read the card-level state: what the Host serves, and what a save would do.
|
|
11239
|
-
* @returns the form state every card shares.
|
|
11240
|
-
*/
|
|
11241
11140
|
shell(): SettingsFormShell;
|
|
11242
|
-
/**
|
|
11243
|
-
* Read one control's state.
|
|
11244
|
-
* @param field - field name of a section field or of a write-only control.
|
|
11245
|
-
* @returns the draft text, whether a save would leave an override, and whether it is invalid.
|
|
11246
|
-
*/
|
|
11247
11141
|
field(field: string): SettingsFieldState;
|
|
11248
|
-
/**
|
|
11249
|
-
* Build the edit, reset, save, and discard actions bound to this form.
|
|
11250
|
-
* @returns the actions a card's slot entry injects.
|
|
11251
|
-
*/
|
|
11252
11142
|
actions(): SettingsFormActions;
|
|
11253
|
-
/**
|
|
11254
|
-
* Write every staged edit, then re-seed from what the Host accepted.
|
|
11255
|
-
*
|
|
11256
|
-
* The Host is the only authority on whether a value was accepted — its
|
|
11257
|
-
* validators own the constraints no schema can express — so the outcome is
|
|
11258
|
-
* read back from the section rather than predicted here. A save that did not
|
|
11259
|
-
* land keeps its drafts, so the user can correct them instead of retyping.
|
|
11260
|
-
* @returns settlement after every write and the read-back.
|
|
11261
|
-
*/
|
|
11262
11143
|
save(): Promise<void>;
|
|
11263
|
-
/** Release the form's accepted-value subscription. */
|
|
11264
11144
|
dispose(): void;
|
|
11265
|
-
/**
|
|
11266
|
-
* Every staged edit a save would write. An entry whose draft is not a value
|
|
11267
|
-
* its field accepts carries no write: the form is still dirty, and the save
|
|
11268
|
-
* refuses rather than dropping the edit.
|
|
11269
|
-
* @returns the planned writes, in the order the fields were staged.
|
|
11270
|
-
*/
|
|
11271
11145
|
private plan;
|
|
11272
11146
|
private stage;
|
|
11273
11147
|
private spec;
|
|
@@ -11280,162 +11154,82 @@ declare class SettingsFormModel<T> {
|
|
|
11280
11154
|
}
|
|
11281
11155
|
//#endregion
|
|
11282
11156
|
//#region src/client/settings-form/fields.d.ts
|
|
11283
|
-
/** What every settings field control needs regardless of its value type. */
|
|
11284
11157
|
interface SettingsFieldProps {
|
|
11285
|
-
/** Stable id associating the label with its control. */
|
|
11286
11158
|
id: string;
|
|
11287
|
-
/** Visible label. */
|
|
11288
11159
|
label: string;
|
|
11289
|
-
/** One-line explanation rendered under the control. */
|
|
11290
11160
|
hint: string;
|
|
11291
|
-
/** Draft text this control renders. */
|
|
11292
11161
|
text: string;
|
|
11293
|
-
/** True when saving would leave a user-layer entry for this field. */
|
|
11294
11162
|
overridden: boolean;
|
|
11295
|
-
/** True when the draft is not a value this field accepts. */
|
|
11296
11163
|
invalid: boolean;
|
|
11297
|
-
/** Copy for the overridden badge. */
|
|
11298
11164
|
overriddenLabel: string;
|
|
11299
|
-
/** Copy for the reset control. */
|
|
11300
11165
|
resetLabel: string;
|
|
11301
|
-
/** Copy shown in place of the hint while the draft is invalid. */
|
|
11302
11166
|
invalidLabel: string;
|
|
11303
|
-
/** Disables every control (read-only document, or an unavailable namespace). */
|
|
11304
11167
|
disabled: boolean;
|
|
11305
|
-
/** Stage draft text. */
|
|
11306
11168
|
onEdit: (text: string) => void;
|
|
11307
|
-
/** Stage a clear so the field re-inherits the composition layer. */
|
|
11308
11169
|
onReset: () => void;
|
|
11309
11170
|
}
|
|
11310
|
-
|
|
11311
|
-
* A staged value field. `numeric` only hints the keypad: which drafts a field
|
|
11312
|
-
* accepts is decided by its spec, so the control never silently rewrites what
|
|
11313
|
-
* the user typed.
|
|
11314
|
-
* @param props - the field's copy, its staged text, and the edit actions.
|
|
11315
|
-
* @returns the labelled control.
|
|
11316
|
-
*/
|
|
11317
|
-
declare function SettingsValueField(props: Omit<SettingsFieldProps, "hint"> & {
|
|
11318
|
-
/** Optional explanation shown below the input. */
|
|
11171
|
+
export declare function SettingsValueField(props: Omit<SettingsFieldProps, "hint"> & {
|
|
11319
11172
|
hint?: string;
|
|
11320
|
-
/** Rules disclosed by the information button beside the label. */
|
|
11321
11173
|
help?: {
|
|
11322
11174
|
label: string;
|
|
11323
11175
|
content: ReactNode;
|
|
11324
11176
|
};
|
|
11325
|
-
/** Hints a numeric keypad without narrowing what the control accepts. */
|
|
11326
11177
|
numeric?: boolean;
|
|
11327
|
-
/** Placeholder shown while the draft is empty. */
|
|
11328
11178
|
placeholder?: string;
|
|
11329
11179
|
}): import("react/jsx-runtime").JSX.Element;
|
|
11330
|
-
|
|
11331
|
-
* A write-only credential control. The value never rides a response, so the
|
|
11332
|
-
* control reports only whether one is configured and starts blank; a blank
|
|
11333
|
-
* draft writes nothing, which keeps the stored key rather than clearing it.
|
|
11334
|
-
* 控件要求浏览器不要把已存的登录密码自动填进来(上游 11c0511271)。
|
|
11335
|
-
* @param props - the field's copy, its staged text, and the configured state.
|
|
11336
|
-
* @returns the labelled control.
|
|
11337
|
-
*/
|
|
11338
|
-
declare function SettingsSecretField(props: Pick<SettingsFieldProps, "id" | "label" | "hint" | "text" | "disabled" | "onEdit"> & {
|
|
11339
|
-
/** Whether the Host reports a configured credential for this reference. */
|
|
11180
|
+
export declare function SettingsSecretField(props: Pick<SettingsFieldProps, "id" | "label" | "hint" | "text" | "disabled" | "onEdit"> & {
|
|
11340
11181
|
configured: boolean;
|
|
11341
|
-
/** Copy describing the configured state. */
|
|
11342
11182
|
stateLabel: string;
|
|
11343
11183
|
}): import("react/jsx-runtime").JSX.Element;
|
|
11344
11184
|
//#endregion
|
|
11345
11185
|
//#region src/client/settings-form/SettingsForm.d.ts
|
|
11346
|
-
/** The copy the form frame renders, from the owning plugin's dictionary. */
|
|
11347
11186
|
interface SettingsFormLabels {
|
|
11348
|
-
/** Shown in place of the controls while the namespace is not served. */
|
|
11349
11187
|
unavailable: string;
|
|
11350
|
-
/** Shown over the controls while the document is read-only. */
|
|
11351
11188
|
readOnly: string;
|
|
11352
|
-
/** Shown beside the save after a save the Host did not accept. */
|
|
11353
11189
|
saveFailed: string;
|
|
11354
|
-
/** The save control. */
|
|
11355
11190
|
save: string;
|
|
11356
|
-
/** The save control while a save is crossing the wire. */
|
|
11357
11191
|
saving: string;
|
|
11358
11192
|
}
|
|
11359
|
-
/** Form chrome shared by every settings page. */
|
|
11360
11193
|
interface SettingsFormProps {
|
|
11361
|
-
/** The frame's copy. */
|
|
11362
11194
|
labels: SettingsFormLabels;
|
|
11363
|
-
/** The form state: availability, writability, and what a save would do. */
|
|
11364
11195
|
state: SettingsFormShell;
|
|
11365
|
-
/** Write every staged edit. */
|
|
11366
11196
|
onSave: () => void;
|
|
11367
|
-
/** Drop every staged edit; the form calls it when it leaves the page. */
|
|
11368
11197
|
onDiscard: () => void;
|
|
11369
|
-
/** The plugin's controls. */
|
|
11370
11198
|
children: ReactNode;
|
|
11371
11199
|
}
|
|
11372
|
-
|
|
11373
|
-
* Render one plugin's settings form.
|
|
11374
|
-
* @param props - the form's copy and state, its controls, and the save and discard actions.
|
|
11375
|
-
* @returns the form, or the unavailable line while the namespace is not served.
|
|
11376
|
-
*/
|
|
11377
|
-
declare function SettingsForm(props: SettingsFormProps): import("react/jsx-runtime").JSX.Element;
|
|
11200
|
+
export declare function SettingsForm(props: SettingsFormProps): import("react/jsx-runtime").JSX.Element;
|
|
11378
11201
|
//#endregion
|
|
11379
11202
|
//#region src/client/schema-form/schema-node.d.ts
|
|
11380
|
-
/** 节点不可编辑的原因;`null` 表示可编辑。 */
|
|
11381
11203
|
type ReadOnlyReason = "transform" | "function" | "constructor";
|
|
11382
|
-
/** 归一化后的字段元数据(schemastery `meta` 的可用子集)。 */
|
|
11383
11204
|
interface FieldMeta {
|
|
11384
|
-
/** `description`(可能是本地化字典):渲染时经 locale 解析。 */
|
|
11385
11205
|
description: string | Readonly<Record<string, string>> | undefined;
|
|
11386
|
-
/** `comment`:纯文本补充说明。 */
|
|
11387
11206
|
comment: string | undefined;
|
|
11388
|
-
/** `link`:外部文档。 */
|
|
11389
11207
|
link: string | undefined;
|
|
11390
|
-
/** `role`:控件提示(`secret` / `slider` / `datetime` …)。 */
|
|
11391
11208
|
role: string | undefined;
|
|
11392
|
-
/** `role === 'secret'`:值不回传,只能写。 */
|
|
11393
11209
|
secret: boolean;
|
|
11394
|
-
/** `required()`。 */
|
|
11395
11210
|
required: boolean;
|
|
11396
|
-
/** `disabled()`:控件禁用。 */
|
|
11397
11211
|
disabled: boolean;
|
|
11398
|
-
/** `collapse()`:嵌套分组默认折叠。 */
|
|
11399
11212
|
collapse: boolean;
|
|
11400
|
-
/** `deprecated()` / `experimental()` 的徽标文本。 */
|
|
11401
11213
|
badges: readonly string[];
|
|
11402
|
-
/** `pattern()` 的正则来源。 */
|
|
11403
11214
|
pattern: string | undefined;
|
|
11404
|
-
/** `min()`。 */
|
|
11405
11215
|
min: number | undefined;
|
|
11406
|
-
/** `max()`。 */
|
|
11407
11216
|
max: number | undefined;
|
|
11408
|
-
/** `step()`:`1` 表示整数。 */
|
|
11409
11217
|
step: number | undefined;
|
|
11410
|
-
/** 是否声明了默认值(与「默认值是 undefined」区分开)。 */
|
|
11411
11218
|
hasDefault: boolean;
|
|
11412
|
-
/** 声明的默认值。 */
|
|
11413
11219
|
defaultValue: unknown;
|
|
11414
|
-
/** `extra()`:角色附带的任意数据,字段槽的自定义控件可用。 */
|
|
11415
11220
|
extra: unknown;
|
|
11416
11221
|
}
|
|
11417
|
-
/** 每种节点共有的部分。 */
|
|
11418
11222
|
interface FieldNodeBase {
|
|
11419
|
-
/** 这一层的名字:对象字段名、tuple 的索引、动态子节点的占位段。 */
|
|
11420
11223
|
key: string;
|
|
11421
|
-
/** 从段根起的路径;动态段是 {@link DYNAMIC_SEGMENT}。 */
|
|
11422
11224
|
path: readonly string[];
|
|
11423
|
-
/**
|
|
11424
|
-
* 按值展开时算好的显示名:数组成员的**项身份**(见 {@link FieldNodeBase} 所在的 array 节点)。
|
|
11425
|
-
* 投影时没有(`undefined`),渲染层用它优先于字段名。
|
|
11426
|
-
*/
|
|
11427
11225
|
label: string | undefined;
|
|
11428
|
-
/** 归一化后的元数据。 */
|
|
11429
11226
|
meta: FieldMeta;
|
|
11430
|
-
/** 不可编辑的原因;`null` 表示可编辑。 */
|
|
11431
11227
|
readOnly: ReadOnlyReason | null;
|
|
11432
11228
|
}
|
|
11433
|
-
/** 位集的一位。 */
|
|
11434
11229
|
interface BitsEntry {
|
|
11435
11230
|
name: string;
|
|
11436
11231
|
bit: number;
|
|
11437
11232
|
}
|
|
11438
|
-
/** 渲染层要的一个字段节点。 */
|
|
11439
11233
|
type FieldNode = (FieldNodeBase & {
|
|
11440
11234
|
type: "object";
|
|
11441
11235
|
fields: readonly FieldNode[];
|
|
@@ -11446,25 +11240,14 @@ type FieldNode = (FieldNodeBase & {
|
|
|
11446
11240
|
}) | (FieldNodeBase & {
|
|
11447
11241
|
type: "array";
|
|
11448
11242
|
item: FieldNode;
|
|
11449
|
-
/**
|
|
11450
|
-
* 项的**身份键**:这一项的「名字」取自它自己的哪个字段。显式声明优先
|
|
11451
|
-
* (`z.array(inner).role('items', { mergeKey: 'id' })`),否则 item 上有 `id` 字段就用 `id`。
|
|
11452
|
-
* 它只决定显示名与「同名即冲突」的判据——写盘仍按索引(host 的 path op 就是索引语义)。
|
|
11453
|
-
*/
|
|
11454
11243
|
mergeKey: string | undefined;
|
|
11455
11244
|
}) | (FieldNodeBase & {
|
|
11456
11245
|
type: "tuple";
|
|
11457
11246
|
items: readonly FieldNode[];
|
|
11458
11247
|
}) | (FieldNodeBase & {
|
|
11459
11248
|
type: "union";
|
|
11460
|
-
/** 成员全是字面量时的可选项;否则 `undefined`。 */
|
|
11461
11249
|
choices: readonly unknown[] | undefined;
|
|
11462
11250
|
variants: readonly FieldNode[];
|
|
11463
|
-
/**
|
|
11464
|
-
* 判别标签:按哪个字段的值挑变体。显式声明优先
|
|
11465
|
-
* (`z.union([...]).role('union', { tag: 'kind' })`),否则取所有对象成员共有的**唯一**常量字段。
|
|
11466
|
-
* schemastery 本身没有 tag 机制(union 按声明顺序逐个试),所以这只是渲染与校验的选支依据。
|
|
11467
|
-
*/
|
|
11468
11251
|
tagKey: string | undefined;
|
|
11469
11252
|
}) | (FieldNodeBase & {
|
|
11470
11253
|
type: "intersect";
|
|
@@ -11480,441 +11263,166 @@ type FieldNode = (FieldNodeBase & {
|
|
|
11480
11263
|
inner: FieldNode;
|
|
11481
11264
|
}) | (FieldNodeBase & {
|
|
11482
11265
|
type: "string" | "number" | "boolean" | "any" | "never" | "function";
|
|
11483
|
-
}) |
|
|
11484
|
-
/** 自引用 schema 回到祖先处:值这一层以下不再描述,由渲染层展开或只读呈现。 */
|
|
11485
|
-
(FieldNodeBase & {
|
|
11266
|
+
}) | (FieldNodeBase & {
|
|
11486
11267
|
type: "recursive";
|
|
11487
11268
|
origin: string;
|
|
11488
11269
|
});
|
|
11489
|
-
/**
|
|
11490
|
-
* 投影一个 schema 节点。
|
|
11491
|
-
* @param schema - rehydrate 之后的 volatile 表单 schema(或它的子节点)。
|
|
11492
|
-
* @param path - 该节点相对段根的路径;动态子节点由调用方给占位段。
|
|
11493
|
-
* @returns 渲染层要的字段树。
|
|
11494
|
-
*/
|
|
11495
11270
|
declare function projectNode(schema: SchemaNode, path?: readonly string[]): FieldNode;
|
|
11496
|
-
/** 按当前值展开出的一个字段:路径与名字已按真实键与索引替换。 */
|
|
11497
11271
|
interface WalkedField {
|
|
11498
11272
|
path: readonly string[];
|
|
11499
11273
|
node: FieldNode;
|
|
11500
|
-
/**
|
|
11501
|
-
* 这一行是某个动态容器的**成员本身**(dict 的键 / array 的项)时给出它的身份:容器路径、键、以及数组
|
|
11502
|
-
* 项的位置。渲染层用它画成员行(名字 + 移除);成员的子字段不带这个标记。
|
|
11503
|
-
*/
|
|
11504
11274
|
member?: {
|
|
11505
11275
|
parent: readonly string[];
|
|
11506
11276
|
key: string;
|
|
11507
11277
|
index: number | undefined;
|
|
11508
11278
|
};
|
|
11509
11279
|
}
|
|
11510
|
-
/** 候选键的来源(业务注册;见 `hints.ts`):dict 的「可以加哪些键」。 */
|
|
11511
11280
|
interface SuggestedKeys {
|
|
11512
|
-
/**
|
|
11513
|
-
* 读某个 dict 字段的候选键。
|
|
11514
|
-
* @param path - 该字段的具体路径。
|
|
11515
|
-
* @returns 候选键;没有就是空数组。
|
|
11516
|
-
*/
|
|
11517
11281
|
keysFor(path: readonly string[]): readonly string[];
|
|
11518
11282
|
}
|
|
11519
|
-
|
|
11520
|
-
* 按当前值把字段树展开成渲染顺序的扁平列表(前序):容器在前、子项紧随其后。
|
|
11521
|
-
*
|
|
11522
|
-
* 出现的**只有值里有的东西,加上必填的**:对象的必填字段始终占行(值是空的也要让用户看见"必须填"),非必填的
|
|
11523
|
-
* 按值出现——值里没有就不占行,它在这一层的「添加属性」候选里,选中才加。数组按索引、字典按键展开;字面量
|
|
11524
|
-
* union 是叶子控件,对象 union 只展开与当前值匹配的那个变体,intersect 的各成员在同一层展开。
|
|
11525
|
-
* @param root - 段根的字段树。
|
|
11526
|
-
* @param value - 生效值(或草稿后的值)。
|
|
11527
|
-
* @returns 渲染顺序的字段列表。
|
|
11528
|
-
*/
|
|
11529
|
-
declare function walkFields(root: FieldNode, value: unknown): WalkedField[];
|
|
11530
|
-
/** union 的变体切换:一个选项要写的值。 */
|
|
11283
|
+
export declare function walkFields(root: FieldNode, value: unknown): WalkedField[];
|
|
11531
11284
|
interface VariantChoice {
|
|
11532
|
-
/** 页面上显示的名字:判别标签的值,或变体的形状。 */
|
|
11533
11285
|
label: string;
|
|
11534
|
-
/** 写这个值就等于选中这一支。 */
|
|
11535
11286
|
value: unknown;
|
|
11536
11287
|
}
|
|
11537
11288
|
//#endregion
|
|
11538
11289
|
//#region src/client/schema-form/draft.d.ts
|
|
11539
|
-
/** 命名空间段(一段配置)的值。 */
|
|
11540
11290
|
type Section = Record<string, unknown>;
|
|
11541
|
-
|
|
11542
|
-
type TextParseResult =
|
|
11543
|
-
/** 得到一个值。 */
|
|
11544
|
-
{
|
|
11291
|
+
type TextParseResult = {
|
|
11545
11292
|
kind: "value";
|
|
11546
11293
|
value: unknown;
|
|
11547
|
-
} |
|
|
11548
|
-
/** 这段文本不产生写(例如 secret 留空=保留已存的值)。 */
|
|
11549
|
-
{
|
|
11294
|
+
} | {
|
|
11550
11295
|
kind: "skip";
|
|
11551
|
-
} |
|
|
11552
|
-
/** 不是这个字段接受的值:留在屏幕上并挡住保存。 */
|
|
11553
|
-
{
|
|
11296
|
+
} | {
|
|
11554
11297
|
kind: "invalid";
|
|
11555
11298
|
message: string;
|
|
11556
11299
|
};
|
|
11557
|
-
/** 控件给文本草稿的解析规则。 */
|
|
11558
11300
|
type TextParse = (text: string) => TextParseResult;
|
|
11559
|
-
/** 整段校验失败:消息 + 它落在哪一层(页面把消息画在**出错的那一行**上)。 */
|
|
11560
11301
|
interface ValidationFailure {
|
|
11561
|
-
/** 面向用户的消息(已去掉 schemastery 拼的 `$…` 位置前缀)。 */
|
|
11562
11302
|
message: string;
|
|
11563
|
-
/** 具体路径(段根起);空数组表示错误在整段上。 */
|
|
11564
11303
|
path: readonly string[];
|
|
11565
11304
|
}
|
|
11566
|
-
|
|
11567
|
-
* 把校验器抛出的错误收成一条失败。
|
|
11568
|
-
*
|
|
11569
|
-
* schemastery 的 `ValidationError` 把路径留在 `options.path` 上(消息里的 `$…` 前缀是给命令行看的),所以这里
|
|
11570
|
-
* 取路径、去前缀——行内报错据此知道挂在哪一行。
|
|
11571
|
-
* @param error - 校验器抛出的错误。
|
|
11572
|
-
* @returns 消息与路径。
|
|
11573
|
-
*/
|
|
11574
|
-
declare function failureOf(error: unknown): ValidationFailure;
|
|
11575
|
-
/** 一字段渲染时要读的状态。 */
|
|
11305
|
+
export declare function failureOf(error: unknown): ValidationFailure;
|
|
11576
11306
|
interface DraftFieldState {
|
|
11577
|
-
/** 控件要显示的值:草稿优先,否则生效层。 */
|
|
11578
11307
|
value: unknown;
|
|
11579
|
-
/** 文本草稿(文本控件显示它而不是重新格式化值)。 */
|
|
11580
11308
|
text: string | undefined;
|
|
11581
|
-
/** 草稿不合法时的消息(控件显示,同时挡住保存)。 */
|
|
11582
11309
|
invalid: string | undefined;
|
|
11583
|
-
/** 保存后这一字段是否会留下用户层条目。 */
|
|
11584
11310
|
overridden: boolean;
|
|
11585
|
-
/** 这一字段在本页有还没保存的编辑(页面上给它一处高亮与一个「撤回」)。 */
|
|
11586
11311
|
staged: boolean;
|
|
11587
11312
|
}
|
|
11588
|
-
/** 模型要读要写的那个命名空间。 */
|
|
11589
11313
|
type DraftScope = ConfigForm<Section>;
|
|
11590
11314
|
//#endregion
|
|
11591
11315
|
//#region src/client/schema-form/hints.d.ts
|
|
11592
|
-
/** 一个 dict 字段的候选键读数。 */
|
|
11593
11316
|
type SuggestedKeysReader = () => readonly string[];
|
|
11594
|
-
/** 一个字段的文案(业务知道的说法;schema 上没有 title 这种位)。 */
|
|
11595
11317
|
interface FieldText {
|
|
11596
|
-
/** 短名字(行式视图里当注释的抬头)。 */
|
|
11597
11318
|
label?: string | undefined;
|
|
11598
|
-
/** 一句话说明。 */
|
|
11599
11319
|
hint?: string | undefined;
|
|
11600
11320
|
}
|
|
11601
|
-
/** 一个字段的文案读数。 */
|
|
11602
11321
|
type FieldTextReader = () => FieldText;
|
|
11603
|
-
/** 一个可选项:要写进去的值,以及页面上显示的名字。 */
|
|
11604
11322
|
interface SelectOption {
|
|
11605
|
-
/** 选中时写进配置的值。 */
|
|
11606
11323
|
value: unknown;
|
|
11607
|
-
/** 显示名;省略就用值本身。 */
|
|
11608
11324
|
label?: string | undefined;
|
|
11609
11325
|
}
|
|
11610
|
-
/** 一个字段的候选值读数。 */
|
|
11611
11326
|
interface SelectSpec {
|
|
11612
|
-
/**
|
|
11613
|
-
* 候选依赖哪些**兄弟字段**(相对该字段所在对象的路径)。
|
|
11614
|
-
*
|
|
11615
|
-
* 依赖只声明"什么时候要重算":读侧在投影时按当前读数(草稿优先)求一次候选,所以声明了依赖的字段会随着
|
|
11616
|
-
* 兄弟字段的编辑立刻换候选——「选完服务商才列它有哪些模型」就是这么来的。
|
|
11617
|
-
*/
|
|
11618
11327
|
dependsOn?: readonly (readonly string[])[] | undefined;
|
|
11619
|
-
/**
|
|
11620
|
-
* 求候选。
|
|
11621
|
-
* @param read - 按依赖路径(相对该字段所在对象)读当前值:草稿优先。
|
|
11622
|
-
* @returns 可选项,顺序即页面上的顺序。
|
|
11623
|
-
*/
|
|
11624
11328
|
options: (read: (path: readonly string[]) => unknown) => readonly SelectOption[];
|
|
11625
11329
|
}
|
|
11626
|
-
/** 一个命名空间里各字段的候选键、文案与候选值。 */
|
|
11627
11330
|
interface SchemaFormHintsFace {
|
|
11628
|
-
/**
|
|
11629
|
-
* 注册一个 dict 字段的候选键读数(重复注册同一处会覆盖,并通知一次)。
|
|
11630
|
-
* @param ns - settings 命名空间(行 id)。
|
|
11631
|
-
* @param path - 该 dict 字段的具体路径(顶层字段就是 `['models']`)。
|
|
11632
|
-
* @param read - 同步读数:当前候选键(顺序即页面上的顺序)。
|
|
11633
|
-
* @returns 注销函数。
|
|
11634
|
-
*/
|
|
11635
11331
|
suggestKeys(ns: string, path: readonly string[], read: SuggestedKeysReader): () => void;
|
|
11636
|
-
/**
|
|
11637
|
-
* 读某处当前声明的候选键。
|
|
11638
|
-
* @param ns - settings 命名空间。
|
|
11639
|
-
* @param path - 该字段的路径。
|
|
11640
|
-
* @returns 候选键;没注册过就是空数组。
|
|
11641
|
-
*/
|
|
11642
11332
|
keysFor(ns: string, path: readonly string[]): readonly string[];
|
|
11643
|
-
/**
|
|
11644
|
-
* 注册一个字段的文案(短名 + 一句话说明)。行式视图把它画成注释行;schema 的 `description` 是兜底。
|
|
11645
|
-
* @param ns - settings 命名空间。
|
|
11646
|
-
* @param path - 该字段的路径。
|
|
11647
|
-
* @param read - 同步读数。
|
|
11648
|
-
* @returns 注销函数。
|
|
11649
|
-
*/
|
|
11650
11333
|
describe(ns: string, path: readonly string[], read: FieldTextReader): () => void;
|
|
11651
|
-
/**
|
|
11652
|
-
* 读某处当前注册的文案。
|
|
11653
|
-
* @param ns - settings 命名空间。
|
|
11654
|
-
* @param path - 该字段的路径。
|
|
11655
|
-
* @returns 文案;没注册过就是空对象。
|
|
11656
|
-
*/
|
|
11657
11334
|
textFor(ns: string, path: readonly string[]): FieldText;
|
|
11658
|
-
/**
|
|
11659
|
-
* 注册一个字段的候选值读数(页面据此把字段画成选择器,并随依赖字段变化重算)。
|
|
11660
|
-
* @param ns - settings 命名空间。
|
|
11661
|
-
* @param path - 该字段的路径。
|
|
11662
|
-
* @param spec - 候选取法与它依赖的兄弟字段。
|
|
11663
|
-
* @returns 注销函数。
|
|
11664
|
-
*/
|
|
11665
11335
|
select(ns: string, path: readonly string[], spec: SelectSpec): () => void;
|
|
11666
|
-
/**
|
|
11667
|
-
* 注册一个**具名候选源**:schema 上用 `role('select', { source })` 认领它,字段因此不必在客户端按 ns/path
|
|
11668
|
-
* 登记——同一个源可以被多行、多个字段复用(「服务商」「模型」就是这种)。
|
|
11669
|
-
* @param name - 源的名字(schema 的 `role` extra 里写的那一个)。
|
|
11670
|
-
* @param spec - 候选取法与它依赖的兄弟字段。
|
|
11671
|
-
* @returns 注销函数。
|
|
11672
|
-
*/
|
|
11673
11336
|
source(name: string, spec: SelectSpec): () => void;
|
|
11674
|
-
/**
|
|
11675
|
-
* 读一个具名候选源。
|
|
11676
|
-
* @param name - 源的名字。
|
|
11677
|
-
* @returns 该源的读数;没注册过就是 `undefined`。
|
|
11678
|
-
*/
|
|
11679
11337
|
sourceFor(name: string): SelectSpec | undefined;
|
|
11680
|
-
/**
|
|
11681
|
-
* 读某处当前声明的候选值读数。
|
|
11682
|
-
* @param ns - settings 命名空间。
|
|
11683
|
-
* @param path - 该字段的路径。
|
|
11684
|
-
* @returns 候选读数;没注册过就是 `undefined`。
|
|
11685
|
-
*/
|
|
11686
11338
|
selectFor(ns: string, path: readonly string[]): SelectSpec | undefined;
|
|
11687
11339
|
}
|
|
11688
|
-
|
|
11689
|
-
declare class SchemaFormHints extends Service implements SchemaFormHintsFace {
|
|
11340
|
+
export declare class SchemaFormHints extends Service implements SchemaFormHintsFace {
|
|
11690
11341
|
#private;
|
|
11691
|
-
/** @param ctx - 提供本服务的插件上下文。 */
|
|
11692
11342
|
constructor(ctx: Context);
|
|
11693
|
-
/** @param ns - settings 命名空间。 @param path - 字段路径。 @returns 该处的键。 */
|
|
11694
11343
|
keysFor(ns: string, path: readonly string[]): readonly string[];
|
|
11695
|
-
/** @param ns - settings 命名空间。 @param path - 字段路径。 @returns 该处注册的文案。 */
|
|
11696
11344
|
textFor(ns: string, path: readonly string[]): FieldText;
|
|
11697
|
-
/**
|
|
11698
|
-
* @param ns - settings 命名空间。
|
|
11699
|
-
* @param path - 字段路径。
|
|
11700
|
-
* @param spec - 候选取法与依赖。
|
|
11701
|
-
* @returns 注销函数。
|
|
11702
|
-
*/
|
|
11703
11345
|
select(ns: string, path: readonly string[], spec: SelectSpec): () => void;
|
|
11704
|
-
/** @param ns - settings 命名空间。 @param path - 字段路径。 @returns 该处注册的候选读数。 */
|
|
11705
11346
|
selectFor(ns: string, path: readonly string[]): SelectSpec | undefined;
|
|
11706
|
-
/**
|
|
11707
|
-
* @param name - 源的名字。
|
|
11708
|
-
* @param spec - 候选取法与依赖。
|
|
11709
|
-
* @returns 注销函数。
|
|
11710
|
-
*/
|
|
11711
11347
|
source(name: string, spec: SelectSpec): () => void;
|
|
11712
|
-
/** @param name - 源的名字。 @returns 该源注册的候选读数。 */
|
|
11713
11348
|
sourceFor(name: string): SelectSpec | undefined;
|
|
11714
|
-
/**
|
|
11715
|
-
* @param ns - settings 命名空间。
|
|
11716
|
-
* @param path - 字段路径。
|
|
11717
|
-
* @param read - 同步读数。
|
|
11718
|
-
* @returns 注销函数。
|
|
11719
|
-
*/
|
|
11720
11349
|
describe(ns: string, path: readonly string[], read: FieldTextReader): () => void;
|
|
11721
|
-
/**
|
|
11722
|
-
* @param ns - settings 命名空间。
|
|
11723
|
-
* @param path - 字段路径。
|
|
11724
|
-
* @param read - 同步读数。
|
|
11725
|
-
* @returns 注销函数。
|
|
11726
|
-
*/
|
|
11727
11350
|
suggestKeys(ns: string, path: readonly string[], read: SuggestedKeysReader): () => void;
|
|
11728
|
-
/**
|
|
11729
|
-
* 观察候选键的变化(注册与注销)。
|
|
11730
|
-
* @param listener - 变更回调。
|
|
11731
|
-
* @returns 取消订阅。
|
|
11732
|
-
*/
|
|
11733
11351
|
subscribe(listener: () => void): () => void;
|
|
11734
|
-
/**
|
|
11735
|
-
* 重新通知一次:读数背后的数据变了(业务自己知道),页面据此重算候选行。
|
|
11736
|
-
*/
|
|
11737
11352
|
refresh(): void;
|
|
11738
11353
|
}
|
|
11739
11354
|
declare module "@deepseek-ai/cordis" {
|
|
11740
11355
|
interface Context {
|
|
11741
|
-
/** 通用表单的提示面(dict 的候选键)。 */
|
|
11742
11356
|
schemaFormHints: SchemaFormHints;
|
|
11743
11357
|
}
|
|
11744
11358
|
}
|
|
11745
11359
|
//#endregion
|
|
11746
11360
|
//#region src/client/schema-form/controller.d.ts
|
|
11747
|
-
|
|
11748
|
-
* rehydrate 一段配置 schema,并判它能不能当页面的根。
|
|
11749
|
-
*
|
|
11750
|
-
* 能当根的形状有三种:对象段、**相交段**(共享判别字段 + 各分支的 `const` 标记,段值仍是对象)、以及带判别
|
|
11751
|
-
* 标签的 `union`(成员都是对象)。字面量 `union`(整段就是一个标量)不行:那一行的写盘会变成整段替换。
|
|
11752
|
-
* @param serialized - host 发来的 `schema.toJSON()`。
|
|
11753
|
-
* @param rehydrate - host schema 的 rehydrate。
|
|
11754
|
-
* @returns schema 与它的字段树,或 `undefined`(不能当页面根)。
|
|
11755
|
-
*/
|
|
11756
|
-
declare function projectRoot(serialized: unknown, rehydrate: (serialized: unknown) => SchemaNode): {
|
|
11361
|
+
export declare function projectRoot(serialized: unknown, rehydrate: (serialized: unknown) => SchemaNode): {
|
|
11757
11362
|
schema: SchemaNode;
|
|
11758
11363
|
root: FieldNode;
|
|
11759
11364
|
} | undefined;
|
|
11760
|
-
/**
|
|
11761
|
-
* 一行能否自动生成配置页:它的 schema 能 rehydrate 且根是 {@link projectRoot} 认的形状。
|
|
11762
|
-
* @param view - host 发来的命名空间视图。
|
|
11763
|
-
* @param rehydrate - host schema 的 rehydrate。
|
|
11764
|
-
* @returns 是否可以渲染。
|
|
11765
|
-
*/
|
|
11766
11365
|
declare function canRender(view: SettingsNamespaceView | undefined, rehydrate: (serialized: unknown) => SchemaNode): boolean;
|
|
11767
|
-
/** 提示面在控制器里的读法:候选键 + 字段文案 + 候选值。 */
|
|
11768
11366
|
interface HintSources extends SuggestedKeys {
|
|
11769
|
-
/**
|
|
11770
|
-
* 读某个字段的文案。
|
|
11771
|
-
* @param path - 该字段的具体路径。
|
|
11772
|
-
* @returns 业务注册的文案;没有就是空对象。
|
|
11773
|
-
*/
|
|
11774
11367
|
textFor: (path: readonly string[]) => FieldText;
|
|
11775
|
-
/**
|
|
11776
|
-
* 读某个字段的候选值读数;不接提示面的装配可以不给(字段就还是文本编辑)。
|
|
11777
|
-
* @param path - 该字段的具体路径。
|
|
11778
|
-
* @returns 业务注册的候选读数;没有就是 `undefined`。
|
|
11779
|
-
*/
|
|
11780
11368
|
selectFor?: ((path: readonly string[]) => SelectSpec | undefined) | undefined;
|
|
11781
|
-
/**
|
|
11782
|
-
* 读一个**具名候选源**(schema 的 `role('select', { source })` 认领它)。
|
|
11783
|
-
* @param name - 源的名字。
|
|
11784
|
-
* @returns 该源的读数;没注册过就是 `undefined`。
|
|
11785
|
-
*/
|
|
11786
11369
|
sourceFor?: ((name: string) => SelectSpec | undefined) | undefined;
|
|
11787
11370
|
}
|
|
11788
|
-
/** 控制器要的外部面(`apply` 里从 cordis ctx 组装;测试直接给替身)。 */
|
|
11789
11371
|
interface SchemaFormDeps {
|
|
11790
|
-
/** 本命名空间的共享配置表单(读 + 带栅栏的写)。 */
|
|
11791
11372
|
form: DraftScope;
|
|
11792
|
-
/** describe mirror 的读面:本行的 schema、autoGenerate 与 secret 槽。 */
|
|
11793
11373
|
describe: SettingsDescribeFace;
|
|
11794
|
-
/** rehydrate host 发来的 `schema.toJSON()`。 */
|
|
11795
11374
|
rehydrate: (serialized: unknown) => SchemaNode;
|
|
11796
|
-
/** 整段校验;失败时连路径一起给(页面把消息画在那一行)。 */
|
|
11797
11375
|
validate: (schema: SchemaNode, value: unknown) => ValidationFailure | undefined;
|
|
11798
|
-
/** 本包字典(项身份冲突这类本地校验的消息)。 */
|
|
11799
11376
|
t: SchemaFormTranslate;
|
|
11800
|
-
/**
|
|
11801
|
-
* dict 字段的候选键(业务注册,见 `hints.ts`):候选里有、值里没有的键会补成一行「未配置」,
|
|
11802
|
-
* 用户填了才算写。
|
|
11803
|
-
*/
|
|
11804
11377
|
hints?: HintSources | undefined;
|
|
11805
11378
|
}
|
|
11806
|
-
/**
|
|
11807
|
-
* 这一层「能加进来」的一项:schema 里声明、值里还没有的字段,或业务注册的候选键。
|
|
11808
|
-
*
|
|
11809
|
-
* 页面上不占行——它们出现在容器的闭合行那个「添加属性 / 添加键」输入框的候选里,选中才加。
|
|
11810
|
-
*/
|
|
11811
11379
|
interface AddableProperty {
|
|
11812
|
-
/** 加进来的键名。 */
|
|
11813
11380
|
key: string;
|
|
11814
|
-
/** 说明(schema 的 `description` / `comment`,可能是本地化字典):渲染层解析后当候选的副标题。 */
|
|
11815
11381
|
description: string | Readonly<Record<string, string>> | undefined;
|
|
11816
11382
|
}
|
|
11817
|
-
/** 页面级状态:表单壳 + 字段树 + 每字段草稿状态。 */
|
|
11818
11383
|
interface SchemaFormState extends SettingsFormShell$1 {
|
|
11819
|
-
/** 这一行的 schema 是否可渲染(否则页面只显示一行说明)。 */
|
|
11820
11384
|
configured: boolean;
|
|
11821
|
-
/** 字段树;未 configured 时是空对象树。 */
|
|
11822
11385
|
root: FieldNode;
|
|
11823
|
-
/** 按草稿后的值展开的字段列表(渲染顺序):追加的数组项与新增的字典键立刻出现。 */
|
|
11824
11386
|
walked: readonly WalkedField[];
|
|
11825
|
-
/** 每个具体路径的草稿状态,键见 {@link fieldKey}。 */
|
|
11826
11387
|
fields: ReadonlyMap<string, DraftFieldState>;
|
|
11827
|
-
/** secret 槽是否已配置,键见 {@link fieldKey}。 */
|
|
11828
11388
|
secrets: ReadonlyMap<string, boolean>;
|
|
11829
|
-
/** 每个字段的文案(提示面注册的),键见 {@link fieldKey};渲染层把它画成注释行。 */
|
|
11830
11389
|
texts: ReadonlyMap<string, FieldText>;
|
|
11831
|
-
/**
|
|
11832
|
-
* 每个字段的可选项,键见 {@link fieldKey}:字面量集合的 union 自带候选,其余来自提示面。
|
|
11833
|
-
* 候选依赖的兄弟字段一改,这里就跟着变(投影时按草稿后的值求一次)。
|
|
11834
|
-
*/
|
|
11835
11390
|
options: ReadonlyMap<string, readonly SelectOption[]>;
|
|
11836
|
-
/**
|
|
11837
|
-
* 每个容器能加进来的项,键见 {@link fieldKey}(容器自己的路径)。没有条目就是加不了东西——对象层的输入框
|
|
11838
|
-
* 因此只在还有声明字段没配时出现。
|
|
11839
|
-
*/
|
|
11840
11391
|
addable: ReadonlyMap<string, readonly AddableProperty[]>;
|
|
11841
|
-
/** 保存被 schema 挡下时的消息与它的位置。 */
|
|
11842
11392
|
violation: ValidationFailure | undefined;
|
|
11843
|
-
/** 每行的校验消息(键见 {@link fieldKey}):行内报错,与底部的整段提示同源。 */
|
|
11844
11393
|
invalidAt: ReadonlyMap<string, string>;
|
|
11845
11394
|
}
|
|
11846
|
-
/** 控件的写动作:全部落在草稿上,`save` 是唯一的写盘点。 */
|
|
11847
11395
|
interface SchemaFormActions {
|
|
11848
|
-
/** 暂存一个合法值。 */
|
|
11849
11396
|
set: (path: readonly string[], value: unknown) => void;
|
|
11850
|
-
/** 暂存一段文本(保存时解析)。 */
|
|
11851
11397
|
setText: (path: readonly string[], text: string, parse: TextParse) => void;
|
|
11852
|
-
/** 暂存「恢复默认」。 */
|
|
11853
11398
|
clear: (path: readonly string[]) => void;
|
|
11854
|
-
/** 追加一个数组项。 */
|
|
11855
11399
|
appendItem: (path: readonly string[]) => void;
|
|
11856
|
-
/** 移除一个数组项。 */
|
|
11857
11400
|
removeItem: (path: readonly string[], index: number) => void;
|
|
11858
|
-
/** 加一个字典键。 */
|
|
11859
11401
|
addKey: (path: readonly string[], key: string) => void;
|
|
11860
|
-
/** 删一个字典键。 */
|
|
11861
11402
|
removeKey: (path: readonly string[], key: string) => void;
|
|
11862
|
-
/** 写盘。 */
|
|
11863
11403
|
save: () => void;
|
|
11864
|
-
/** 撤销一个字段的草稿(行内编辑取消)。 */
|
|
11865
11404
|
revert: (path: readonly string[]) => void;
|
|
11866
|
-
/** 丢弃草稿。 */
|
|
11867
11405
|
discard: () => void;
|
|
11868
11406
|
}
|
|
11869
|
-
/** 槽位渲染器绑定的动作与可观察状态。 */
|
|
11870
11407
|
interface SchemaFormFace extends SchemaFormActions {
|
|
11871
11408
|
hooks: {
|
|
11872
11409
|
schemaForm: SnapshotStore<SchemaFormState>;
|
|
11873
11410
|
};
|
|
11874
11411
|
}
|
|
11875
|
-
/**
|
|
11876
|
-
* 一个字段的可选项。
|
|
11877
|
-
*
|
|
11878
|
-
* 字面量集合的 union(`z.union(["wal", "delete"])`)自己就带着候选;其余看提示面注册的读数——读的时候把依赖的
|
|
11879
|
-
* 兄弟字段值喂进去,所以「选完服务商才列它有哪些模型」是投影的一部分,不是额外的一次订阅。
|
|
11880
|
-
* @param node - 字段节点。
|
|
11881
|
-
* @param path - 该字段的具体路径。
|
|
11882
|
-
* @param value - 段值(草稿后的)。
|
|
11883
|
-
* @param hints - 提示面。
|
|
11884
|
-
* @returns 可选项;没有候选就是 `undefined`。
|
|
11885
|
-
*/
|
|
11886
11412
|
declare function optionsFor(node: FieldNode, path: readonly string[], value: unknown, hints: HintSources | undefined): readonly SelectOption[] | undefined;
|
|
11887
|
-
|
|
11888
|
-
* 一行配置页的控制器。
|
|
11889
|
-
*/
|
|
11890
|
-
declare class SchemaFormController {
|
|
11413
|
+
export declare class SchemaFormController {
|
|
11891
11414
|
#private;
|
|
11892
|
-
/**
|
|
11893
|
-
* @param ns - settings 命名空间(行 id)。
|
|
11894
|
-
* @param deps - 该行的共享表单与 schema 面。
|
|
11895
|
-
*/
|
|
11896
11415
|
constructor(ns: string, deps: SchemaFormDeps);
|
|
11897
|
-
/** 槽位渲染器要的动作与状态。 */
|
|
11898
11416
|
face(): SchemaFormFace;
|
|
11899
|
-
/** 本行的 settings 命名空间。 */
|
|
11900
11417
|
namespace(): string;
|
|
11901
|
-
/** 外部提示(候选键这类)变了:重新投影一次,字段树与草稿都不动。 */
|
|
11902
11418
|
refresh(): void;
|
|
11903
|
-
/** 释放订阅。 */
|
|
11904
11419
|
dispose(): void;
|
|
11905
11420
|
}
|
|
11906
11421
|
//#endregion
|
|
11907
11422
|
//#region src/client/schema-form/labels.d.ts
|
|
11908
|
-
/** 把 schema 里的本地化文本解析成当前语言;由 locale 服务提供。 */
|
|
11909
11423
|
type ResolveText = (text: string | Readonly<Record<string, string>>) => string;
|
|
11910
11424
|
//#endregion
|
|
11911
11425
|
//#region src/client/schema-form/locales.d.ts
|
|
11912
|
-
/**
|
|
11913
|
-
* 本包字典(命名空间 `settings.schema-form`):表单壳、字段控件与只读呈现的文案。
|
|
11914
|
-
*
|
|
11915
|
-
* 字段自身的人话标签不在这里(那是业务方经字段槽或 schema `description` 给的),这里只放**机制**文案。
|
|
11916
|
-
*/
|
|
11917
|
-
/** 中文文案(部署语言偏好是 zh)。 */
|
|
11918
11426
|
declare const zh: {
|
|
11919
11427
|
readonly unavailable: "该插件当前未加载,暂时无法配置。";
|
|
11920
11428
|
readonly readOnly: "本部署的设置为只读。";
|
|
@@ -11969,116 +11477,58 @@ declare const zh: {
|
|
|
11969
11477
|
readonly duplicateItem: "重复的 {key}:{value}";
|
|
11970
11478
|
readonly missingItem: "每一项都需要一个 {key}";
|
|
11971
11479
|
};
|
|
11972
|
-
/** 本命名空间的字典键。 */
|
|
11973
11480
|
type SchemaFormLocaleKey = keyof typeof zh;
|
|
11974
11481
|
//#endregion
|
|
11975
11482
|
//#region src/client/schema-form/slot-contract.d.ts
|
|
11976
|
-
/** 字段槽的 owner props:路由输入 + 显示状态 + 受控动作(默认控件要的一切都在这里)。 */
|
|
11977
11483
|
interface SchemaFieldOwnerProps {
|
|
11978
|
-
/** settings 命名空间(行 id)。 */
|
|
11979
11484
|
ns: string;
|
|
11980
|
-
/** 字段的具体路径(动态段已按真实键或索引替换)。 */
|
|
11981
11485
|
path: readonly string[];
|
|
11982
|
-
/** 字段节点(类型、`role`、`extra`、界限、只读原因)。 */
|
|
11983
11486
|
node: FieldNode;
|
|
11984
|
-
/** 显示标签:默认是字段名拆词,业务方经槽给时会覆盖。 */
|
|
11985
11487
|
label: string;
|
|
11986
|
-
/** 显示说明(`description` 本地化 + `comment`)。 */
|
|
11987
11488
|
hint: string | undefined;
|
|
11988
|
-
/** 当前生效值(草稿优先)。 */
|
|
11989
11489
|
value: unknown;
|
|
11990
|
-
/**
|
|
11991
|
-
* 这个字段的可选项:给了就是选择器(点值不再进文本编辑)。来源是字面量集合的 union,或业务经提示面注册的
|
|
11992
|
-
* 候选——候选依赖的兄弟字段一变,这里就换一批。
|
|
11993
|
-
*/
|
|
11994
11490
|
options: readonly SelectOption[] | undefined;
|
|
11995
|
-
/** 文本草稿:文本控件显示它,而不是重新格式化生效值。 */
|
|
11996
11491
|
text: string | undefined;
|
|
11997
|
-
/** secret 槽是否已配置(值本身不回传)。 */
|
|
11998
11492
|
secretConfigured: boolean;
|
|
11999
|
-
/** 嵌套深度:默认控件按它缩进。 */
|
|
12000
11493
|
depth: number;
|
|
12001
|
-
/** 保存后这一字段是否会留下用户层条目。 */
|
|
12002
11494
|
overridden: boolean;
|
|
12003
|
-
/** 草稿不合法时的消息。 */
|
|
12004
11495
|
invalid: string | undefined;
|
|
12005
|
-
/** 只读部署或不可用命名空间时为 true。 */
|
|
12006
11496
|
disabled: boolean;
|
|
12007
|
-
/** 本包字典(复刻或包装默认控件时用)。 */
|
|
12008
11497
|
t: SchemaFormTranslate;
|
|
12009
|
-
/** 容器动作(增删数组项、字典键、丢弃、保存)。 */
|
|
12010
11498
|
actions: SchemaFormActions;
|
|
12011
|
-
/**
|
|
12012
|
-
* 分组节点的折叠交互(object / dict / array / tuple);叶子节点是 `undefined`。
|
|
12013
|
-
* 默认折叠与否由 schema 的 `collapse()` 决定,用户点一下就是反转。
|
|
12014
|
-
*/
|
|
12015
11499
|
group: {
|
|
12016
11500
|
collapsed: boolean;
|
|
12017
11501
|
toggle: () => void;
|
|
12018
11502
|
} | undefined;
|
|
12019
|
-
/**
|
|
12020
|
-
* 这一行是动态容器的成员本身(dict 的键 / array 的项)时的身份:容器路径、键、数组项的位置。容器成员把它画进
|
|
12021
|
-
* 标题行(名字 + 移除),叶子成员由渲染层另起一行——所以「哪个字段属于哪个键/哪一项」在页面上一眼可见。
|
|
12022
|
-
*/
|
|
12023
11503
|
member: {
|
|
12024
11504
|
parent: readonly string[];
|
|
12025
11505
|
key: string;
|
|
12026
11506
|
index: number | undefined;
|
|
12027
11507
|
pending?: boolean;
|
|
12028
11508
|
} | undefined;
|
|
12029
|
-
/** 暂存一个合法值。 */
|
|
12030
11509
|
onChange: (value: unknown) => void;
|
|
12031
|
-
/**
|
|
12032
|
-
* 暂存一段文本:按字段类型的默认规则解析;给了 `parse` 就用它(例如 secret 留空=不写)。
|
|
12033
|
-
* @param text - 用户输入。
|
|
12034
|
-
* @param parse - 覆盖默认解析规则。
|
|
12035
|
-
*/
|
|
12036
11510
|
onEditText: (text: string, parse?: TextParse) => void;
|
|
12037
|
-
/** 暂存「恢复默认」。 */
|
|
12038
11511
|
onReset: () => void;
|
|
12039
11512
|
}
|
|
12040
|
-
/**
|
|
12041
|
-
* 字段槽注册项的完整 props:框架注入的 owner props({@link SchemaFieldOwnerProps})+它的 `select` 结果。
|
|
12042
|
-
*
|
|
12043
|
-
* 注册方的组件按这个类型声明参数(**不要**自己重写 owner props 的类型:注册时框架会把它读成 inject 面)。
|
|
12044
|
-
*/
|
|
12045
11513
|
type SchemaFieldComponentProps<M extends SchemaFieldMatch = SchemaFieldMatch> = PropsRuntime<"settings.schema-form.field"> & {
|
|
12046
11514
|
matched: M;
|
|
12047
11515
|
};
|
|
12048
|
-
/**
|
|
12049
|
-
* 字段槽注册项的 `select`:返回认领结果,或 `null` 表示不认领(chain 槽的约定是 `null` 放行给下一项,
|
|
12050
|
-
* `undefined` 不会被当成"不认领")。
|
|
12051
|
-
*/
|
|
12052
11516
|
type SchemaFieldSelect = (field: SchemaFieldOwnerProps) => SchemaFieldMatch | null;
|
|
12053
|
-
/** 字段槽 `select` 可以只给文案:控件仍由注册方渲染(拿本包的默认控件包一层即可)。 */
|
|
12054
11517
|
interface SchemaFieldMatch {
|
|
12055
|
-
/** 覆盖显示标签。 */
|
|
12056
11518
|
label?: string;
|
|
12057
|
-
/** 覆盖显示说明。 */
|
|
12058
11519
|
hint?: string;
|
|
12059
11520
|
}
|
|
12060
|
-
/** Factory 的输入 props:一行的配置页。 */
|
|
12061
11521
|
interface SchemaFormProps {
|
|
12062
|
-
/** settings 命名空间(行 id)。 */
|
|
12063
11522
|
ns: string;
|
|
12064
|
-
/** 该行的控制器动作与状态。 */
|
|
12065
11523
|
face: SchemaFormFace;
|
|
12066
|
-
/** schema 里的本地化文本(`description`)按当前语言解析。 */
|
|
12067
11524
|
resolveText: ResolveText;
|
|
12068
11525
|
}
|
|
12069
|
-
/** 本包字典的翻译函数(默认控件与表单壳使用)。 */
|
|
12070
11526
|
type SchemaFormTranslate = TranslateNS<"settings.schema-form">;
|
|
12071
11527
|
declare module "@deepseek-ai/dsh-client-ui-slots" {
|
|
12072
11528
|
interface LocaleNamespaceMap {
|
|
12073
|
-
/** 表单壳、字段控件与只读呈现的文案。 */
|
|
12074
11529
|
"settings.schema-form": SchemaFormLocaleKey;
|
|
12075
11530
|
}
|
|
12076
11531
|
interface SlotMap {
|
|
12077
|
-
/**
|
|
12078
|
-
* 字段级自定义输入与文案:按 `role` 或 `ns + path` 认领一个字段,命中即渲染注册方的组件(未命中落到默认
|
|
12079
|
-
* 控件)。注册项由业务插件用 `ctx.slots.inject('settings.schema-form.field', …)` 注册,声明由本包的
|
|
12080
|
-
* Factory 给出。
|
|
12081
|
-
*/
|
|
12082
11532
|
"settings.schema-form.field": {
|
|
12083
11533
|
kind: "chain";
|
|
12084
11534
|
scope: "root";
|
|
@@ -12086,10 +11536,6 @@ declare module "@deepseek-ai/dsh-client-ui-slots" {
|
|
|
12086
11536
|
};
|
|
12087
11537
|
}
|
|
12088
11538
|
interface SlotFactoryMap {
|
|
12089
|
-
/**
|
|
12090
|
-
* 一行配置页的渲染体:每个可渲染的行注册项经 `renderFactorySlot` 渲染同一个 Factory,字段槽因此只需声明
|
|
12091
|
-
* 一次(slots 的 children 声明 per key 唯一)。
|
|
12092
|
-
*/
|
|
12093
11539
|
"settings.schema-form.form": {
|
|
12094
11540
|
scope: "root";
|
|
12095
11541
|
props: SchemaFormProps;
|
|
@@ -12105,87 +11551,42 @@ declare module "@deepseek-ai/dsh-client-ui-slots" {
|
|
|
12105
11551
|
}
|
|
12106
11552
|
//#endregion
|
|
12107
11553
|
//#region src/client/schema-form/rows.d.ts
|
|
12108
|
-
/** 一个该自动长出配置页的行。 */
|
|
12109
11554
|
interface RowRegistrationPlan {
|
|
12110
|
-
/** `plugins.row.config` 的 key:`<bundle 包名>#<行 id>`。 */
|
|
12111
11555
|
key: string;
|
|
12112
|
-
/** settings 命名空间(行 id)。 */
|
|
12113
11556
|
ns: string;
|
|
12114
11557
|
}
|
|
12115
|
-
|
|
12116
|
-
* 配对命名空间与 bundle 行清单。
|
|
12117
|
-
* @param namespaces - host 发来的命名空间视图。
|
|
12118
|
-
* @param bundles - host 的 bundle 清单(含各 bundle 声明的行 id)。
|
|
12119
|
-
* @returns 该自动注册的行,按命名空间视图的顺序。
|
|
12120
|
-
*/
|
|
12121
|
-
declare function rowRegistrations(namespaces: readonly SettingsNamespaceView[], bundles: readonly BundleInfo[]): RowRegistrationPlan[];
|
|
11558
|
+
export declare function rowRegistrations(namespaces: readonly SettingsNamespaceView[], bundles: readonly BundleInfo[]): RowRegistrationPlan[];
|
|
12122
11559
|
//#endregion
|
|
12123
11560
|
//#region src/client/schema-form/value.d.ts
|
|
12124
|
-
/** 编辑态文本:字符串就是原文(换行照旧),其余按 JSON 写。 */
|
|
12125
11561
|
declare function valueText(value: unknown): string;
|
|
12126
|
-
/** 显示态文本:字符串带引号;多行与特殊字符都按 JSON 的写法收在一行里。 */
|
|
12127
11562
|
declare function tokenText(value: unknown): string;
|
|
12128
|
-
/** 值的语法色分组。 */
|
|
12129
11563
|
declare function tokenTone(value: unknown): "string" | "number" | "boolean" | "empty";
|
|
12130
|
-
/**
|
|
12131
|
-
* 行内值的默认呈现(显示态 token)。
|
|
12132
|
-
* @param props.owner - 字段上下文(值、是否 secret、只读原因)。
|
|
12133
|
-
* @returns 一行里的值节点。
|
|
12134
|
-
*/
|
|
12135
11564
|
declare function InlineValue({ owner }: {
|
|
12136
11565
|
owner: SchemaFieldOwnerProps;
|
|
12137
11566
|
}): ReactNode;
|
|
12138
|
-
/**
|
|
12139
|
-
* 字段槽注册方复用的默认值:只改文案时拿它包一层即可(`owner` 上覆盖 `label`/`hint`)。
|
|
12140
|
-
*
|
|
12141
|
-
* 注意行式视图里键名来自配置键本身、注释来自 `hint`,所以 `label` 只在业务自写控件时才需要。
|
|
12142
|
-
*/
|
|
12143
11567
|
declare function SchemaFieldDefault({ owner }: {
|
|
12144
11568
|
owner: SchemaFieldOwnerProps;
|
|
12145
11569
|
}): ReactNode;
|
|
12146
11570
|
//#endregion
|
|
12147
11571
|
//#region src/client/schema-form/fields.d.ts
|
|
12148
|
-
/**
|
|
12149
|
-
* 各类型的文本解析规则(消息来自本包字典)。
|
|
12150
|
-
*
|
|
12151
|
-
* 解析不只看类型:schema 上声明的界限(`pattern` / `min` / `max` / `step`)与字面量集合都在这里说话——
|
|
12152
|
-
* 用户敲完当场就知道对不对,而不是等保存时被整段校验退回。
|
|
12153
|
-
* @param node - 字段节点(`meta` 是约束的来源)。
|
|
12154
|
-
* @param t - 本包字典。
|
|
12155
|
-
* @returns 这段文本的解析规则。
|
|
12156
|
-
*/
|
|
12157
11572
|
declare function parseFor(node: FieldNode, t: SchemaFormTranslate): TextParse;
|
|
12158
11573
|
//#endregion
|
|
12159
11574
|
//#region src/client/schema-form/lines.d.ts
|
|
12160
|
-
|
|
12161
|
-
type AddLineSpec =
|
|
12162
|
-
/** 数组:追加一个空项。 */
|
|
12163
|
-
{
|
|
11575
|
+
type AddLineSpec = {
|
|
12164
11576
|
kind: "item";
|
|
12165
|
-
} |
|
|
12166
|
-
/** 字典:敲键名,或从候选键里选(业务注册的读数)。 */
|
|
12167
|
-
{
|
|
11577
|
+
} | {
|
|
12168
11578
|
kind: "key";
|
|
12169
11579
|
options: readonly AddableProperty[];
|
|
12170
|
-
} |
|
|
12171
|
-
/** 对象:从「schema 声明了、值里还没有」的字段里选(没有候选项时不给输入框)。 */
|
|
12172
|
-
{
|
|
11580
|
+
} | {
|
|
12173
11581
|
kind: "prop";
|
|
12174
11582
|
options: readonly AddableProperty[];
|
|
12175
11583
|
};
|
|
12176
|
-
/** 一行上的变体切换控件。 */
|
|
12177
11584
|
interface VariantControl {
|
|
12178
|
-
/** 可以切到哪几支;顺序即声明顺序。 */
|
|
12179
11585
|
choices: readonly VariantChoice[];
|
|
12180
|
-
/** 当前落在第几支。 */
|
|
12181
11586
|
selected: number;
|
|
12182
11587
|
}
|
|
12183
|
-
/** 容器类型:结构行用 `{` 还是 `[`。 */
|
|
12184
11588
|
type ContainerShape = "object" | "array";
|
|
12185
|
-
|
|
12186
|
-
type EditorLine =
|
|
12187
|
-
/** 容器的开启行:`key: {` 或 `[`。 */
|
|
12188
|
-
{
|
|
11589
|
+
type EditorLine = {
|
|
12189
11590
|
kind: "open";
|
|
12190
11591
|
path: readonly string[];
|
|
12191
11592
|
node: FieldNode;
|
|
@@ -12193,82 +11594,43 @@ type EditorLine =
|
|
|
12193
11594
|
depth: number;
|
|
12194
11595
|
collapsed: boolean;
|
|
12195
11596
|
member: WalkedField["member"];
|
|
12196
|
-
/** 这一层是 union 时,可以在哪几支之间切(写哪个值)。 */
|
|
12197
11597
|
variants: VariantControl | undefined;
|
|
12198
|
-
} |
|
|
12199
|
-
/** 容器的关闭行:`}` / `]`(添加行挂在它后面同一行)。 */
|
|
12200
|
-
{
|
|
11598
|
+
} | {
|
|
12201
11599
|
kind: "close";
|
|
12202
11600
|
path: readonly string[];
|
|
12203
11601
|
node: FieldNode;
|
|
12204
11602
|
shape: ContainerShape;
|
|
12205
11603
|
depth: number;
|
|
12206
|
-
/** 这一层能加什么;`undefined` 表示加不了(对象的声明字段都配齐了)。 */
|
|
12207
11604
|
add: AddLineSpec | undefined;
|
|
12208
11605
|
member: WalkedField["member"];
|
|
12209
|
-
} |
|
|
12210
|
-
/** 字段行:`key: value`。 */
|
|
12211
|
-
{
|
|
11606
|
+
} | {
|
|
12212
11607
|
kind: "field";
|
|
12213
11608
|
path: readonly string[];
|
|
12214
11609
|
node: FieldNode;
|
|
12215
11610
|
depth: number;
|
|
12216
11611
|
field: DraftFieldState;
|
|
12217
11612
|
member: WalkedField["member"];
|
|
12218
|
-
/** 这个字段是 union 时,可以在哪几支之间切。 */
|
|
12219
11613
|
variants: VariantControl | undefined;
|
|
12220
|
-
/**
|
|
12221
|
-
* 变体触发**代替这一行的值**:判别式 union 的标签行就是这样——`type: "sqlite" ▾` 里的值就是那个触发,
|
|
12222
|
-
* 不再另画一份值。
|
|
12223
|
-
*/
|
|
12224
11614
|
variantsStandIn: boolean;
|
|
12225
|
-
} |
|
|
12226
|
-
/** 注释行:schema 的说明与业务给的文案,画在字段行上方;这一行有问题时它装的是那条消息。 */
|
|
12227
|
-
{
|
|
11615
|
+
} | {
|
|
12228
11616
|
kind: "comment";
|
|
12229
11617
|
path: readonly string[];
|
|
12230
11618
|
depth: number;
|
|
12231
11619
|
text: string;
|
|
12232
|
-
/** 这一行有校验消息(草稿解析失败或整段校验落下来):画成错误,而不是普通说明。 */
|
|
12233
11620
|
invalid: boolean;
|
|
12234
11621
|
};
|
|
12235
|
-
/**
|
|
12236
|
-
* 容器的形状:对象类用 `{}`,序列类用 `[]`。
|
|
12237
|
-
*
|
|
12238
|
-
* union 没有自己的形状——它跟着**当前选中那一支**走(`access` 是数组就在页面上画 `[`),这也是
|
|
12239
|
-
* `access: string | string[]` 这类字段以前被画成对象容器的原因。
|
|
12240
|
-
* @param node - 字段节点。
|
|
12241
|
-
* @param value - 这一层的值(选支判据)。
|
|
12242
|
-
* @returns 形状;叶子节点是 `undefined`。
|
|
12243
|
-
*/
|
|
12244
11622
|
declare function containerShape(node: FieldNode, value?: unknown): ContainerShape | undefined;
|
|
12245
|
-
/** 折叠状态与可见性:记「用户切换过的路径」,开合 = 切换过就反转 schema 的默认值。 */
|
|
12246
11623
|
interface FoldState {
|
|
12247
11624
|
collapsed(path: readonly string[]): boolean;
|
|
12248
11625
|
toggle(path: readonly string[]): void;
|
|
12249
11626
|
}
|
|
12250
|
-
/** 渲染顺序里可见的字段:折叠的容器把整棵子树滤掉,只留它自己的开启行。 */
|
|
12251
11627
|
declare function visibleFields(state: SchemaFormState, fold: FoldState): readonly WalkedField[];
|
|
12252
|
-
/**
|
|
12253
|
-
* 排成行序列。
|
|
12254
|
-
* @param state - 页面读数。
|
|
12255
|
-
* @param fold - 折叠状态。
|
|
12256
|
-
* @param resolveText - `description` 的本地化。
|
|
12257
|
-
* @param t - 本包字典。
|
|
12258
|
-
* @returns 行序列(行号即下标)。
|
|
12259
|
-
*/
|
|
12260
11628
|
declare function editorLines(state: SchemaFormState, fold: FoldState, resolveText: ResolveText, t: SchemaFormTranslate): EditorLine[];
|
|
12261
11629
|
declare namespace index_d_exports {
|
|
12262
11630
|
export { EditorLine, FieldMeta, FieldNode, FieldText, FoldState, InlineValue, NS, RowRegistrationPlan, SchemaFieldComponentProps, SchemaFieldDefault, SchemaFieldMatch, SchemaFieldOwnerProps, SchemaFieldSelect, SchemaFormActions, SchemaFormController, SchemaFormFace, SchemaFormHints, SchemaFormHintsFace, SchemaFormLocaleKey, SchemaFormProps, SchemaFormState, SelectOption, SelectSpec, SuggestedKeys, SuggestedKeysReader, ValidationFailure, WalkedField, apply$1 as apply, canRender, containerShape, editorLines, failureOf, inject$1 as inject, optionsFor, parseFor, projectNode, projectRoot, rowRegistrations, tokenText, tokenTone, valueText, visibleFields, walkFields };
|
|
12263
11631
|
}
|
|
12264
|
-
/** 本包字典与槽位文案的命名空间。 */
|
|
12265
11632
|
declare const NS = "settings.schema-form";
|
|
12266
|
-
/** 需要的服务:槽位、字典、共享配置表单、schema 服务与插件管理(bundle 行清单)。 */
|
|
12267
11633
|
declare const inject$1: string[];
|
|
12268
|
-
/**
|
|
12269
|
-
* 装上本包:字典、Factory(字段槽的声明者)与按行自动注册。
|
|
12270
|
-
* @param ctx - 浏览器插件上下文。
|
|
12271
|
-
*/
|
|
12272
11634
|
declare function apply$1(ctx: Context): void;
|
|
12273
11635
|
//#endregion
|
|
12274
11636
|
//#region src/reference-markdown.d.ts
|
|
@@ -12283,20 +11645,11 @@ interface ReferenceMarkdownProps {
|
|
|
12283
11645
|
readonly streaming?: boolean | undefined;
|
|
12284
11646
|
readonly pathImages?: MarkdownPathImages | undefined;
|
|
12285
11647
|
}
|
|
12286
|
-
declare function referenceMentions(actions?: ReferenceActions, tokens?: ReadonlyMap<string, Reference>): MarkdownFileMentions;
|
|
12287
|
-
declare const ReferenceMarkdown: import("react").MemoExoticComponent<({ text, labels, actions, streaming, pathImages }: ReferenceMarkdownProps) => import("react/jsx-runtime").JSX.Element>;
|
|
11648
|
+
export declare function referenceMentions(actions?: ReferenceActions, tokens?: ReadonlyMap<string, Reference>): MarkdownFileMentions;
|
|
11649
|
+
export declare const ReferenceMarkdown: import("react").MemoExoticComponent<({ text, labels, actions, streaming, pathImages }: ReferenceMarkdownProps) => import("react/jsx-runtime").JSX.Element>;
|
|
12288
11650
|
//#endregion
|
|
12289
11651
|
//#region src/client/index.d.ts
|
|
12290
|
-
|
|
12291
|
-
|
|
12292
|
-
*
|
|
12293
|
-
* 与包清单里的 `dsh.client.inject` 不是一回事:那份是**装配行 id**(谁先到),交给模块系统排 arrival 顺序;
|
|
12294
|
-
* 这里读的是 cordis 服务名(谁已 provide),Loader 拿它决定这一行何时才算 active。写错成包名,这一行就永远
|
|
12295
|
-
* pending(`web boot: ... waiting for services`)。
|
|
12296
|
-
*
|
|
12297
|
-
* 值直接取自 schema 表单那一面,不另抄一份清单。
|
|
12298
|
-
*/
|
|
12299
|
-
declare const inject: readonly string[];
|
|
12300
|
-
declare function apply(ctx: Context): void;
|
|
11652
|
+
export declare const inject: readonly string[];
|
|
11653
|
+
export declare function apply(ctx: Context): void;
|
|
12301
11654
|
//#endregion
|
|
12302
|
-
export { type CSSObject, type CSSProps, type CSSSelector, type CSSValue, type CSSVar, type CSSVarRef, type FieldMeta, type FieldNode,
|
|
11655
|
+
export { type CSSObject, type CSSProps, type CSSSelector, type CSSValue, type CSSVar, type CSSVarRef, type FieldMeta, type FieldNode, type Reference, type ReferenceActions, type ReferenceMarkdownProps, type ReferenceSpan, NS as SCHEMA_FORM_NS, type SchemaFormActions, type SchemaFormFace, type SchemaFormLocaleKey, type SchemaFormState, type SelectOption, type SelectSpec, type SettingsFieldProps, type SettingsFieldSpec, type SettingsFieldState, type SettingsFieldWrite, type SettingsFormActions, type SettingsFormLabels, type SettingsFormPathOp, type SettingsFormProps, type SettingsFormScope, type SettingsFormScopeSnapshot, type SettingsFormShell, type SettingsSecretSpec, type StyledComponent, type SuggestedKeys, type TokenVars, type Tokens, type ValidationFailure, type WalkedField, findReferences, formatReference, formatReferenceMention, isLocalReference, parseReference, parseReferenceToken, index_d_exports as schemaForm };
|