@morlay/dsh-client-ui-primitives 0.0.2-alpha.7 → 0.0.2-alpha.9
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 +275 -13
- package/dist/client.cjs +4959 -1057
- package/dist/client.d.cts +1366 -16
- package/dist/client.d.mts +1365 -16
- package/dist/rolldown-runtime-EAsCxrDo.mjs +14 -0
- package/locale/en.json +1 -1
- package/locale/zh.json +1 -1
- package/package.json +28 -11
- package/src/client/index.ts +41 -2
- package/src/client/schema-form/Editor.tsx +777 -0
- package/src/client/schema-form/SchemaForm.tsx +77 -0
- package/src/client/schema-form/controller.ts +457 -0
- package/src/client/schema-form/draft.ts +487 -0
- package/src/client/schema-form/fields.tsx +100 -0
- package/src/client/schema-form/hints.ts +286 -0
- package/src/client/schema-form/index.ts +188 -0
- package/src/client/schema-form/labels.ts +30 -0
- package/src/client/schema-form/lines.ts +334 -0
- package/src/client/schema-form/locales.ts +128 -0
- package/src/client/schema-form/rows.ts +153 -0
- package/src/client/schema-form/schema-node.ts +812 -0
- package/src/client/schema-form/slot-contract.ts +156 -0
- package/src/client/schema-form/styles.ts +310 -0
- package/src/client/schema-form/testing/fake-describe.ts +45 -0
- package/src/client/schema-form/testing/fake-scope.ts +97 -0
- package/src/client/schema-form/value.tsx +146 -0
- package/src/client/settings-form/SettingsForm.styles.ts +58 -0
- package/src/client/settings-form/SettingsForm.tsx +72 -0
- package/src/client/settings-form/fields.styles.ts +158 -0
- package/src/client/settings-form/fields.tsx +194 -0
- package/src/client/settings-form/form-model.ts +421 -0
- package/src/client/settings-form/index.ts +19 -0
- package/src/client/styling/focus.ts +9 -0
- package/src/client/theme.generated.ts +802 -728
- package/cordis.patch.yml +0 -3
package/dist/client.d.cts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { a as formatReferenceMention, c as parseReferenceToken, i as formatReference, n as ReferenceSpan, o as isLocalReference, r as findReferences, s as parseReference, t as Reference } from "./reference-BX54bj6_.cjs";
|
|
2
|
-
import { Context } from "@deepseek-ai/cordis";
|
|
3
|
-
import { ComponentProps, ComponentPropsWithRef, ElementType, ForwardRefExoticComponent, Ref, RefAttributes } from "react";
|
|
4
|
-
import { MarkdownFileMentions, MarkdownLabels, MarkdownLabels as MarkdownLabels$1, MarkdownPathImages } from "@deepseek-ai/dsh-client-ui-primitives";
|
|
2
|
+
import { Context, Service } from "@deepseek-ai/cordis";
|
|
3
|
+
import { ComponentProps, ComponentPropsWithRef, ElementType, ForwardRefExoticComponent, ReactNode, Ref, RefAttributes } from "react";
|
|
4
|
+
import { MarkdownFileMentions, MarkdownLabels, MarkdownLabels as MarkdownLabels$1, MarkdownPathImages, SettingsFormShell as SettingsFormShell$1 } from "@deepseek-ai/dsh-client-ui-primitives";
|
|
5
|
+
import { SnapshotStore } from "@deepseek-ai/dsh-client-store";
|
|
6
|
+
import { PropsRuntime, TranslateNS } from "@deepseek-ai/dsh-client-ui-slots";
|
|
7
|
+
import { BundleInfo, SettingsNamespaceView } from "@deepseek-ai/dsh-api-remotes/client";
|
|
8
|
+
import { ConfigForm, SchemaNode, SettingsDescribeFace } from "@deepseek-ai/dsh-client-ui-settings/client";
|
|
9
|
+
//#endregion
|
|
5
10
|
//#region ../../../node_modules/.pnpm/csstype@3.2.3/node_modules/csstype/index.d.ts
|
|
6
11
|
interface StandardLonghandProperties<TLength = (string & {}) | 0, TTime = string & {}> {
|
|
7
12
|
/**
|
|
@@ -9414,7 +9419,7 @@ declare function styleOf(component: StyledComponent<ElementType>): CSSProps;
|
|
|
9414
9419
|
//#endregion
|
|
9415
9420
|
//#region src/client/theme.generated.d.ts
|
|
9416
9421
|
/**
|
|
9417
|
-
* 官方主题的 `--dsw-*` token 全集(
|
|
9422
|
+
* 官方主题的 `--dsw-*` token 全集(395 个),由 packages/client/ui-primitives/scripts/gen-design-tokens.mts 生成,勿手改。
|
|
9418
9423
|
*
|
|
9419
9424
|
* 叶子是该变量的**默认值**(官方 light 主题里首次出现的定义):既是类型推导的来源,也可作 fallback。
|
|
9420
9425
|
* `"$"` 键出现在「自身也是 token 的分支」上(命名体系里有 40 个短名同时是长名前缀的 token)。
|
|
@@ -9425,7 +9430,7 @@ declare const designTokens: {
|
|
|
9425
9430
|
readonly bg: {
|
|
9426
9431
|
readonly base: "var(--dsw-static-neutral-bluish-00)";
|
|
9427
9432
|
readonly document: {
|
|
9428
|
-
readonly preview: "var(--dsw-static-neutral-bluish-
|
|
9433
|
+
readonly preview: "var(--dsw-static-neutral-bluish-100)";
|
|
9429
9434
|
};
|
|
9430
9435
|
readonly layer: {
|
|
9431
9436
|
readonly "1": "var(--dsw-static-neutral-bluish-00)";
|
|
@@ -9518,6 +9523,20 @@ declare const designTokens: {
|
|
|
9518
9523
|
readonly deleted: "var(--dsw-static-red-600-a08)";
|
|
9519
9524
|
};
|
|
9520
9525
|
};
|
|
9526
|
+
readonly file: {
|
|
9527
|
+
readonly diff: {
|
|
9528
|
+
readonly added: {
|
|
9529
|
+
readonly bg: "rgb(230, 244, 231)";
|
|
9530
|
+
readonly gutter: "rgb(237, 247, 237)";
|
|
9531
|
+
readonly marker: "rgb(1, 162, 65)";
|
|
9532
|
+
};
|
|
9533
|
+
readonly deleted: {
|
|
9534
|
+
readonly bg: "rgb(252, 230, 226)";
|
|
9535
|
+
readonly gutter: "rgb(253, 236, 233)";
|
|
9536
|
+
readonly marker: "rgb(186, 39, 35)";
|
|
9537
|
+
};
|
|
9538
|
+
};
|
|
9539
|
+
};
|
|
9521
9540
|
readonly interactive: {
|
|
9522
9541
|
readonly bg: {
|
|
9523
9542
|
readonly active: "rgba(38, 49, 72, 0.1)";
|
|
@@ -9533,7 +9552,7 @@ declare const designTokens: {
|
|
|
9533
9552
|
readonly caption: "var(--dsw-static-neutral-bluish-400)";
|
|
9534
9553
|
readonly dimmed: "var(--dsw-static-neutral-bluish-200)";
|
|
9535
9554
|
readonly document: {
|
|
9536
|
-
readonly preview: "var(--dsw-static-neutral-bluish-
|
|
9555
|
+
readonly preview: "var(--dsw-static-neutral-bluish-700)";
|
|
9537
9556
|
};
|
|
9538
9557
|
readonly primary: {
|
|
9539
9558
|
readonly $: "var(--dsw-static-neutral-bluish-1000)";
|
|
@@ -9564,6 +9583,21 @@ declare const designTokens: {
|
|
|
9564
9583
|
readonly placeholder: "var(--dsw-static-neutral-bluish-60)";
|
|
9565
9584
|
readonly tag: "var(--dsw-static-neutral-bluish-75)";
|
|
9566
9585
|
};
|
|
9586
|
+
readonly menu: {
|
|
9587
|
+
readonly icon: "var(--dsw-static-neutral-bluish-800)";
|
|
9588
|
+
};
|
|
9589
|
+
readonly onboarding: {
|
|
9590
|
+
readonly accent: "rgb(57, 100, 254)";
|
|
9591
|
+
readonly card: {
|
|
9592
|
+
readonly fill: "color-mix(in srgb, var(--dsw-static-neutral-bluish-00) 80%, transparent)";
|
|
9593
|
+
};
|
|
9594
|
+
readonly checkbox: {
|
|
9595
|
+
readonly border: "color-mix(in srgb, var(--dsw-static-neutral-bluish-1000) 20%, transparent)";
|
|
9596
|
+
};
|
|
9597
|
+
readonly secondary: {
|
|
9598
|
+
readonly fill: "var(--dsw-static-neutral-bluish-00)";
|
|
9599
|
+
};
|
|
9600
|
+
};
|
|
9567
9601
|
readonly scrollbar: {
|
|
9568
9602
|
readonly bg: {
|
|
9569
9603
|
readonly l1: "var(--dsw-static-neutral-200)";
|
|
@@ -9574,6 +9608,12 @@ declare const designTokens: {
|
|
|
9574
9608
|
readonly l2: "var(--dsw-static-neutral-300)";
|
|
9575
9609
|
};
|
|
9576
9610
|
};
|
|
9611
|
+
readonly settings: {
|
|
9612
|
+
readonly card: {
|
|
9613
|
+
readonly fill: "var(--dsw-alias-bg-layer-2)";
|
|
9614
|
+
readonly stroke: "var(--dsw-alias-border-l4)";
|
|
9615
|
+
};
|
|
9616
|
+
};
|
|
9577
9617
|
readonly state: {
|
|
9578
9618
|
readonly business: {
|
|
9579
9619
|
readonly primary: "var(--dsw-static-deepseek-500)";
|
|
@@ -9600,9 +9640,13 @@ declare const designTokens: {
|
|
|
9600
9640
|
};
|
|
9601
9641
|
readonly toast: {
|
|
9602
9642
|
readonly bg: "var(--dsw-static-neutral-bluish-800)";
|
|
9643
|
+
readonly label: "var(--dsw-static-neutral-bluish-00)";
|
|
9603
9644
|
};
|
|
9604
9645
|
readonly tooltip: {
|
|
9605
9646
|
readonly bg: "var(--dsw-static-neutral-bluish-850)";
|
|
9647
|
+
readonly key: {
|
|
9648
|
+
readonly bg: "color-mix(in srgb, var(--dsw-alias-tooltip-bg), white 18%)";
|
|
9649
|
+
};
|
|
9606
9650
|
};
|
|
9607
9651
|
};
|
|
9608
9652
|
readonly corner: {
|
|
@@ -9617,6 +9661,12 @@ declare const designTokens: {
|
|
|
9617
9661
|
readonly color: "var(--dsw-alias-border-l4)";
|
|
9618
9662
|
};
|
|
9619
9663
|
};
|
|
9664
|
+
readonly focus: {
|
|
9665
|
+
readonly ring: {
|
|
9666
|
+
readonly color: "transparent";
|
|
9667
|
+
readonly width: "2px";
|
|
9668
|
+
};
|
|
9669
|
+
};
|
|
9620
9670
|
readonly font: {
|
|
9621
9671
|
readonly base: {
|
|
9622
9672
|
readonly "16": {
|
|
@@ -9646,7 +9696,10 @@ declare const designTokens: {
|
|
|
9646
9696
|
};
|
|
9647
9697
|
};
|
|
9648
9698
|
};
|
|
9649
|
-
readonly family:
|
|
9699
|
+
readonly family: {
|
|
9700
|
+
readonly $: "-apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC',\n 'Hiragino Sans GB', 'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial, sans-serif";
|
|
9701
|
+
readonly brand: "'Montserrat', var(--dsw-font-family)";
|
|
9702
|
+
};
|
|
9650
9703
|
readonly l: {
|
|
9651
9704
|
readonly "20": {
|
|
9652
9705
|
readonly $: "500 20px/28px var(--dsw-font-family)";
|
|
@@ -10008,6 +10061,19 @@ declare const designTokens: {
|
|
|
10008
10061
|
};
|
|
10009
10062
|
};
|
|
10010
10063
|
};
|
|
10064
|
+
readonly gradient: {
|
|
10065
|
+
readonly onboarding: {
|
|
10066
|
+
readonly blue: {
|
|
10067
|
+
readonly stops: "#3964fe 18.75%, #398efe 51.78%, #6dccff 86.252%, #3964fe";
|
|
10068
|
+
};
|
|
10069
|
+
readonly cyan: {
|
|
10070
|
+
readonly stops: "#0293b4 21.154%, #2dc8eb 50.954%, #aff0ff 85.326%, #0293b4";
|
|
10071
|
+
};
|
|
10072
|
+
readonly violet: {
|
|
10073
|
+
readonly stops: "#2a2fb6 33.102%, #8b76f6 50.954%, #c5c0ff 85.326%, #2a2fb6";
|
|
10074
|
+
};
|
|
10075
|
+
};
|
|
10076
|
+
};
|
|
10011
10077
|
readonly linear: {
|
|
10012
10078
|
readonly gradient: {
|
|
10013
10079
|
readonly think: "linear-gradient(180deg, #fff 20.19%, rgba(255, 255, 255, 0) 100%)";
|
|
@@ -10017,12 +10083,23 @@ declare const designTokens: {
|
|
|
10017
10083
|
};
|
|
10018
10084
|
};
|
|
10019
10085
|
readonly mask: {
|
|
10020
|
-
readonly blur: "
|
|
10086
|
+
readonly blur: "none";
|
|
10021
10087
|
};
|
|
10022
10088
|
readonly menu: {
|
|
10023
10089
|
readonly backdrop: {
|
|
10024
10090
|
readonly filter: "blur(40px) saturate(150%)";
|
|
10025
10091
|
};
|
|
10092
|
+
readonly surface: {
|
|
10093
|
+
readonly fill: "rgba(248, 249, 250, 0.58)";
|
|
10094
|
+
};
|
|
10095
|
+
};
|
|
10096
|
+
readonly radius: {
|
|
10097
|
+
readonly lg: "16px";
|
|
10098
|
+
readonly md: "12px";
|
|
10099
|
+
readonly panel: "28px";
|
|
10100
|
+
readonly sm: "8px";
|
|
10101
|
+
readonly xl: "20px";
|
|
10102
|
+
readonly xs: "4px";
|
|
10026
10103
|
};
|
|
10027
10104
|
readonly shadow: {
|
|
10028
10105
|
readonly lv1: {
|
|
@@ -10043,7 +10120,7 @@ declare const designTokens: {
|
|
|
10043
10120
|
readonly login: {
|
|
10044
10121
|
readonly input: "var(--dsw-static-neutral-bluish-50)";
|
|
10045
10122
|
};
|
|
10046
|
-
readonly menu: "
|
|
10123
|
+
readonly menu: "var(--dsw-menu-surface-fill)";
|
|
10047
10124
|
readonly selector: "var(--dsw-static-neutral-bluish-60)";
|
|
10048
10125
|
readonly sidebar: {
|
|
10049
10126
|
readonly fill: "var(--dsw-static-neutral-bluish-50)";
|
|
@@ -10168,7 +10245,7 @@ declare const dsw: TokenVars<{
|
|
|
10168
10245
|
readonly bg: {
|
|
10169
10246
|
readonly base: "var(--dsw-static-neutral-bluish-00)";
|
|
10170
10247
|
readonly document: {
|
|
10171
|
-
readonly preview: "var(--dsw-static-neutral-bluish-
|
|
10248
|
+
readonly preview: "var(--dsw-static-neutral-bluish-100)";
|
|
10172
10249
|
};
|
|
10173
10250
|
readonly layer: {
|
|
10174
10251
|
readonly "1": "var(--dsw-static-neutral-bluish-00)";
|
|
@@ -10261,6 +10338,20 @@ declare const dsw: TokenVars<{
|
|
|
10261
10338
|
readonly deleted: "var(--dsw-static-red-600-a08)";
|
|
10262
10339
|
};
|
|
10263
10340
|
};
|
|
10341
|
+
readonly file: {
|
|
10342
|
+
readonly diff: {
|
|
10343
|
+
readonly added: {
|
|
10344
|
+
readonly bg: "rgb(230, 244, 231)";
|
|
10345
|
+
readonly gutter: "rgb(237, 247, 237)";
|
|
10346
|
+
readonly marker: "rgb(1, 162, 65)";
|
|
10347
|
+
};
|
|
10348
|
+
readonly deleted: {
|
|
10349
|
+
readonly bg: "rgb(252, 230, 226)";
|
|
10350
|
+
readonly gutter: "rgb(253, 236, 233)";
|
|
10351
|
+
readonly marker: "rgb(186, 39, 35)";
|
|
10352
|
+
};
|
|
10353
|
+
};
|
|
10354
|
+
};
|
|
10264
10355
|
readonly interactive: {
|
|
10265
10356
|
readonly bg: {
|
|
10266
10357
|
readonly active: "rgba(38, 49, 72, 0.1)";
|
|
@@ -10276,7 +10367,7 @@ declare const dsw: TokenVars<{
|
|
|
10276
10367
|
readonly caption: "var(--dsw-static-neutral-bluish-400)";
|
|
10277
10368
|
readonly dimmed: "var(--dsw-static-neutral-bluish-200)";
|
|
10278
10369
|
readonly document: {
|
|
10279
|
-
readonly preview: "var(--dsw-static-neutral-bluish-
|
|
10370
|
+
readonly preview: "var(--dsw-static-neutral-bluish-700)";
|
|
10280
10371
|
};
|
|
10281
10372
|
readonly primary: {
|
|
10282
10373
|
readonly $: "var(--dsw-static-neutral-bluish-1000)";
|
|
@@ -10307,6 +10398,21 @@ declare const dsw: TokenVars<{
|
|
|
10307
10398
|
readonly placeholder: "var(--dsw-static-neutral-bluish-60)";
|
|
10308
10399
|
readonly tag: "var(--dsw-static-neutral-bluish-75)";
|
|
10309
10400
|
};
|
|
10401
|
+
readonly menu: {
|
|
10402
|
+
readonly icon: "var(--dsw-static-neutral-bluish-800)";
|
|
10403
|
+
};
|
|
10404
|
+
readonly onboarding: {
|
|
10405
|
+
readonly accent: "rgb(57, 100, 254)";
|
|
10406
|
+
readonly card: {
|
|
10407
|
+
readonly fill: "color-mix(in srgb, var(--dsw-static-neutral-bluish-00) 80%, transparent)";
|
|
10408
|
+
};
|
|
10409
|
+
readonly checkbox: {
|
|
10410
|
+
readonly border: "color-mix(in srgb, var(--dsw-static-neutral-bluish-1000) 20%, transparent)";
|
|
10411
|
+
};
|
|
10412
|
+
readonly secondary: {
|
|
10413
|
+
readonly fill: "var(--dsw-static-neutral-bluish-00)";
|
|
10414
|
+
};
|
|
10415
|
+
};
|
|
10310
10416
|
readonly scrollbar: {
|
|
10311
10417
|
readonly bg: {
|
|
10312
10418
|
readonly l1: "var(--dsw-static-neutral-200)";
|
|
@@ -10317,6 +10423,12 @@ declare const dsw: TokenVars<{
|
|
|
10317
10423
|
readonly l2: "var(--dsw-static-neutral-300)";
|
|
10318
10424
|
};
|
|
10319
10425
|
};
|
|
10426
|
+
readonly settings: {
|
|
10427
|
+
readonly card: {
|
|
10428
|
+
readonly fill: "var(--dsw-alias-bg-layer-2)";
|
|
10429
|
+
readonly stroke: "var(--dsw-alias-border-l4)";
|
|
10430
|
+
};
|
|
10431
|
+
};
|
|
10320
10432
|
readonly state: {
|
|
10321
10433
|
readonly business: {
|
|
10322
10434
|
readonly primary: "var(--dsw-static-deepseek-500)";
|
|
@@ -10343,9 +10455,13 @@ declare const dsw: TokenVars<{
|
|
|
10343
10455
|
};
|
|
10344
10456
|
readonly toast: {
|
|
10345
10457
|
readonly bg: "var(--dsw-static-neutral-bluish-800)";
|
|
10458
|
+
readonly label: "var(--dsw-static-neutral-bluish-00)";
|
|
10346
10459
|
};
|
|
10347
10460
|
readonly tooltip: {
|
|
10348
10461
|
readonly bg: "var(--dsw-static-neutral-bluish-850)";
|
|
10462
|
+
readonly key: {
|
|
10463
|
+
readonly bg: "color-mix(in srgb, var(--dsw-alias-tooltip-bg), white 18%)";
|
|
10464
|
+
};
|
|
10349
10465
|
};
|
|
10350
10466
|
};
|
|
10351
10467
|
readonly corner: {
|
|
@@ -10360,6 +10476,12 @@ declare const dsw: TokenVars<{
|
|
|
10360
10476
|
readonly color: "var(--dsw-alias-border-l4)";
|
|
10361
10477
|
};
|
|
10362
10478
|
};
|
|
10479
|
+
readonly focus: {
|
|
10480
|
+
readonly ring: {
|
|
10481
|
+
readonly color: "transparent";
|
|
10482
|
+
readonly width: "2px";
|
|
10483
|
+
};
|
|
10484
|
+
};
|
|
10363
10485
|
readonly font: {
|
|
10364
10486
|
readonly base: {
|
|
10365
10487
|
readonly "16": {
|
|
@@ -10389,7 +10511,10 @@ declare const dsw: TokenVars<{
|
|
|
10389
10511
|
};
|
|
10390
10512
|
};
|
|
10391
10513
|
};
|
|
10392
|
-
readonly family:
|
|
10514
|
+
readonly family: {
|
|
10515
|
+
readonly $: "-apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC',\n 'Hiragino Sans GB', 'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial, sans-serif";
|
|
10516
|
+
readonly brand: "'Montserrat', var(--dsw-font-family)";
|
|
10517
|
+
};
|
|
10393
10518
|
readonly l: {
|
|
10394
10519
|
readonly "20": {
|
|
10395
10520
|
readonly $: "500 20px/28px var(--dsw-font-family)";
|
|
@@ -10751,6 +10876,19 @@ declare const dsw: TokenVars<{
|
|
|
10751
10876
|
};
|
|
10752
10877
|
};
|
|
10753
10878
|
};
|
|
10879
|
+
readonly gradient: {
|
|
10880
|
+
readonly onboarding: {
|
|
10881
|
+
readonly blue: {
|
|
10882
|
+
readonly stops: "#3964fe 18.75%, #398efe 51.78%, #6dccff 86.252%, #3964fe";
|
|
10883
|
+
};
|
|
10884
|
+
readonly cyan: {
|
|
10885
|
+
readonly stops: "#0293b4 21.154%, #2dc8eb 50.954%, #aff0ff 85.326%, #0293b4";
|
|
10886
|
+
};
|
|
10887
|
+
readonly violet: {
|
|
10888
|
+
readonly stops: "#2a2fb6 33.102%, #8b76f6 50.954%, #c5c0ff 85.326%, #2a2fb6";
|
|
10889
|
+
};
|
|
10890
|
+
};
|
|
10891
|
+
};
|
|
10754
10892
|
readonly linear: {
|
|
10755
10893
|
readonly gradient: {
|
|
10756
10894
|
readonly think: "linear-gradient(180deg, #fff 20.19%, rgba(255, 255, 255, 0) 100%)";
|
|
@@ -10760,12 +10898,23 @@ declare const dsw: TokenVars<{
|
|
|
10760
10898
|
};
|
|
10761
10899
|
};
|
|
10762
10900
|
readonly mask: {
|
|
10763
|
-
readonly blur: "
|
|
10901
|
+
readonly blur: "none";
|
|
10764
10902
|
};
|
|
10765
10903
|
readonly menu: {
|
|
10766
10904
|
readonly backdrop: {
|
|
10767
10905
|
readonly filter: "blur(40px) saturate(150%)";
|
|
10768
10906
|
};
|
|
10907
|
+
readonly surface: {
|
|
10908
|
+
readonly fill: "rgba(248, 249, 250, 0.58)";
|
|
10909
|
+
};
|
|
10910
|
+
};
|
|
10911
|
+
readonly radius: {
|
|
10912
|
+
readonly lg: "16px";
|
|
10913
|
+
readonly md: "12px";
|
|
10914
|
+
readonly panel: "28px";
|
|
10915
|
+
readonly sm: "8px";
|
|
10916
|
+
readonly xl: "20px";
|
|
10917
|
+
readonly xs: "4px";
|
|
10769
10918
|
};
|
|
10770
10919
|
readonly shadow: {
|
|
10771
10920
|
readonly lv1: {
|
|
@@ -10786,7 +10935,7 @@ declare const dsw: TokenVars<{
|
|
|
10786
10935
|
readonly login: {
|
|
10787
10936
|
readonly input: "var(--dsw-static-neutral-bluish-50)";
|
|
10788
10937
|
};
|
|
10789
|
-
readonly menu: "
|
|
10938
|
+
readonly menu: "var(--dsw-menu-surface-fill)";
|
|
10790
10939
|
readonly selector: "var(--dsw-static-neutral-bluish-60)";
|
|
10791
10940
|
readonly sidebar: {
|
|
10792
10941
|
readonly fill: "var(--dsw-static-neutral-bluish-50)";
|
|
@@ -10909,6 +11058,1198 @@ declare const dsw: TokenVars<{
|
|
|
10909
11058
|
type MarkdownCopySeat = (key: "copy" | "copied" | "markdown.footnotes") => string;
|
|
10910
11059
|
declare function markdownLabels(t: MarkdownCopySeat): MarkdownLabels;
|
|
10911
11060
|
//#endregion
|
|
11061
|
+
//#region src/client/settings-form/form-model.d.ts
|
|
11062
|
+
/** What the model reads of one Host entry's form. */
|
|
11063
|
+
interface SettingsFormScopeSnapshot<T> {
|
|
11064
|
+
/** `ready` while the Host serves the entry to this client; the form renders nothing otherwise. */
|
|
11065
|
+
status: "loading" | "ready" | "unavailable";
|
|
11066
|
+
/** Last accepted schema-resolved section; undefined before the first acceptance. */
|
|
11067
|
+
value: T | undefined;
|
|
11068
|
+
/** Composition layer the value resolves over: what a field reverts to once cleared. */
|
|
11069
|
+
base: unknown;
|
|
11070
|
+
/** Raw user layer as stored; a field's PRESENCE here is what marks it overridden. */
|
|
11071
|
+
user: unknown;
|
|
11072
|
+
/** Whether the Host document accepts writes. */
|
|
11073
|
+
writable: boolean;
|
|
11074
|
+
/** Revision the snapshot was read at; a save fences its mutation with the revision its drafts started from. */
|
|
11075
|
+
revision: number | undefined;
|
|
11076
|
+
}
|
|
11077
|
+
/** One path edit a save sends, as the shared configuration form's `mutate` accepts it. */
|
|
11078
|
+
type SettingsFormPathOp = {
|
|
11079
|
+
op: "set";
|
|
11080
|
+
path: readonly string[];
|
|
11081
|
+
value: unknown;
|
|
11082
|
+
} | {
|
|
11083
|
+
op: "unset";
|
|
11084
|
+
path: readonly string[];
|
|
11085
|
+
};
|
|
11086
|
+
/** The entry form the model stages over: the reads and the atomic write of the form `ui-settings` shares per Host entry. */
|
|
11087
|
+
interface SettingsFormScope<T> {
|
|
11088
|
+
/** @returns the current sync snapshot. */
|
|
11089
|
+
getSnapshot(): SettingsFormScopeSnapshot<T>;
|
|
11090
|
+
/**
|
|
11091
|
+
* Observe snapshot replacements.
|
|
11092
|
+
* @param listener - invoked after each snapshot change.
|
|
11093
|
+
* @returns the disposer removing this listener.
|
|
11094
|
+
*/
|
|
11095
|
+
subscribe(listener: () => void): () => void;
|
|
11096
|
+
/**
|
|
11097
|
+
* Apply ordered field edits in one revision-fenced write.
|
|
11098
|
+
* @param ops - the edits, in staging order.
|
|
11099
|
+
* @param expectedRevision - the revision the drafts were staged against, when known.
|
|
11100
|
+
* @returns true for Host acceptance, false for refusal, after any recovery read.
|
|
11101
|
+
*/
|
|
11102
|
+
mutate(ops: readonly SettingsFormPathOp[], expectedRevision?: number): Promise<boolean>;
|
|
11103
|
+
}
|
|
11104
|
+
/** The write one field's staged text performs when the card is saved. */
|
|
11105
|
+
type SettingsFieldWrite = {
|
|
11106
|
+
kind: "set";
|
|
11107
|
+
value: unknown;
|
|
11108
|
+
} | {
|
|
11109
|
+
kind: "clear";
|
|
11110
|
+
};
|
|
11111
|
+
/** How one section field converts between its stored value and its draft text. */
|
|
11112
|
+
interface SettingsFieldSpec {
|
|
11113
|
+
/** Field name inside the namespace section. */
|
|
11114
|
+
field: string;
|
|
11115
|
+
/** Render a stored value as draft text; the empty string when the section carries none. */
|
|
11116
|
+
format: (value: unknown) => string;
|
|
11117
|
+
/**
|
|
11118
|
+
* The write this draft text stages, or undefined when the text is not a
|
|
11119
|
+
* value this field accepts — which blocks the save rather than discarding it.
|
|
11120
|
+
*/
|
|
11121
|
+
parse: (text: string) => SettingsFieldWrite | undefined;
|
|
11122
|
+
}
|
|
11123
|
+
/**
|
|
11124
|
+
* A control whose value is written outside the settings section. A credential
|
|
11125
|
+
* literal never rides a response, so its draft has nothing to seed from: it is
|
|
11126
|
+
* blank until typed, and a blank draft writes nothing.
|
|
11127
|
+
*/
|
|
11128
|
+
interface SettingsSecretSpec {
|
|
11129
|
+
/** Field name addressing this control inside the card's form. */
|
|
11130
|
+
field: string;
|
|
11131
|
+
/** Write the staged text; resolves to whether the Host accepted it. */
|
|
11132
|
+
write: (text: string) => Promise<boolean>;
|
|
11133
|
+
}
|
|
11134
|
+
/** One field as a card's control renders it. */
|
|
11135
|
+
interface SettingsFieldState {
|
|
11136
|
+
/** Draft text the control renders. */
|
|
11137
|
+
text: string;
|
|
11138
|
+
/**
|
|
11139
|
+
* Whether saving would leave a user-layer entry for this field. A staged
|
|
11140
|
+
* edit answers for itself, so the badge previews the save rather than
|
|
11141
|
+
* reporting a state the pending edit already contradicts.
|
|
11142
|
+
*/
|
|
11143
|
+
overridden: boolean;
|
|
11144
|
+
/** Whether the draft is not a value this field accepts, which blocks saving. */
|
|
11145
|
+
invalid: boolean;
|
|
11146
|
+
}
|
|
11147
|
+
/** Form state every plugin card shares. */
|
|
11148
|
+
interface SettingsFormShell {
|
|
11149
|
+
/** False while the namespace is not served to this client; the card renders nothing. */
|
|
11150
|
+
available: boolean;
|
|
11151
|
+
/** Whether the Host document accepts writes. */
|
|
11152
|
+
writable: boolean;
|
|
11153
|
+
/** Whether the form holds edits that a save would write. */
|
|
11154
|
+
dirty: boolean;
|
|
11155
|
+
/** Whether any staged draft is invalid, which blocks the save. */
|
|
11156
|
+
invalid: boolean;
|
|
11157
|
+
/** Whether a save is crossing the wire. */
|
|
11158
|
+
saving: boolean;
|
|
11159
|
+
/** Whether the last save did not land as staged; cleared by the next edit or save. */
|
|
11160
|
+
failed: boolean;
|
|
11161
|
+
}
|
|
11162
|
+
/** The write actions every plugin card's slot entry injects. */
|
|
11163
|
+
interface SettingsFormActions {
|
|
11164
|
+
/** Stage draft text for one field. */
|
|
11165
|
+
edit: (field: string, text: string) => void;
|
|
11166
|
+
/** Stage a clear, so saving lets the field re-inherit the composition layer. */
|
|
11167
|
+
resetField: (field: string) => void;
|
|
11168
|
+
/** Write every staged edit, then re-seed from what the Host accepted. */
|
|
11169
|
+
save: () => void;
|
|
11170
|
+
/** Drop every staged edit. */
|
|
11171
|
+
discard: () => void;
|
|
11172
|
+
}
|
|
11173
|
+
/**
|
|
11174
|
+
* A whole-number field. An empty draft clears the field; any other draft that
|
|
11175
|
+
* is not a finite number blocks the save.
|
|
11176
|
+
* @param field - field name inside the namespace section.
|
|
11177
|
+
* @returns the field's conversion spec.
|
|
11178
|
+
*/
|
|
11179
|
+
declare function settingsNumberField(field: string): SettingsFieldSpec;
|
|
11180
|
+
/**
|
|
11181
|
+
* A free-text field. An empty draft clears the field, so emptying the control
|
|
11182
|
+
* and saving is the same gesture as resetting it.
|
|
11183
|
+
* @param field - field name inside the namespace section.
|
|
11184
|
+
* @returns the field's conversion spec.
|
|
11185
|
+
*/
|
|
11186
|
+
declare function settingsTextField(field: string): SettingsFieldSpec;
|
|
11187
|
+
/**
|
|
11188
|
+
* Stages one card's edits over one settings namespace and writes them on save.
|
|
11189
|
+
*
|
|
11190
|
+
* The form publishes through a snapshot store because slot components read
|
|
11191
|
+
* through a snapshot selector, while both the scope and the local drafts
|
|
11192
|
+
* change underneath; every projection is rebuilt from the two together.
|
|
11193
|
+
*/
|
|
11194
|
+
declare class SettingsFormModel<T> {
|
|
11195
|
+
private readonly scope;
|
|
11196
|
+
private readonly specs;
|
|
11197
|
+
private readonly secretSpecs;
|
|
11198
|
+
private readonly staged;
|
|
11199
|
+
private readonly listeners;
|
|
11200
|
+
private baseline;
|
|
11201
|
+
private readonly unsubscribe;
|
|
11202
|
+
private saving;
|
|
11203
|
+
private failed;
|
|
11204
|
+
/**
|
|
11205
|
+
* @param scope - the shared configuration form for this card's namespace.
|
|
11206
|
+
* @param specs - the section fields this card edits.
|
|
11207
|
+
* @param secrets - the card's write-only controls, written outside the section.
|
|
11208
|
+
*/
|
|
11209
|
+
constructor(scope: SettingsFormScope<T>, specs: SettingsFieldSpec[], secrets?: SettingsSecretSpec[]);
|
|
11210
|
+
/**
|
|
11211
|
+
* Publish a projection of this form, rebuilt whenever the scope or a draft changes.
|
|
11212
|
+
* @param project - build the card's state from the form's current reads.
|
|
11213
|
+
* @returns the store the card's component reads through its bound selector.
|
|
11214
|
+
*/
|
|
11215
|
+
bind<S>(project: () => S): SnapshotStore<S>;
|
|
11216
|
+
/**
|
|
11217
|
+
* Read the card-level state: what the Host serves, and what a save would do.
|
|
11218
|
+
* @returns the form state every card shares.
|
|
11219
|
+
*/
|
|
11220
|
+
shell(): SettingsFormShell;
|
|
11221
|
+
/**
|
|
11222
|
+
* Read one control's state.
|
|
11223
|
+
* @param field - field name of a section field or of a write-only control.
|
|
11224
|
+
* @returns the draft text, whether a save would leave an override, and whether it is invalid.
|
|
11225
|
+
*/
|
|
11226
|
+
field(field: string): SettingsFieldState;
|
|
11227
|
+
/**
|
|
11228
|
+
* Build the edit, reset, save, and discard actions bound to this form.
|
|
11229
|
+
* @returns the actions a card's slot entry injects.
|
|
11230
|
+
*/
|
|
11231
|
+
actions(): SettingsFormActions;
|
|
11232
|
+
/**
|
|
11233
|
+
* Write every staged edit, then re-seed from what the Host accepted.
|
|
11234
|
+
*
|
|
11235
|
+
* The Host is the only authority on whether a value was accepted — its
|
|
11236
|
+
* validators own the constraints no schema can express — so the outcome is
|
|
11237
|
+
* read back from the section rather than predicted here. A save that did not
|
|
11238
|
+
* land keeps its drafts, so the user can correct them instead of retyping.
|
|
11239
|
+
* @returns settlement after every write and the read-back.
|
|
11240
|
+
*/
|
|
11241
|
+
save(): Promise<void>;
|
|
11242
|
+
/** Release the form's accepted-value subscription. */
|
|
11243
|
+
dispose(): void;
|
|
11244
|
+
/**
|
|
11245
|
+
* Every staged edit a save would write. An entry whose draft is not a value
|
|
11246
|
+
* its field accepts carries no write: the form is still dirty, and the save
|
|
11247
|
+
* refuses rather than dropping the edit.
|
|
11248
|
+
* @returns the planned writes, in the order the fields were staged.
|
|
11249
|
+
*/
|
|
11250
|
+
private plan;
|
|
11251
|
+
private stage;
|
|
11252
|
+
private spec;
|
|
11253
|
+
private snapshotOf;
|
|
11254
|
+
private sectionValue;
|
|
11255
|
+
private baseValue;
|
|
11256
|
+
private userLayer;
|
|
11257
|
+
private stored;
|
|
11258
|
+
private publish;
|
|
11259
|
+
}
|
|
11260
|
+
//#endregion
|
|
11261
|
+
//#region src/client/settings-form/fields.d.ts
|
|
11262
|
+
/** What every settings field control needs regardless of its value type. */
|
|
11263
|
+
interface SettingsFieldProps {
|
|
11264
|
+
/** Stable id associating the label with its control. */
|
|
11265
|
+
id: string;
|
|
11266
|
+
/** Visible label. */
|
|
11267
|
+
label: string;
|
|
11268
|
+
/** One-line explanation rendered under the control. */
|
|
11269
|
+
hint: string;
|
|
11270
|
+
/** Draft text this control renders. */
|
|
11271
|
+
text: string;
|
|
11272
|
+
/** True when saving would leave a user-layer entry for this field. */
|
|
11273
|
+
overridden: boolean;
|
|
11274
|
+
/** True when the draft is not a value this field accepts. */
|
|
11275
|
+
invalid: boolean;
|
|
11276
|
+
/** Copy for the overridden badge. */
|
|
11277
|
+
overriddenLabel: string;
|
|
11278
|
+
/** Copy for the reset control. */
|
|
11279
|
+
resetLabel: string;
|
|
11280
|
+
/** Copy shown in place of the hint while the draft is invalid. */
|
|
11281
|
+
invalidLabel: string;
|
|
11282
|
+
/** Disables every control (read-only document, or an unavailable namespace). */
|
|
11283
|
+
disabled: boolean;
|
|
11284
|
+
/** Stage draft text. */
|
|
11285
|
+
onEdit: (text: string) => void;
|
|
11286
|
+
/** Stage a clear so the field re-inherits the composition layer. */
|
|
11287
|
+
onReset: () => void;
|
|
11288
|
+
}
|
|
11289
|
+
/**
|
|
11290
|
+
* A staged value field. `numeric` only hints the keypad: which drafts a field
|
|
11291
|
+
* accepts is decided by its spec, so the control never silently rewrites what
|
|
11292
|
+
* the user typed.
|
|
11293
|
+
* @param props - the field's copy, its staged text, and the edit actions.
|
|
11294
|
+
* @returns the labelled control.
|
|
11295
|
+
*/
|
|
11296
|
+
declare function SettingsValueField(props: Omit<SettingsFieldProps, "hint"> & {
|
|
11297
|
+
/** Optional explanation shown below the input. */
|
|
11298
|
+
hint?: string;
|
|
11299
|
+
/** Rules disclosed by the information button beside the label. */
|
|
11300
|
+
help?: {
|
|
11301
|
+
label: string;
|
|
11302
|
+
content: ReactNode;
|
|
11303
|
+
};
|
|
11304
|
+
/** Hints a numeric keypad without narrowing what the control accepts. */
|
|
11305
|
+
numeric?: boolean;
|
|
11306
|
+
/** Placeholder shown while the draft is empty. */
|
|
11307
|
+
placeholder?: string;
|
|
11308
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
11309
|
+
/**
|
|
11310
|
+
* A write-only credential control. The value never rides a response, so the
|
|
11311
|
+
* control reports only whether one is configured and starts blank; a blank
|
|
11312
|
+
* draft writes nothing, which keeps the stored key rather than clearing it.
|
|
11313
|
+
* 控件要求浏览器不要把已存的登录密码自动填进来(上游 11c0511271)。
|
|
11314
|
+
* @param props - the field's copy, its staged text, and the configured state.
|
|
11315
|
+
* @returns the labelled control.
|
|
11316
|
+
*/
|
|
11317
|
+
declare function SettingsSecretField(props: Pick<SettingsFieldProps, "id" | "label" | "hint" | "text" | "disabled" | "onEdit"> & {
|
|
11318
|
+
/** Whether the Host reports a configured credential for this reference. */
|
|
11319
|
+
configured: boolean;
|
|
11320
|
+
/** Copy describing the configured state. */
|
|
11321
|
+
stateLabel: string;
|
|
11322
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
11323
|
+
//#endregion
|
|
11324
|
+
//#region src/client/settings-form/SettingsForm.d.ts
|
|
11325
|
+
/** The copy the form frame renders, from the owning plugin's dictionary. */
|
|
11326
|
+
interface SettingsFormLabels {
|
|
11327
|
+
/** Shown in place of the controls while the namespace is not served. */
|
|
11328
|
+
unavailable: string;
|
|
11329
|
+
/** Shown over the controls while the document is read-only. */
|
|
11330
|
+
readOnly: string;
|
|
11331
|
+
/** Shown beside the save after a save the Host did not accept. */
|
|
11332
|
+
saveFailed: string;
|
|
11333
|
+
/** The save control. */
|
|
11334
|
+
save: string;
|
|
11335
|
+
/** The save control while a save is crossing the wire. */
|
|
11336
|
+
saving: string;
|
|
11337
|
+
}
|
|
11338
|
+
/** Form chrome shared by every settings page. */
|
|
11339
|
+
interface SettingsFormProps {
|
|
11340
|
+
/** The frame's copy. */
|
|
11341
|
+
labels: SettingsFormLabels;
|
|
11342
|
+
/** The form state: availability, writability, and what a save would do. */
|
|
11343
|
+
state: SettingsFormShell;
|
|
11344
|
+
/** Write every staged edit. */
|
|
11345
|
+
onSave: () => void;
|
|
11346
|
+
/** Drop every staged edit; the form calls it when it leaves the page. */
|
|
11347
|
+
onDiscard: () => void;
|
|
11348
|
+
/** The plugin's controls. */
|
|
11349
|
+
children: ReactNode;
|
|
11350
|
+
}
|
|
11351
|
+
/**
|
|
11352
|
+
* Render one plugin's settings form.
|
|
11353
|
+
* @param props - the form's copy and state, its controls, and the save and discard actions.
|
|
11354
|
+
* @returns the form, or the unavailable line while the namespace is not served.
|
|
11355
|
+
*/
|
|
11356
|
+
declare function SettingsForm(props: SettingsFormProps): import("react/jsx-runtime").JSX.Element;
|
|
11357
|
+
//#endregion
|
|
11358
|
+
//#region src/client/schema-form/schema-node.d.ts
|
|
11359
|
+
/** 节点不可编辑的原因;`null` 表示可编辑。 */
|
|
11360
|
+
type ReadOnlyReason = "transform" | "function" | "constructor";
|
|
11361
|
+
/** 归一化后的字段元数据(schemastery `meta` 的可用子集)。 */
|
|
11362
|
+
interface FieldMeta {
|
|
11363
|
+
/** `description`(可能是本地化字典):渲染时经 locale 解析。 */
|
|
11364
|
+
description: string | Readonly<Record<string, string>> | undefined;
|
|
11365
|
+
/** `comment`:纯文本补充说明。 */
|
|
11366
|
+
comment: string | undefined;
|
|
11367
|
+
/** `link`:外部文档。 */
|
|
11368
|
+
link: string | undefined;
|
|
11369
|
+
/** `role`:控件提示(`secret` / `slider` / `datetime` …)。 */
|
|
11370
|
+
role: string | undefined;
|
|
11371
|
+
/** `role === 'secret'`:值不回传,只能写。 */
|
|
11372
|
+
secret: boolean;
|
|
11373
|
+
/** `required()`。 */
|
|
11374
|
+
required: boolean;
|
|
11375
|
+
/** `disabled()`:控件禁用。 */
|
|
11376
|
+
disabled: boolean;
|
|
11377
|
+
/** `collapse()`:嵌套分组默认折叠。 */
|
|
11378
|
+
collapse: boolean;
|
|
11379
|
+
/** `deprecated()` / `experimental()` 的徽标文本。 */
|
|
11380
|
+
badges: readonly string[];
|
|
11381
|
+
/** `pattern()` 的正则来源。 */
|
|
11382
|
+
pattern: string | undefined;
|
|
11383
|
+
/** `min()`。 */
|
|
11384
|
+
min: number | undefined;
|
|
11385
|
+
/** `max()`。 */
|
|
11386
|
+
max: number | undefined;
|
|
11387
|
+
/** `step()`:`1` 表示整数。 */
|
|
11388
|
+
step: number | undefined;
|
|
11389
|
+
/** 是否声明了默认值(与「默认值是 undefined」区分开)。 */
|
|
11390
|
+
hasDefault: boolean;
|
|
11391
|
+
/** 声明的默认值。 */
|
|
11392
|
+
defaultValue: unknown;
|
|
11393
|
+
/** `extra()`:角色附带的任意数据,字段槽的自定义控件可用。 */
|
|
11394
|
+
extra: unknown;
|
|
11395
|
+
}
|
|
11396
|
+
/** 每种节点共有的部分。 */
|
|
11397
|
+
interface FieldNodeBase {
|
|
11398
|
+
/** 这一层的名字:对象字段名、tuple 的索引、动态子节点的占位段。 */
|
|
11399
|
+
key: string;
|
|
11400
|
+
/** 从段根起的路径;动态段是 {@link DYNAMIC_SEGMENT}。 */
|
|
11401
|
+
path: readonly string[];
|
|
11402
|
+
/**
|
|
11403
|
+
* 按值展开时算好的显示名:数组成员的**项身份**(见 {@link FieldNodeBase} 所在的 array 节点)。
|
|
11404
|
+
* 投影时没有(`undefined`),渲染层用它优先于字段名。
|
|
11405
|
+
*/
|
|
11406
|
+
label: string | undefined;
|
|
11407
|
+
/** 归一化后的元数据。 */
|
|
11408
|
+
meta: FieldMeta;
|
|
11409
|
+
/** 不可编辑的原因;`null` 表示可编辑。 */
|
|
11410
|
+
readOnly: ReadOnlyReason | null;
|
|
11411
|
+
}
|
|
11412
|
+
/** 位集的一位。 */
|
|
11413
|
+
interface BitsEntry {
|
|
11414
|
+
name: string;
|
|
11415
|
+
bit: number;
|
|
11416
|
+
}
|
|
11417
|
+
/** 渲染层要的一个字段节点。 */
|
|
11418
|
+
type FieldNode = (FieldNodeBase & {
|
|
11419
|
+
type: "object";
|
|
11420
|
+
fields: readonly FieldNode[];
|
|
11421
|
+
}) | (FieldNodeBase & {
|
|
11422
|
+
type: "dict";
|
|
11423
|
+
keyNode: FieldNode;
|
|
11424
|
+
valueNode: FieldNode;
|
|
11425
|
+
}) | (FieldNodeBase & {
|
|
11426
|
+
type: "array";
|
|
11427
|
+
item: FieldNode;
|
|
11428
|
+
/**
|
|
11429
|
+
* 项的**身份键**:这一项的「名字」取自它自己的哪个字段。显式声明优先
|
|
11430
|
+
* (`z.array(inner).role('items', { mergeKey: 'id' })`),否则 item 上有 `id` 字段就用 `id`。
|
|
11431
|
+
* 它只决定显示名与「同名即冲突」的判据——写盘仍按索引(host 的 path op 就是索引语义)。
|
|
11432
|
+
*/
|
|
11433
|
+
mergeKey: string | undefined;
|
|
11434
|
+
}) | (FieldNodeBase & {
|
|
11435
|
+
type: "tuple";
|
|
11436
|
+
items: readonly FieldNode[];
|
|
11437
|
+
}) | (FieldNodeBase & {
|
|
11438
|
+
type: "union";
|
|
11439
|
+
/** 成员全是字面量时的可选项;否则 `undefined`。 */
|
|
11440
|
+
choices: readonly unknown[] | undefined;
|
|
11441
|
+
variants: readonly FieldNode[];
|
|
11442
|
+
/**
|
|
11443
|
+
* 判别标签:按哪个字段的值挑变体。显式声明优先
|
|
11444
|
+
* (`z.union([...]).role('union', { tag: 'kind' })`),否则取所有对象成员共有的**唯一**常量字段。
|
|
11445
|
+
* schemastery 本身没有 tag 机制(union 按声明顺序逐个试),所以这只是渲染与校验的选支依据。
|
|
11446
|
+
*/
|
|
11447
|
+
tagKey: string | undefined;
|
|
11448
|
+
}) | (FieldNodeBase & {
|
|
11449
|
+
type: "intersect";
|
|
11450
|
+
members: readonly FieldNode[];
|
|
11451
|
+
}) | (FieldNodeBase & {
|
|
11452
|
+
type: "bitset";
|
|
11453
|
+
bits: readonly BitsEntry[];
|
|
11454
|
+
}) | (FieldNodeBase & {
|
|
11455
|
+
type: "const";
|
|
11456
|
+
value: unknown;
|
|
11457
|
+
}) | (FieldNodeBase & {
|
|
11458
|
+
type: "lazy";
|
|
11459
|
+
inner: FieldNode;
|
|
11460
|
+
}) | (FieldNodeBase & {
|
|
11461
|
+
type: "string" | "number" | "boolean" | "any" | "never" | "function";
|
|
11462
|
+
}) |
|
|
11463
|
+
/** 自引用 schema 回到祖先处:值这一层以下不再描述,由渲染层展开或只读呈现。 */
|
|
11464
|
+
(FieldNodeBase & {
|
|
11465
|
+
type: "recursive";
|
|
11466
|
+
origin: string;
|
|
11467
|
+
});
|
|
11468
|
+
/**
|
|
11469
|
+
* 投影一个 schema 节点。
|
|
11470
|
+
* @param schema - rehydrate 之后的 volatile 表单 schema(或它的子节点)。
|
|
11471
|
+
* @param path - 该节点相对段根的路径;动态子节点由调用方给占位段。
|
|
11472
|
+
* @returns 渲染层要的字段树。
|
|
11473
|
+
*/
|
|
11474
|
+
declare function projectNode(schema: SchemaNode, path?: readonly string[]): FieldNode;
|
|
11475
|
+
/** 按当前值展开出的一个字段:路径与名字已按真实键与索引替换。 */
|
|
11476
|
+
interface WalkedField {
|
|
11477
|
+
path: readonly string[];
|
|
11478
|
+
node: FieldNode;
|
|
11479
|
+
/**
|
|
11480
|
+
* 这一行是某个动态容器的**成员本身**(dict 的键 / array 的项)时给出它的身份:容器路径、键、以及数组
|
|
11481
|
+
* 项的位置。渲染层用它画成员行(名字 + 移除);成员的子字段不带这个标记。
|
|
11482
|
+
*/
|
|
11483
|
+
member?: {
|
|
11484
|
+
parent: readonly string[];
|
|
11485
|
+
key: string;
|
|
11486
|
+
index: number | undefined;
|
|
11487
|
+
};
|
|
11488
|
+
}
|
|
11489
|
+
/** 候选键的来源(业务注册;见 `hints.ts`):dict 的「可以加哪些键」。 */
|
|
11490
|
+
interface SuggestedKeys {
|
|
11491
|
+
/**
|
|
11492
|
+
* 读某个 dict 字段的候选键。
|
|
11493
|
+
* @param path - 该字段的具体路径。
|
|
11494
|
+
* @returns 候选键;没有就是空数组。
|
|
11495
|
+
*/
|
|
11496
|
+
keysFor(path: readonly string[]): readonly string[];
|
|
11497
|
+
}
|
|
11498
|
+
/**
|
|
11499
|
+
* 按当前值把字段树展开成渲染顺序的扁平列表(前序):容器在前、子项紧随其后。
|
|
11500
|
+
*
|
|
11501
|
+
* 出现的**只有值里有的东西,加上必填的**:对象的必填字段始终占行(值是空的也要让用户看见"必须填"),非必填的
|
|
11502
|
+
* 按值出现——值里没有就不占行,它在这一层的「添加属性」候选里,选中才加。数组按索引、字典按键展开;字面量
|
|
11503
|
+
* union 是叶子控件,对象 union 只展开与当前值匹配的那个变体,intersect 的各成员在同一层展开。
|
|
11504
|
+
* @param root - 段根的字段树。
|
|
11505
|
+
* @param value - 生效值(或草稿后的值)。
|
|
11506
|
+
* @returns 渲染顺序的字段列表。
|
|
11507
|
+
*/
|
|
11508
|
+
declare function walkFields(root: FieldNode, value: unknown): WalkedField[];
|
|
11509
|
+
/** union 的变体切换:一个选项要写的值。 */
|
|
11510
|
+
interface VariantChoice {
|
|
11511
|
+
/** 页面上显示的名字:判别标签的值,或变体的形状。 */
|
|
11512
|
+
label: string;
|
|
11513
|
+
/** 写这个值就等于选中这一支。 */
|
|
11514
|
+
value: unknown;
|
|
11515
|
+
}
|
|
11516
|
+
//#endregion
|
|
11517
|
+
//#region src/client/schema-form/draft.d.ts
|
|
11518
|
+
/** 命名空间段(一段配置)的值。 */
|
|
11519
|
+
type Section = Record<string, unknown>;
|
|
11520
|
+
/** 文本草稿的解析结果:控件把用户输入交给保存那一刻解析。 */
|
|
11521
|
+
type TextParseResult =
|
|
11522
|
+
/** 得到一个值。 */
|
|
11523
|
+
{
|
|
11524
|
+
kind: "value";
|
|
11525
|
+
value: unknown;
|
|
11526
|
+
} |
|
|
11527
|
+
/** 这段文本不产生写(例如 secret 留空=保留已存的值)。 */
|
|
11528
|
+
{
|
|
11529
|
+
kind: "skip";
|
|
11530
|
+
} |
|
|
11531
|
+
/** 不是这个字段接受的值:留在屏幕上并挡住保存。 */
|
|
11532
|
+
{
|
|
11533
|
+
kind: "invalid";
|
|
11534
|
+
message: string;
|
|
11535
|
+
};
|
|
11536
|
+
/** 控件给文本草稿的解析规则。 */
|
|
11537
|
+
type TextParse = (text: string) => TextParseResult;
|
|
11538
|
+
/** 整段校验失败:消息 + 它落在哪一层(页面把消息画在**出错的那一行**上)。 */
|
|
11539
|
+
interface ValidationFailure {
|
|
11540
|
+
/** 面向用户的消息(已去掉 schemastery 拼的 `$…` 位置前缀)。 */
|
|
11541
|
+
message: string;
|
|
11542
|
+
/** 具体路径(段根起);空数组表示错误在整段上。 */
|
|
11543
|
+
path: readonly string[];
|
|
11544
|
+
}
|
|
11545
|
+
/**
|
|
11546
|
+
* 把校验器抛出的错误收成一条失败。
|
|
11547
|
+
*
|
|
11548
|
+
* schemastery 的 `ValidationError` 把路径留在 `options.path` 上(消息里的 `$…` 前缀是给命令行看的),所以这里
|
|
11549
|
+
* 取路径、去前缀——行内报错据此知道挂在哪一行。
|
|
11550
|
+
* @param error - 校验器抛出的错误。
|
|
11551
|
+
* @returns 消息与路径。
|
|
11552
|
+
*/
|
|
11553
|
+
declare function failureOf(error: unknown): ValidationFailure;
|
|
11554
|
+
/** 一字段渲染时要读的状态。 */
|
|
11555
|
+
interface DraftFieldState {
|
|
11556
|
+
/** 控件要显示的值:草稿优先,否则生效层。 */
|
|
11557
|
+
value: unknown;
|
|
11558
|
+
/** 文本草稿(文本控件显示它而不是重新格式化值)。 */
|
|
11559
|
+
text: string | undefined;
|
|
11560
|
+
/** 草稿不合法时的消息(控件显示,同时挡住保存)。 */
|
|
11561
|
+
invalid: string | undefined;
|
|
11562
|
+
/** 保存后这一字段是否会留下用户层条目。 */
|
|
11563
|
+
overridden: boolean;
|
|
11564
|
+
/** 这一字段在本页有还没保存的编辑(页面上给它一处高亮与一个「撤回」)。 */
|
|
11565
|
+
staged: boolean;
|
|
11566
|
+
}
|
|
11567
|
+
/** 模型要读要写的那个命名空间。 */
|
|
11568
|
+
type DraftScope = ConfigForm<Section>;
|
|
11569
|
+
//#endregion
|
|
11570
|
+
//#region src/client/schema-form/hints.d.ts
|
|
11571
|
+
/** 一个 dict 字段的候选键读数。 */
|
|
11572
|
+
type SuggestedKeysReader = () => readonly string[];
|
|
11573
|
+
/** 一个字段的文案(业务知道的说法;schema 上没有 title 这种位)。 */
|
|
11574
|
+
interface FieldText {
|
|
11575
|
+
/** 短名字(行式视图里当注释的抬头)。 */
|
|
11576
|
+
label?: string | undefined;
|
|
11577
|
+
/** 一句话说明。 */
|
|
11578
|
+
hint?: string | undefined;
|
|
11579
|
+
}
|
|
11580
|
+
/** 一个字段的文案读数。 */
|
|
11581
|
+
type FieldTextReader = () => FieldText;
|
|
11582
|
+
/** 一个可选项:要写进去的值,以及页面上显示的名字。 */
|
|
11583
|
+
interface SelectOption {
|
|
11584
|
+
/** 选中时写进配置的值。 */
|
|
11585
|
+
value: unknown;
|
|
11586
|
+
/** 显示名;省略就用值本身。 */
|
|
11587
|
+
label?: string | undefined;
|
|
11588
|
+
}
|
|
11589
|
+
/** 一个字段的候选值读数。 */
|
|
11590
|
+
interface SelectSpec {
|
|
11591
|
+
/**
|
|
11592
|
+
* 候选依赖哪些**兄弟字段**(相对该字段所在对象的路径)。
|
|
11593
|
+
*
|
|
11594
|
+
* 依赖只声明"什么时候要重算":读侧在投影时按当前读数(草稿优先)求一次候选,所以声明了依赖的字段会随着
|
|
11595
|
+
* 兄弟字段的编辑立刻换候选——「选完服务商才列它有哪些模型」就是这么来的。
|
|
11596
|
+
*/
|
|
11597
|
+
dependsOn?: readonly (readonly string[])[] | undefined;
|
|
11598
|
+
/**
|
|
11599
|
+
* 求候选。
|
|
11600
|
+
* @param read - 按依赖路径(相对该字段所在对象)读当前值:草稿优先。
|
|
11601
|
+
* @returns 可选项,顺序即页面上的顺序。
|
|
11602
|
+
*/
|
|
11603
|
+
options: (read: (path: readonly string[]) => unknown) => readonly SelectOption[];
|
|
11604
|
+
}
|
|
11605
|
+
/** 一个命名空间里各字段的候选键、文案与候选值。 */
|
|
11606
|
+
interface SchemaFormHintsFace {
|
|
11607
|
+
/**
|
|
11608
|
+
* 注册一个 dict 字段的候选键读数(重复注册同一处会覆盖,并通知一次)。
|
|
11609
|
+
* @param ns - settings 命名空间(行 id)。
|
|
11610
|
+
* @param path - 该 dict 字段的具体路径(顶层字段就是 `['models']`)。
|
|
11611
|
+
* @param read - 同步读数:当前候选键(顺序即页面上的顺序)。
|
|
11612
|
+
* @returns 注销函数。
|
|
11613
|
+
*/
|
|
11614
|
+
suggestKeys(ns: string, path: readonly string[], read: SuggestedKeysReader): () => void;
|
|
11615
|
+
/**
|
|
11616
|
+
* 读某处当前声明的候选键。
|
|
11617
|
+
* @param ns - settings 命名空间。
|
|
11618
|
+
* @param path - 该字段的路径。
|
|
11619
|
+
* @returns 候选键;没注册过就是空数组。
|
|
11620
|
+
*/
|
|
11621
|
+
keysFor(ns: string, path: readonly string[]): readonly string[];
|
|
11622
|
+
/**
|
|
11623
|
+
* 注册一个字段的文案(短名 + 一句话说明)。行式视图把它画成注释行;schema 的 `description` 是兜底。
|
|
11624
|
+
* @param ns - settings 命名空间。
|
|
11625
|
+
* @param path - 该字段的路径。
|
|
11626
|
+
* @param read - 同步读数。
|
|
11627
|
+
* @returns 注销函数。
|
|
11628
|
+
*/
|
|
11629
|
+
describe(ns: string, path: readonly string[], read: FieldTextReader): () => void;
|
|
11630
|
+
/**
|
|
11631
|
+
* 读某处当前注册的文案。
|
|
11632
|
+
* @param ns - settings 命名空间。
|
|
11633
|
+
* @param path - 该字段的路径。
|
|
11634
|
+
* @returns 文案;没注册过就是空对象。
|
|
11635
|
+
*/
|
|
11636
|
+
textFor(ns: string, path: readonly string[]): FieldText;
|
|
11637
|
+
/**
|
|
11638
|
+
* 注册一个字段的候选值读数(页面据此把字段画成选择器,并随依赖字段变化重算)。
|
|
11639
|
+
* @param ns - settings 命名空间。
|
|
11640
|
+
* @param path - 该字段的路径。
|
|
11641
|
+
* @param spec - 候选取法与它依赖的兄弟字段。
|
|
11642
|
+
* @returns 注销函数。
|
|
11643
|
+
*/
|
|
11644
|
+
select(ns: string, path: readonly string[], spec: SelectSpec): () => void;
|
|
11645
|
+
/**
|
|
11646
|
+
* 注册一个**具名候选源**:schema 上用 `role('select', { source })` 认领它,字段因此不必在客户端按 ns/path
|
|
11647
|
+
* 登记——同一个源可以被多行、多个字段复用(「服务商」「模型」就是这种)。
|
|
11648
|
+
* @param name - 源的名字(schema 的 `role` extra 里写的那一个)。
|
|
11649
|
+
* @param spec - 候选取法与它依赖的兄弟字段。
|
|
11650
|
+
* @returns 注销函数。
|
|
11651
|
+
*/
|
|
11652
|
+
source(name: string, spec: SelectSpec): () => void;
|
|
11653
|
+
/**
|
|
11654
|
+
* 读一个具名候选源。
|
|
11655
|
+
* @param name - 源的名字。
|
|
11656
|
+
* @returns 该源的读数;没注册过就是 `undefined`。
|
|
11657
|
+
*/
|
|
11658
|
+
sourceFor(name: string): SelectSpec | undefined;
|
|
11659
|
+
/**
|
|
11660
|
+
* 读某处当前声明的候选值读数。
|
|
11661
|
+
* @param ns - settings 命名空间。
|
|
11662
|
+
* @param path - 该字段的路径。
|
|
11663
|
+
* @returns 候选读数;没注册过就是 `undefined`。
|
|
11664
|
+
*/
|
|
11665
|
+
selectFor(ns: string, path: readonly string[]): SelectSpec | undefined;
|
|
11666
|
+
}
|
|
11667
|
+
/** 提示面的完整服务(业务用注册侧,表单一侧用读侧)。 */
|
|
11668
|
+
declare class SchemaFormHints extends Service implements SchemaFormHintsFace {
|
|
11669
|
+
#private;
|
|
11670
|
+
/** @param ctx - 提供本服务的插件上下文。 */
|
|
11671
|
+
constructor(ctx: Context);
|
|
11672
|
+
/** @param ns - settings 命名空间。 @param path - 字段路径。 @returns 该处的键。 */
|
|
11673
|
+
keysFor(ns: string, path: readonly string[]): readonly string[];
|
|
11674
|
+
/** @param ns - settings 命名空间。 @param path - 字段路径。 @returns 该处注册的文案。 */
|
|
11675
|
+
textFor(ns: string, path: readonly string[]): FieldText;
|
|
11676
|
+
/**
|
|
11677
|
+
* @param ns - settings 命名空间。
|
|
11678
|
+
* @param path - 字段路径。
|
|
11679
|
+
* @param spec - 候选取法与依赖。
|
|
11680
|
+
* @returns 注销函数。
|
|
11681
|
+
*/
|
|
11682
|
+
select(ns: string, path: readonly string[], spec: SelectSpec): () => void;
|
|
11683
|
+
/** @param ns - settings 命名空间。 @param path - 字段路径。 @returns 该处注册的候选读数。 */
|
|
11684
|
+
selectFor(ns: string, path: readonly string[]): SelectSpec | undefined;
|
|
11685
|
+
/**
|
|
11686
|
+
* @param name - 源的名字。
|
|
11687
|
+
* @param spec - 候选取法与依赖。
|
|
11688
|
+
* @returns 注销函数。
|
|
11689
|
+
*/
|
|
11690
|
+
source(name: string, spec: SelectSpec): () => void;
|
|
11691
|
+
/** @param name - 源的名字。 @returns 该源注册的候选读数。 */
|
|
11692
|
+
sourceFor(name: string): SelectSpec | undefined;
|
|
11693
|
+
/**
|
|
11694
|
+
* @param ns - settings 命名空间。
|
|
11695
|
+
* @param path - 字段路径。
|
|
11696
|
+
* @param read - 同步读数。
|
|
11697
|
+
* @returns 注销函数。
|
|
11698
|
+
*/
|
|
11699
|
+
describe(ns: string, path: readonly string[], read: FieldTextReader): () => void;
|
|
11700
|
+
/**
|
|
11701
|
+
* @param ns - settings 命名空间。
|
|
11702
|
+
* @param path - 字段路径。
|
|
11703
|
+
* @param read - 同步读数。
|
|
11704
|
+
* @returns 注销函数。
|
|
11705
|
+
*/
|
|
11706
|
+
suggestKeys(ns: string, path: readonly string[], read: SuggestedKeysReader): () => void;
|
|
11707
|
+
/**
|
|
11708
|
+
* 观察候选键的变化(注册与注销)。
|
|
11709
|
+
* @param listener - 变更回调。
|
|
11710
|
+
* @returns 取消订阅。
|
|
11711
|
+
*/
|
|
11712
|
+
subscribe(listener: () => void): () => void;
|
|
11713
|
+
/**
|
|
11714
|
+
* 重新通知一次:读数背后的数据变了(业务自己知道),页面据此重算候选行。
|
|
11715
|
+
*/
|
|
11716
|
+
refresh(): void;
|
|
11717
|
+
}
|
|
11718
|
+
declare module "@deepseek-ai/cordis" {
|
|
11719
|
+
interface Context {
|
|
11720
|
+
/** 通用表单的提示面(dict 的候选键)。 */
|
|
11721
|
+
schemaFormHints: SchemaFormHints;
|
|
11722
|
+
}
|
|
11723
|
+
}
|
|
11724
|
+
//#endregion
|
|
11725
|
+
//#region src/client/schema-form/controller.d.ts
|
|
11726
|
+
/**
|
|
11727
|
+
* rehydrate 一段配置 schema,并判它能不能当页面的根。
|
|
11728
|
+
*
|
|
11729
|
+
* 能当根的形状有三种:对象段、**相交段**(共享判别字段 + 各分支的 `const` 标记,段值仍是对象)、以及带判别
|
|
11730
|
+
* 标签的 `union`(成员都是对象)。字面量 `union`(整段就是一个标量)不行:那一行的写盘会变成整段替换。
|
|
11731
|
+
* @param serialized - host 发来的 `schema.toJSON()`。
|
|
11732
|
+
* @param rehydrate - host schema 的 rehydrate。
|
|
11733
|
+
* @returns schema 与它的字段树,或 `undefined`(不能当页面根)。
|
|
11734
|
+
*/
|
|
11735
|
+
declare function projectRoot(serialized: unknown, rehydrate: (serialized: unknown) => SchemaNode): {
|
|
11736
|
+
schema: SchemaNode;
|
|
11737
|
+
root: FieldNode;
|
|
11738
|
+
} | undefined;
|
|
11739
|
+
/**
|
|
11740
|
+
* 一行能否自动生成配置页:它的 schema 能 rehydrate 且根是 {@link projectRoot} 认的形状。
|
|
11741
|
+
* @param view - host 发来的命名空间视图。
|
|
11742
|
+
* @param rehydrate - host schema 的 rehydrate。
|
|
11743
|
+
* @returns 是否可以渲染。
|
|
11744
|
+
*/
|
|
11745
|
+
declare function canRender(view: SettingsNamespaceView | undefined, rehydrate: (serialized: unknown) => SchemaNode): boolean;
|
|
11746
|
+
/** 提示面在控制器里的读法:候选键 + 字段文案 + 候选值。 */
|
|
11747
|
+
interface HintSources extends SuggestedKeys {
|
|
11748
|
+
/**
|
|
11749
|
+
* 读某个字段的文案。
|
|
11750
|
+
* @param path - 该字段的具体路径。
|
|
11751
|
+
* @returns 业务注册的文案;没有就是空对象。
|
|
11752
|
+
*/
|
|
11753
|
+
textFor: (path: readonly string[]) => FieldText;
|
|
11754
|
+
/**
|
|
11755
|
+
* 读某个字段的候选值读数;不接提示面的装配可以不给(字段就还是文本编辑)。
|
|
11756
|
+
* @param path - 该字段的具体路径。
|
|
11757
|
+
* @returns 业务注册的候选读数;没有就是 `undefined`。
|
|
11758
|
+
*/
|
|
11759
|
+
selectFor?: ((path: readonly string[]) => SelectSpec | undefined) | undefined;
|
|
11760
|
+
/**
|
|
11761
|
+
* 读一个**具名候选源**(schema 的 `role('select', { source })` 认领它)。
|
|
11762
|
+
* @param name - 源的名字。
|
|
11763
|
+
* @returns 该源的读数;没注册过就是 `undefined`。
|
|
11764
|
+
*/
|
|
11765
|
+
sourceFor?: ((name: string) => SelectSpec | undefined) | undefined;
|
|
11766
|
+
}
|
|
11767
|
+
/** 控制器要的外部面(`apply` 里从 cordis ctx 组装;测试直接给替身)。 */
|
|
11768
|
+
interface SchemaFormDeps {
|
|
11769
|
+
/** 本命名空间的共享配置表单(读 + 带栅栏的写)。 */
|
|
11770
|
+
form: DraftScope;
|
|
11771
|
+
/** describe mirror 的读面:本行的 schema、autoGenerate 与 secret 槽。 */
|
|
11772
|
+
describe: SettingsDescribeFace;
|
|
11773
|
+
/** rehydrate host 发来的 `schema.toJSON()`。 */
|
|
11774
|
+
rehydrate: (serialized: unknown) => SchemaNode;
|
|
11775
|
+
/** 整段校验;失败时连路径一起给(页面把消息画在那一行)。 */
|
|
11776
|
+
validate: (schema: SchemaNode, value: unknown) => ValidationFailure | undefined;
|
|
11777
|
+
/** 本包字典(项身份冲突这类本地校验的消息)。 */
|
|
11778
|
+
t: SchemaFormTranslate;
|
|
11779
|
+
/**
|
|
11780
|
+
* dict 字段的候选键(业务注册,见 `hints.ts`):候选里有、值里没有的键会补成一行「未配置」,
|
|
11781
|
+
* 用户填了才算写。
|
|
11782
|
+
*/
|
|
11783
|
+
hints?: HintSources | undefined;
|
|
11784
|
+
}
|
|
11785
|
+
/**
|
|
11786
|
+
* 这一层「能加进来」的一项:schema 里声明、值里还没有的字段,或业务注册的候选键。
|
|
11787
|
+
*
|
|
11788
|
+
* 页面上不占行——它们出现在容器的闭合行那个「添加属性 / 添加键」输入框的候选里,选中才加。
|
|
11789
|
+
*/
|
|
11790
|
+
interface AddableProperty {
|
|
11791
|
+
/** 加进来的键名。 */
|
|
11792
|
+
key: string;
|
|
11793
|
+
/** 说明(schema 的 `description` / `comment`,可能是本地化字典):渲染层解析后当候选的副标题。 */
|
|
11794
|
+
description: string | Readonly<Record<string, string>> | undefined;
|
|
11795
|
+
}
|
|
11796
|
+
/** 页面级状态:表单壳 + 字段树 + 每字段草稿状态。 */
|
|
11797
|
+
interface SchemaFormState extends SettingsFormShell$1 {
|
|
11798
|
+
/** 这一行的 schema 是否可渲染(否则页面只显示一行说明)。 */
|
|
11799
|
+
configured: boolean;
|
|
11800
|
+
/** 字段树;未 configured 时是空对象树。 */
|
|
11801
|
+
root: FieldNode;
|
|
11802
|
+
/** 按草稿后的值展开的字段列表(渲染顺序):追加的数组项与新增的字典键立刻出现。 */
|
|
11803
|
+
walked: readonly WalkedField[];
|
|
11804
|
+
/** 每个具体路径的草稿状态,键见 {@link fieldKey}。 */
|
|
11805
|
+
fields: ReadonlyMap<string, DraftFieldState>;
|
|
11806
|
+
/** secret 槽是否已配置,键见 {@link fieldKey}。 */
|
|
11807
|
+
secrets: ReadonlyMap<string, boolean>;
|
|
11808
|
+
/** 每个字段的文案(提示面注册的),键见 {@link fieldKey};渲染层把它画成注释行。 */
|
|
11809
|
+
texts: ReadonlyMap<string, FieldText>;
|
|
11810
|
+
/**
|
|
11811
|
+
* 每个字段的可选项,键见 {@link fieldKey}:字面量集合的 union 自带候选,其余来自提示面。
|
|
11812
|
+
* 候选依赖的兄弟字段一改,这里就跟着变(投影时按草稿后的值求一次)。
|
|
11813
|
+
*/
|
|
11814
|
+
options: ReadonlyMap<string, readonly SelectOption[]>;
|
|
11815
|
+
/**
|
|
11816
|
+
* 每个容器能加进来的项,键见 {@link fieldKey}(容器自己的路径)。没有条目就是加不了东西——对象层的输入框
|
|
11817
|
+
* 因此只在还有声明字段没配时出现。
|
|
11818
|
+
*/
|
|
11819
|
+
addable: ReadonlyMap<string, readonly AddableProperty[]>;
|
|
11820
|
+
/** 保存被 schema 挡下时的消息与它的位置。 */
|
|
11821
|
+
violation: ValidationFailure | undefined;
|
|
11822
|
+
/** 每行的校验消息(键见 {@link fieldKey}):行内报错,与底部的整段提示同源。 */
|
|
11823
|
+
invalidAt: ReadonlyMap<string, string>;
|
|
11824
|
+
}
|
|
11825
|
+
/** 控件的写动作:全部落在草稿上,`save` 是唯一的写盘点。 */
|
|
11826
|
+
interface SchemaFormActions {
|
|
11827
|
+
/** 暂存一个合法值。 */
|
|
11828
|
+
set: (path: readonly string[], value: unknown) => void;
|
|
11829
|
+
/** 暂存一段文本(保存时解析)。 */
|
|
11830
|
+
setText: (path: readonly string[], text: string, parse: TextParse) => void;
|
|
11831
|
+
/** 暂存「恢复默认」。 */
|
|
11832
|
+
clear: (path: readonly string[]) => void;
|
|
11833
|
+
/** 追加一个数组项。 */
|
|
11834
|
+
appendItem: (path: readonly string[]) => void;
|
|
11835
|
+
/** 移除一个数组项。 */
|
|
11836
|
+
removeItem: (path: readonly string[], index: number) => void;
|
|
11837
|
+
/** 加一个字典键。 */
|
|
11838
|
+
addKey: (path: readonly string[], key: string) => void;
|
|
11839
|
+
/** 删一个字典键。 */
|
|
11840
|
+
removeKey: (path: readonly string[], key: string) => void;
|
|
11841
|
+
/** 写盘。 */
|
|
11842
|
+
save: () => void;
|
|
11843
|
+
/** 撤销一个字段的草稿(行内编辑取消)。 */
|
|
11844
|
+
revert: (path: readonly string[]) => void;
|
|
11845
|
+
/** 丢弃草稿。 */
|
|
11846
|
+
discard: () => void;
|
|
11847
|
+
}
|
|
11848
|
+
/** 槽位渲染器绑定的动作与可观察状态。 */
|
|
11849
|
+
interface SchemaFormFace extends SchemaFormActions {
|
|
11850
|
+
hooks: {
|
|
11851
|
+
schemaForm: SnapshotStore<SchemaFormState>;
|
|
11852
|
+
};
|
|
11853
|
+
}
|
|
11854
|
+
/**
|
|
11855
|
+
* 一个字段的可选项。
|
|
11856
|
+
*
|
|
11857
|
+
* 字面量集合的 union(`z.union(["wal", "delete"])`)自己就带着候选;其余看提示面注册的读数——读的时候把依赖的
|
|
11858
|
+
* 兄弟字段值喂进去,所以「选完服务商才列它有哪些模型」是投影的一部分,不是额外的一次订阅。
|
|
11859
|
+
* @param node - 字段节点。
|
|
11860
|
+
* @param path - 该字段的具体路径。
|
|
11861
|
+
* @param value - 段值(草稿后的)。
|
|
11862
|
+
* @param hints - 提示面。
|
|
11863
|
+
* @returns 可选项;没有候选就是 `undefined`。
|
|
11864
|
+
*/
|
|
11865
|
+
declare function optionsFor(node: FieldNode, path: readonly string[], value: unknown, hints: HintSources | undefined): readonly SelectOption[] | undefined;
|
|
11866
|
+
/**
|
|
11867
|
+
* 一行配置页的控制器。
|
|
11868
|
+
*/
|
|
11869
|
+
declare class SchemaFormController {
|
|
11870
|
+
#private;
|
|
11871
|
+
/**
|
|
11872
|
+
* @param ns - settings 命名空间(行 id)。
|
|
11873
|
+
* @param deps - 该行的共享表单与 schema 面。
|
|
11874
|
+
*/
|
|
11875
|
+
constructor(ns: string, deps: SchemaFormDeps);
|
|
11876
|
+
/** 槽位渲染器要的动作与状态。 */
|
|
11877
|
+
face(): SchemaFormFace;
|
|
11878
|
+
/** 本行的 settings 命名空间。 */
|
|
11879
|
+
namespace(): string;
|
|
11880
|
+
/** 外部提示(候选键这类)变了:重新投影一次,字段树与草稿都不动。 */
|
|
11881
|
+
refresh(): void;
|
|
11882
|
+
/** 释放订阅。 */
|
|
11883
|
+
dispose(): void;
|
|
11884
|
+
}
|
|
11885
|
+
//#endregion
|
|
11886
|
+
//#region src/client/schema-form/labels.d.ts
|
|
11887
|
+
/** 把 schema 里的本地化文本解析成当前语言;由 locale 服务提供。 */
|
|
11888
|
+
type ResolveText = (text: string | Readonly<Record<string, string>>) => string;
|
|
11889
|
+
//#endregion
|
|
11890
|
+
//#region src/client/schema-form/locales.d.ts
|
|
11891
|
+
/**
|
|
11892
|
+
* 本包字典(命名空间 `settings.schema-form`):表单壳、字段控件与只读呈现的文案。
|
|
11893
|
+
*
|
|
11894
|
+
* 字段自身的人话标签不在这里(那是业务方经字段槽或 schema `description` 给的),这里只放**机制**文案。
|
|
11895
|
+
*/
|
|
11896
|
+
/** 中文文案(部署语言偏好是 zh)。 */
|
|
11897
|
+
declare const zh: {
|
|
11898
|
+
readonly unavailable: "该插件当前未加载,暂时无法配置。";
|
|
11899
|
+
readonly readOnly: "本部署的设置为只读。";
|
|
11900
|
+
readonly save: "保存";
|
|
11901
|
+
readonly confirmEdit: "确认";
|
|
11902
|
+
readonly cancelEdit: "取消";
|
|
11903
|
+
readonly saving: "保存中…";
|
|
11904
|
+
readonly saveFailed: "本部署没有接受这些值,已保留供你修改。";
|
|
11905
|
+
readonly notSaved: "没有保存:{message}";
|
|
11906
|
+
readonly noSchema: "这一行没有可自动生成的配置项。";
|
|
11907
|
+
readonly reset: "恢复默认";
|
|
11908
|
+
readonly revert: "撤回";
|
|
11909
|
+
readonly invalid: "这个值不被接受。";
|
|
11910
|
+
readonly invalidNumber: "需要一个数字。";
|
|
11911
|
+
readonly invalidInteger: "需要一个整数。";
|
|
11912
|
+
readonly invalidJson: "需要一段合法的 JSON。";
|
|
11913
|
+
readonly invalidBoolean: "需要 true 或 false。";
|
|
11914
|
+
readonly invalidConst: "这个字段只接受固定值。";
|
|
11915
|
+
readonly invalidPattern: "要匹配 {pattern}。";
|
|
11916
|
+
readonly invalidRange: "要在 {min} 与 {max} 之间。";
|
|
11917
|
+
readonly invalidMin: "不能小于 {min}。";
|
|
11918
|
+
readonly invalidMax: "不能大于 {max}。";
|
|
11919
|
+
readonly invalidChoice: "只能是 {choices} 之一。";
|
|
11920
|
+
readonly unknownProperty: "这一层没有这个字段:从上面的候选里选,或换个键名。";
|
|
11921
|
+
readonly empty: "(空)";
|
|
11922
|
+
readonly toggleGroup: "展开 / 收起这一层";
|
|
11923
|
+
readonly switchVariant: "切换这一层的形状或分支";
|
|
11924
|
+
readonly copyValue: "复制值";
|
|
11925
|
+
readonly copied: "已复制";
|
|
11926
|
+
readonly addProperty: "添加属性";
|
|
11927
|
+
readonly addItemPaste: "添加数组项(可粘贴 JSON 字符串)";
|
|
11928
|
+
readonly addItem: "添加一项";
|
|
11929
|
+
readonly removeItem: "移除";
|
|
11930
|
+
readonly addKey: "添加键(可粘贴 JSON 字符串)";
|
|
11931
|
+
readonly keyName: "键名";
|
|
11932
|
+
readonly noKeys: "还没有键。";
|
|
11933
|
+
readonly noItems: "还没有项。";
|
|
11934
|
+
readonly deprecated: "已废弃";
|
|
11935
|
+
readonly experimental: "试验中";
|
|
11936
|
+
readonly secretSet: "已配置";
|
|
11937
|
+
readonly secretUnset: "未配置";
|
|
11938
|
+
readonly secretHint: "留空即保留已存的值。";
|
|
11939
|
+
readonly constValue: "固定值";
|
|
11940
|
+
readonly notEditable: "这一项由插件在运行时提供,不能在页面上编辑。";
|
|
11941
|
+
readonly recursive: "递归结构:展开到这一层为止。";
|
|
11942
|
+
readonly fixedLength: "固定长度";
|
|
11943
|
+
readonly bitsetHint: "可多选。";
|
|
11944
|
+
readonly unconfigured: "未配置";
|
|
11945
|
+
readonly readOnlyField: "只读";
|
|
11946
|
+
readonly noDescription: "(无说明)";
|
|
11947
|
+
readonly required: "必填";
|
|
11948
|
+
readonly duplicateItem: "重复的 {key}:{value}";
|
|
11949
|
+
readonly missingItem: "每一项都需要一个 {key}";
|
|
11950
|
+
};
|
|
11951
|
+
/** 本命名空间的字典键。 */
|
|
11952
|
+
type SchemaFormLocaleKey = keyof typeof zh;
|
|
11953
|
+
//#endregion
|
|
11954
|
+
//#region src/client/schema-form/slot-contract.d.ts
|
|
11955
|
+
/** 字段槽的 owner props:路由输入 + 显示状态 + 受控动作(默认控件要的一切都在这里)。 */
|
|
11956
|
+
interface SchemaFieldOwnerProps {
|
|
11957
|
+
/** settings 命名空间(行 id)。 */
|
|
11958
|
+
ns: string;
|
|
11959
|
+
/** 字段的具体路径(动态段已按真实键或索引替换)。 */
|
|
11960
|
+
path: readonly string[];
|
|
11961
|
+
/** 字段节点(类型、`role`、`extra`、界限、只读原因)。 */
|
|
11962
|
+
node: FieldNode;
|
|
11963
|
+
/** 显示标签:默认是字段名拆词,业务方经槽给时会覆盖。 */
|
|
11964
|
+
label: string;
|
|
11965
|
+
/** 显示说明(`description` 本地化 + `comment`)。 */
|
|
11966
|
+
hint: string | undefined;
|
|
11967
|
+
/** 当前生效值(草稿优先)。 */
|
|
11968
|
+
value: unknown;
|
|
11969
|
+
/**
|
|
11970
|
+
* 这个字段的可选项:给了就是选择器(点值不再进文本编辑)。来源是字面量集合的 union,或业务经提示面注册的
|
|
11971
|
+
* 候选——候选依赖的兄弟字段一变,这里就换一批。
|
|
11972
|
+
*/
|
|
11973
|
+
options: readonly SelectOption[] | undefined;
|
|
11974
|
+
/** 文本草稿:文本控件显示它,而不是重新格式化生效值。 */
|
|
11975
|
+
text: string | undefined;
|
|
11976
|
+
/** secret 槽是否已配置(值本身不回传)。 */
|
|
11977
|
+
secretConfigured: boolean;
|
|
11978
|
+
/** 嵌套深度:默认控件按它缩进。 */
|
|
11979
|
+
depth: number;
|
|
11980
|
+
/** 保存后这一字段是否会留下用户层条目。 */
|
|
11981
|
+
overridden: boolean;
|
|
11982
|
+
/** 草稿不合法时的消息。 */
|
|
11983
|
+
invalid: string | undefined;
|
|
11984
|
+
/** 只读部署或不可用命名空间时为 true。 */
|
|
11985
|
+
disabled: boolean;
|
|
11986
|
+
/** 本包字典(复刻或包装默认控件时用)。 */
|
|
11987
|
+
t: SchemaFormTranslate;
|
|
11988
|
+
/** 容器动作(增删数组项、字典键、丢弃、保存)。 */
|
|
11989
|
+
actions: SchemaFormActions;
|
|
11990
|
+
/**
|
|
11991
|
+
* 分组节点的折叠交互(object / dict / array / tuple);叶子节点是 `undefined`。
|
|
11992
|
+
* 默认折叠与否由 schema 的 `collapse()` 决定,用户点一下就是反转。
|
|
11993
|
+
*/
|
|
11994
|
+
group: {
|
|
11995
|
+
collapsed: boolean;
|
|
11996
|
+
toggle: () => void;
|
|
11997
|
+
} | undefined;
|
|
11998
|
+
/**
|
|
11999
|
+
* 这一行是动态容器的成员本身(dict 的键 / array 的项)时的身份:容器路径、键、数组项的位置。容器成员把它画进
|
|
12000
|
+
* 标题行(名字 + 移除),叶子成员由渲染层另起一行——所以「哪个字段属于哪个键/哪一项」在页面上一眼可见。
|
|
12001
|
+
*/
|
|
12002
|
+
member: {
|
|
12003
|
+
parent: readonly string[];
|
|
12004
|
+
key: string;
|
|
12005
|
+
index: number | undefined;
|
|
12006
|
+
pending?: boolean;
|
|
12007
|
+
} | undefined;
|
|
12008
|
+
/** 暂存一个合法值。 */
|
|
12009
|
+
onChange: (value: unknown) => void;
|
|
12010
|
+
/**
|
|
12011
|
+
* 暂存一段文本:按字段类型的默认规则解析;给了 `parse` 就用它(例如 secret 留空=不写)。
|
|
12012
|
+
* @param text - 用户输入。
|
|
12013
|
+
* @param parse - 覆盖默认解析规则。
|
|
12014
|
+
*/
|
|
12015
|
+
onEditText: (text: string, parse?: TextParse) => void;
|
|
12016
|
+
/** 暂存「恢复默认」。 */
|
|
12017
|
+
onReset: () => void;
|
|
12018
|
+
}
|
|
12019
|
+
/**
|
|
12020
|
+
* 字段槽注册项的完整 props:框架注入的 owner props({@link SchemaFieldOwnerProps})+它的 `select` 结果。
|
|
12021
|
+
*
|
|
12022
|
+
* 注册方的组件按这个类型声明参数(**不要**自己重写 owner props 的类型:注册时框架会把它读成 inject 面)。
|
|
12023
|
+
*/
|
|
12024
|
+
type SchemaFieldComponentProps<M extends SchemaFieldMatch = SchemaFieldMatch> = PropsRuntime<"settings.schema-form.field"> & {
|
|
12025
|
+
matched: M;
|
|
12026
|
+
};
|
|
12027
|
+
/**
|
|
12028
|
+
* 字段槽注册项的 `select`:返回认领结果,或 `null` 表示不认领(chain 槽的约定是 `null` 放行给下一项,
|
|
12029
|
+
* `undefined` 不会被当成"不认领")。
|
|
12030
|
+
*/
|
|
12031
|
+
type SchemaFieldSelect = (field: SchemaFieldOwnerProps) => SchemaFieldMatch | null;
|
|
12032
|
+
/** 字段槽 `select` 可以只给文案:控件仍由注册方渲染(拿本包的默认控件包一层即可)。 */
|
|
12033
|
+
interface SchemaFieldMatch {
|
|
12034
|
+
/** 覆盖显示标签。 */
|
|
12035
|
+
label?: string;
|
|
12036
|
+
/** 覆盖显示说明。 */
|
|
12037
|
+
hint?: string;
|
|
12038
|
+
}
|
|
12039
|
+
/** Factory 的输入 props:一行的配置页。 */
|
|
12040
|
+
interface SchemaFormProps {
|
|
12041
|
+
/** settings 命名空间(行 id)。 */
|
|
12042
|
+
ns: string;
|
|
12043
|
+
/** 该行的控制器动作与状态。 */
|
|
12044
|
+
face: SchemaFormFace;
|
|
12045
|
+
/** schema 里的本地化文本(`description`)按当前语言解析。 */
|
|
12046
|
+
resolveText: ResolveText;
|
|
12047
|
+
}
|
|
12048
|
+
/** 本包字典的翻译函数(默认控件与表单壳使用)。 */
|
|
12049
|
+
type SchemaFormTranslate = TranslateNS<"settings.schema-form">;
|
|
12050
|
+
declare module "@deepseek-ai/dsh-client-ui-slots" {
|
|
12051
|
+
interface LocaleNamespaceMap {
|
|
12052
|
+
/** 表单壳、字段控件与只读呈现的文案。 */
|
|
12053
|
+
"settings.schema-form": SchemaFormLocaleKey;
|
|
12054
|
+
}
|
|
12055
|
+
interface SlotMap {
|
|
12056
|
+
/**
|
|
12057
|
+
* 字段级自定义输入与文案:按 `role` 或 `ns + path` 认领一个字段,命中即渲染注册方的组件(未命中落到默认
|
|
12058
|
+
* 控件)。注册项由业务插件用 `ctx.slots.inject('settings.schema-form.field', …)` 注册,声明由本包的
|
|
12059
|
+
* Factory 给出。
|
|
12060
|
+
*/
|
|
12061
|
+
"settings.schema-form.field": {
|
|
12062
|
+
kind: "chain";
|
|
12063
|
+
scope: "root";
|
|
12064
|
+
owner: SchemaFieldOwnerProps;
|
|
12065
|
+
};
|
|
12066
|
+
}
|
|
12067
|
+
interface SlotFactoryMap {
|
|
12068
|
+
/**
|
|
12069
|
+
* 一行配置页的渲染体:每个可渲染的行注册项经 `renderFactorySlot` 渲染同一个 Factory,字段槽因此只需声明
|
|
12070
|
+
* 一次(slots 的 children 声明 per key 唯一)。
|
|
12071
|
+
*/
|
|
12072
|
+
"settings.schema-form.form": {
|
|
12073
|
+
scope: "root";
|
|
12074
|
+
props: SchemaFormProps;
|
|
12075
|
+
locale: "settings.schema-form";
|
|
12076
|
+
children: {
|
|
12077
|
+
"settings.schema-form.field": {
|
|
12078
|
+
kind: "chain";
|
|
12079
|
+
scope: "root";
|
|
12080
|
+
};
|
|
12081
|
+
};
|
|
12082
|
+
};
|
|
12083
|
+
}
|
|
12084
|
+
}
|
|
12085
|
+
//#endregion
|
|
12086
|
+
//#region src/client/schema-form/rows.d.ts
|
|
12087
|
+
/** 一个该自动长出配置页的行。 */
|
|
12088
|
+
interface RowRegistrationPlan {
|
|
12089
|
+
/** `plugins.row.config` 的 key:`<bundle 包名>#<行 id>`。 */
|
|
12090
|
+
key: string;
|
|
12091
|
+
/** settings 命名空间(行 id)。 */
|
|
12092
|
+
ns: string;
|
|
12093
|
+
}
|
|
12094
|
+
/**
|
|
12095
|
+
* 配对命名空间与 bundle 行清单。
|
|
12096
|
+
* @param namespaces - host 发来的命名空间视图。
|
|
12097
|
+
* @param bundles - host 的 bundle 清单(含各 bundle 声明的行 id)。
|
|
12098
|
+
* @returns 该自动注册的行,按命名空间视图的顺序。
|
|
12099
|
+
*/
|
|
12100
|
+
declare function rowRegistrations(namespaces: readonly SettingsNamespaceView[], bundles: readonly BundleInfo[]): RowRegistrationPlan[];
|
|
12101
|
+
//#endregion
|
|
12102
|
+
//#region src/client/schema-form/value.d.ts
|
|
12103
|
+
/** 编辑态文本:字符串就是原文(换行照旧),其余按 JSON 写。 */
|
|
12104
|
+
declare function valueText(value: unknown): string;
|
|
12105
|
+
/** 显示态文本:字符串带引号;多行与特殊字符都按 JSON 的写法收在一行里。 */
|
|
12106
|
+
declare function tokenText(value: unknown): string;
|
|
12107
|
+
/** 值的语法色分组。 */
|
|
12108
|
+
declare function tokenTone(value: unknown): "string" | "number" | "boolean" | "empty";
|
|
12109
|
+
/**
|
|
12110
|
+
* 行内值的默认呈现(显示态 token)。
|
|
12111
|
+
* @param props.owner - 字段上下文(值、是否 secret、只读原因)。
|
|
12112
|
+
* @returns 一行里的值节点。
|
|
12113
|
+
*/
|
|
12114
|
+
declare function InlineValue({ owner }: {
|
|
12115
|
+
owner: SchemaFieldOwnerProps;
|
|
12116
|
+
}): ReactNode;
|
|
12117
|
+
/**
|
|
12118
|
+
* 字段槽注册方复用的默认值:只改文案时拿它包一层即可(`owner` 上覆盖 `label`/`hint`)。
|
|
12119
|
+
*
|
|
12120
|
+
* 注意行式视图里键名来自配置键本身、注释来自 `hint`,所以 `label` 只在业务自写控件时才需要。
|
|
12121
|
+
*/
|
|
12122
|
+
declare function SchemaFieldDefault({ owner }: {
|
|
12123
|
+
owner: SchemaFieldOwnerProps;
|
|
12124
|
+
}): ReactNode;
|
|
12125
|
+
//#endregion
|
|
12126
|
+
//#region src/client/schema-form/fields.d.ts
|
|
12127
|
+
/**
|
|
12128
|
+
* 各类型的文本解析规则(消息来自本包字典)。
|
|
12129
|
+
*
|
|
12130
|
+
* 解析不只看类型:schema 上声明的界限(`pattern` / `min` / `max` / `step`)与字面量集合都在这里说话——
|
|
12131
|
+
* 用户敲完当场就知道对不对,而不是等保存时被整段校验退回。
|
|
12132
|
+
* @param node - 字段节点(`meta` 是约束的来源)。
|
|
12133
|
+
* @param t - 本包字典。
|
|
12134
|
+
* @returns 这段文本的解析规则。
|
|
12135
|
+
*/
|
|
12136
|
+
declare function parseFor(node: FieldNode, t: SchemaFormTranslate): TextParse;
|
|
12137
|
+
//#endregion
|
|
12138
|
+
//#region src/client/schema-form/lines.d.ts
|
|
12139
|
+
/** 一个容器的闭合行后面能加什么。 */
|
|
12140
|
+
type AddLineSpec =
|
|
12141
|
+
/** 数组:追加一个空项。 */
|
|
12142
|
+
{
|
|
12143
|
+
kind: "item";
|
|
12144
|
+
} |
|
|
12145
|
+
/** 字典:敲键名,或从候选键里选(业务注册的读数)。 */
|
|
12146
|
+
{
|
|
12147
|
+
kind: "key";
|
|
12148
|
+
options: readonly AddableProperty[];
|
|
12149
|
+
} |
|
|
12150
|
+
/** 对象:从「schema 声明了、值里还没有」的字段里选(没有候选项时不给输入框)。 */
|
|
12151
|
+
{
|
|
12152
|
+
kind: "prop";
|
|
12153
|
+
options: readonly AddableProperty[];
|
|
12154
|
+
};
|
|
12155
|
+
/** 一行上的变体切换控件。 */
|
|
12156
|
+
interface VariantControl {
|
|
12157
|
+
/** 可以切到哪几支;顺序即声明顺序。 */
|
|
12158
|
+
choices: readonly VariantChoice[];
|
|
12159
|
+
/** 当前落在第几支。 */
|
|
12160
|
+
selected: number;
|
|
12161
|
+
}
|
|
12162
|
+
/** 容器类型:结构行用 `{` 还是 `[`。 */
|
|
12163
|
+
type ContainerShape = "object" | "array";
|
|
12164
|
+
/** 一行。 */
|
|
12165
|
+
type EditorLine =
|
|
12166
|
+
/** 容器的开启行:`key: {` 或 `[`。 */
|
|
12167
|
+
{
|
|
12168
|
+
kind: "open";
|
|
12169
|
+
path: readonly string[];
|
|
12170
|
+
node: FieldNode;
|
|
12171
|
+
shape: ContainerShape;
|
|
12172
|
+
depth: number;
|
|
12173
|
+
collapsed: boolean;
|
|
12174
|
+
member: WalkedField["member"];
|
|
12175
|
+
/** 这一层是 union 时,可以在哪几支之间切(写哪个值)。 */
|
|
12176
|
+
variants: VariantControl | undefined;
|
|
12177
|
+
} |
|
|
12178
|
+
/** 容器的关闭行:`}` / `]`(添加行挂在它后面同一行)。 */
|
|
12179
|
+
{
|
|
12180
|
+
kind: "close";
|
|
12181
|
+
path: readonly string[];
|
|
12182
|
+
node: FieldNode;
|
|
12183
|
+
shape: ContainerShape;
|
|
12184
|
+
depth: number;
|
|
12185
|
+
/** 这一层能加什么;`undefined` 表示加不了(对象的声明字段都配齐了)。 */
|
|
12186
|
+
add: AddLineSpec | undefined;
|
|
12187
|
+
member: WalkedField["member"];
|
|
12188
|
+
} |
|
|
12189
|
+
/** 字段行:`key: value`。 */
|
|
12190
|
+
{
|
|
12191
|
+
kind: "field";
|
|
12192
|
+
path: readonly string[];
|
|
12193
|
+
node: FieldNode;
|
|
12194
|
+
depth: number;
|
|
12195
|
+
field: DraftFieldState;
|
|
12196
|
+
member: WalkedField["member"];
|
|
12197
|
+
/** 这个字段是 union 时,可以在哪几支之间切。 */
|
|
12198
|
+
variants: VariantControl | undefined;
|
|
12199
|
+
/**
|
|
12200
|
+
* 变体触发**代替这一行的值**:判别式 union 的标签行就是这样——`type: "sqlite" ▾` 里的值就是那个触发,
|
|
12201
|
+
* 不再另画一份值。
|
|
12202
|
+
*/
|
|
12203
|
+
variantsStandIn: boolean;
|
|
12204
|
+
} |
|
|
12205
|
+
/** 注释行:schema 的说明与业务给的文案,画在字段行上方;这一行有问题时它装的是那条消息。 */
|
|
12206
|
+
{
|
|
12207
|
+
kind: "comment";
|
|
12208
|
+
path: readonly string[];
|
|
12209
|
+
depth: number;
|
|
12210
|
+
text: string;
|
|
12211
|
+
/** 这一行有校验消息(草稿解析失败或整段校验落下来):画成错误,而不是普通说明。 */
|
|
12212
|
+
invalid: boolean;
|
|
12213
|
+
};
|
|
12214
|
+
/**
|
|
12215
|
+
* 容器的形状:对象类用 `{}`,序列类用 `[]`。
|
|
12216
|
+
*
|
|
12217
|
+
* union 没有自己的形状——它跟着**当前选中那一支**走(`access` 是数组就在页面上画 `[`),这也是
|
|
12218
|
+
* `access: string | string[]` 这类字段以前被画成对象容器的原因。
|
|
12219
|
+
* @param node - 字段节点。
|
|
12220
|
+
* @param value - 这一层的值(选支判据)。
|
|
12221
|
+
* @returns 形状;叶子节点是 `undefined`。
|
|
12222
|
+
*/
|
|
12223
|
+
declare function containerShape(node: FieldNode, value?: unknown): ContainerShape | undefined;
|
|
12224
|
+
/** 折叠状态与可见性:记「用户切换过的路径」,开合 = 切换过就反转 schema 的默认值。 */
|
|
12225
|
+
interface FoldState {
|
|
12226
|
+
collapsed(path: readonly string[]): boolean;
|
|
12227
|
+
toggle(path: readonly string[]): void;
|
|
12228
|
+
}
|
|
12229
|
+
/** 渲染顺序里可见的字段:折叠的容器把整棵子树滤掉,只留它自己的开启行。 */
|
|
12230
|
+
declare function visibleFields(state: SchemaFormState, fold: FoldState): readonly WalkedField[];
|
|
12231
|
+
/**
|
|
12232
|
+
* 排成行序列。
|
|
12233
|
+
* @param state - 页面读数。
|
|
12234
|
+
* @param fold - 折叠状态。
|
|
12235
|
+
* @param resolveText - `description` 的本地化。
|
|
12236
|
+
* @param t - 本包字典。
|
|
12237
|
+
* @returns 行序列(行号即下标)。
|
|
12238
|
+
*/
|
|
12239
|
+
declare function editorLines(state: SchemaFormState, fold: FoldState, resolveText: ResolveText, t: SchemaFormTranslate): EditorLine[];
|
|
12240
|
+
declare namespace index_d_exports {
|
|
12241
|
+
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 };
|
|
12242
|
+
}
|
|
12243
|
+
/** 本包字典与槽位文案的命名空间。 */
|
|
12244
|
+
declare const NS = "settings.schema-form";
|
|
12245
|
+
/** 需要的服务:槽位、字典、共享配置表单、schema 服务与插件管理(bundle 行清单)。 */
|
|
12246
|
+
declare const inject$1: string[];
|
|
12247
|
+
/**
|
|
12248
|
+
* 装上本包:字典、Factory(字段槽的声明者)与按行自动注册。
|
|
12249
|
+
* @param ctx - 浏览器插件上下文。
|
|
12250
|
+
*/
|
|
12251
|
+
declare function apply$1(ctx: Context): void;
|
|
12252
|
+
//#endregion
|
|
10912
12253
|
//#region src/reference-markdown.d.ts
|
|
10913
12254
|
interface ReferenceActions {
|
|
10914
12255
|
readonly openFile: (path: string) => void;
|
|
@@ -10925,7 +12266,16 @@ declare function referenceMentions(actions?: ReferenceActions, tokens?: Readonly
|
|
|
10925
12266
|
declare const ReferenceMarkdown: import("react").MemoExoticComponent<({ text, labels, actions, streaming, pathImages }: ReferenceMarkdownProps) => import("react/jsx-runtime").JSX.Element>;
|
|
10926
12267
|
//#endregion
|
|
10927
12268
|
//#region src/client/index.d.ts
|
|
12269
|
+
/**
|
|
12270
|
+
* 需要的**服务名**:样式与引用那半不要服务,schema 表单那半要槽位、字典与配置表单。
|
|
12271
|
+
*
|
|
12272
|
+
* 与包清单里的 `dsh.client.inject` 不是一回事:那份是**装配行 id**(谁先到),交给模块系统排 arrival 顺序;
|
|
12273
|
+
* 这里读的是 cordis 服务名(谁已 provide),Loader 拿它决定这一行何时才算 active。写错成包名,这一行就永远
|
|
12274
|
+
* pending(`web boot: ... waiting for services`)。
|
|
12275
|
+
*
|
|
12276
|
+
* 值直接取自 schema 表单那一面,不另抄一份清单。
|
|
12277
|
+
*/
|
|
10928
12278
|
declare const inject: readonly string[];
|
|
10929
|
-
declare function apply(
|
|
12279
|
+
declare function apply(ctx: Context): void;
|
|
10930
12280
|
//#endregion
|
|
10931
|
-
export { type CSSObject, type CSSProps, type CSSSelector, type CSSValue, type CSSVar, type CSSVarRef, MarkdownCopySeat, type Reference, type ReferenceActions, ReferenceMarkdown, type ReferenceMarkdownProps, type ReferenceSpan, type StyledComponent, Styling, Token, type TokenVars, type Tokens, apply, designTokens, dsw, findReferences, formatReference, formatReferenceMention, inject, isLocalReference, markdownLabels, parseReference, parseReferenceToken, referenceMentions, styleOf, styled, styling };
|
|
12281
|
+
export { type CSSObject, type CSSProps, type CSSSelector, type CSSValue, type CSSVar, type CSSVarRef, type FieldMeta, type FieldNode, MarkdownCopySeat, type Reference, type ReferenceActions, ReferenceMarkdown, type ReferenceMarkdownProps, type ReferenceSpan, NS as SCHEMA_FORM_NS, type SchemaFormActions, SchemaFormController, type SchemaFormFace, SchemaFormHints, type SchemaFormLocaleKey, type SchemaFormState, type SelectOption, type SelectSpec, type SettingsFieldProps, type SettingsFieldSpec, type SettingsFieldState, type SettingsFieldWrite, SettingsForm, type SettingsFormActions, type SettingsFormLabels, SettingsFormModel, type SettingsFormPathOp, type SettingsFormProps, type SettingsFormScope, type SettingsFormScopeSnapshot, type SettingsFormShell, SettingsSecretField, type SettingsSecretSpec, SettingsValueField, type StyledComponent, Styling, type SuggestedKeys, Token, type TokenVars, type Tokens, type ValidationFailure, type WalkedField, apply, designTokens, dsw, failureOf, findReferences, formatReference, formatReferenceMention, inject, isLocalReference, markdownLabels, parseReference, parseReferenceToken, projectRoot, referenceMentions, rowRegistrations, index_d_exports as schemaForm, settingsNumberField, settingsTextField, styleOf, styled, styling, walkFields };
|