@morlay/dsh-client-ui-primitives 0.0.4 → 0.0.5

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