@byteluck-fe/model-driven-controls 7.1.0-beta.2 → 7.1.0-beta.4

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.
@@ -0,0 +1,49 @@
1
+ export type ControlTreePath = ReadonlyArray<string | number>;
2
+ /**
3
+ * 保存态与构造态控件共有的最小结构。
4
+ *
5
+ * 历史保存模型可能只有 `control_type`,构造态则通常使用 `controlType`;遍历只依赖
6
+ * `type` 与 `props`,避免为了读取纯 JSON 控件树加载 Designer、Vue 或 DOM。
7
+ */
8
+ export interface ControlTreeNode {
9
+ readonly type: string;
10
+ readonly props: Readonly<Record<string, unknown>>;
11
+ readonly children?: unknown;
12
+ readonly [key: string]: unknown;
13
+ }
14
+ export interface ControlTreeVisit {
15
+ node: ControlTreeNode;
16
+ path: ControlTreePath;
17
+ parent?: ControlTreeNode;
18
+ source: 'root' | 'children' | 'nested-prop';
19
+ nestedPropKey?: string;
20
+ }
21
+ export interface ControlTreeTraversalOptions {
22
+ /**
23
+ * 宿主额外确认会保存控件节点的 props 槽位。默认槽位始终保留,不能由调用方覆盖。
24
+ */
25
+ additionalNestedPropKeys?: readonly string[];
26
+ }
27
+ export type ControlTreeVisitor = (visit: ControlTreeVisit) => void;
28
+ /**
29
+ * 当前公共模型中已确认的 props 嵌套控件槽位。footers 仍存在于历史列表 Schema。
30
+ */
31
+ export declare const CONTROL_TREE_NESTED_PROP_KEYS: readonly ["headers", "footers"];
32
+ /**
33
+ * 只要求保存态与构造态共有字段;不要求 id/controlType,兼容待诊断的历史节点。
34
+ */
35
+ export declare function isControlTreeNode(value: unknown): value is ControlTreeNode;
36
+ /**
37
+ * 以前序稳定顺序遍历一个控件或控件数组。visitor 只接收只读视图,本函数不修改输入。
38
+ */
39
+ export declare function visitControlTree(value: unknown, visitor: ControlTreeVisitor, options?: ControlTreeTraversalOptions): void;
40
+ /** 返回稳定顺序的节点与路径,不复制页面 JSON 或 props。 */
41
+ export declare function collectControlTreeNodes(value: unknown, options?: ControlTreeTraversalOptions): ControlTreeVisit[];
42
+ /**
43
+ * 为整棵树补齐 catalog 已核实的 Runtime 缺失属性语义。
44
+ *
45
+ * - 缺失与 own-property `undefined` 使用 absent Runtime 值;`null` 和其它显式值保留。
46
+ * - 结果使用 catalog 公共构造属性名,适合实例化兼容,不是持久化 Schema 升级。
47
+ * - 未变化时保留原引用;变化时只复制命中节点及其祖先,不修改输入对象。
48
+ */
49
+ export declare function applyRuntimeAbsentDefaultsToControlTree<T>(value: T, options?: ControlTreeTraversalOptions): T;
@@ -1,2 +1,3 @@
1
1
  export * from './types';
2
2
  export * from './query';
3
+ export * from './control-tree';
@@ -1,4 +1,5 @@
1
- import { ControlCatalogInfo, ControlDefinition, ControlLocaleMessageFact, ControlSavedPropertyFact, ControlSettingFact } from './types';
1
+ import { ControlAuthoringFacts, ControlAuthoringPropertyFact, ControlCatalogInfo, ControlDefinition, ControlLocaleMessageFact, ResolvedControlSavedPropertyValue, ControlSavedPropertyFact, ControlSettingFact } from './types';
2
+ import { JsonObject } from '@byteluck-fe/model-driven-core/contracts';
2
3
  /** 返回独立副本,避免调用方污染进程内共享 catalog。 */
3
4
  export declare function getControlDefinition(type: string): ControlDefinition | undefined;
4
5
  /** 控件列表按 type 稳定排序,生成器与运行时查询顺序保持一致。 */
@@ -15,6 +16,31 @@ export declare function getControlSettingFacts(type: string): ControlSettingFact
15
16
  * propertyNameMap 与 defaultProps,才能作为控件切换时的能力证据。
16
17
  */
17
18
  export declare function getControlSavedPropertyFact(type: string, savedPropertyKey: string): ControlSavedPropertyFact | undefined;
19
+ /**
20
+ * 按保存键返回单个紧凑 authoring 事实;不存在或未被真实默认模型物化时失败关闭。
21
+ */
22
+ export declare function getControlAuthoringPropertyFact(type: string, savedPropertyKey: string): ControlAuthoringPropertyFact | undefined;
23
+ /**
24
+ * 返回一个控件的紧凑 authoring 事实,属性按保存键稳定排序;不复制完整 catalog。
25
+ */
26
+ export declare function getControlAuthoringFacts(type: string): ControlAuthoringFacts | undefined;
27
+ /**
28
+ * 解析一个保存属性的有效值,仅在 catalog 已登记历史缺失语义时补值。
29
+ *
30
+ * `null` 是显式 JSON 值,不能与缺失/undefined 混为一谈。调用方可传 camelCase
31
+ * 构造态或 snake_case 保存态 props,返回值始终指出公共构造属性名。
32
+ */
33
+ export declare function resolveControlSavedPropertyValue(input: {
34
+ controlType: string;
35
+ savedPropertyKey: string;
36
+ props: JsonObject;
37
+ }): ResolvedControlSavedPropertyValue | undefined;
38
+ /**
39
+ * 为 Designer 等构造态消费者补齐 Runtime 已核实的历史缺失语义。
40
+ *
41
+ * 未命中时保留原对象引用;命中时只浅拷贝 props 并写入公共属性名,不修改保存态原对象。
42
+ */
43
+ export declare function applyControlRuntimeAbsentDefaults(controlType: string, props: JsonObject): JsonObject;
18
44
  /** headless 按稳定 key 窄查消息事实,避免复制整份 catalog。 */
19
45
  export declare function getControlLocaleMessageFact(key: string): ControlLocaleMessageFact | undefined;
20
46
  export declare function getControlCatalogInfo(): ControlCatalogInfo;
@@ -1,5 +1,5 @@
1
1
  import { ControlCatalogSchemaVersion, JsonObject, JsonValue, HeadlessControlNode, ModelDrivenBaseControlType } from '@byteluck-fe/model-driven-core/contracts';
2
- export type ControlCatalogValueType = 'array' | 'boolean' | 'integer' | 'number' | 'object' | 'string';
2
+ export type ControlCatalogValueType = 'array' | 'boolean' | 'integer' | 'null' | 'number' | 'object' | 'string';
3
3
  export interface ControlSettingFact {
4
4
  controlType: string;
5
5
  propertyKey: string;
@@ -16,11 +16,62 @@ export interface ControlSettingFact {
16
16
  * 才会产生此事实。它只证明目标控件支持该保存属性,不自动授权跨控件继承或任意写入。
17
17
  */
18
18
  export interface ControlSavedPropertyFact {
19
+ /** 新建控件时由真实 Designer 工厂物化的默认值。 */
19
20
  controlType: string;
20
21
  defaultValue: JsonValue;
22
+ /**
23
+ * 历史保存态缺少该属性时,当前 Runtime 实际采用的值。
24
+ *
25
+ * 该字段只描述已经核实的兼容语义;未登记时调用方不得猜测或套用创建默认值。
26
+ */
27
+ absentRuntimeValue?: JsonValue;
21
28
  propertyKey: string;
22
29
  savedPropertyKey: string;
23
30
  }
31
+ export type ControlAuthoringConstraintCompleteness = 'complete' | 'top-level';
32
+ export type ControlAuthoringAbsentRuntimeValueFact = {
33
+ known: false;
34
+ } | {
35
+ known: true;
36
+ value: JsonValue;
37
+ };
38
+ /**
39
+ * 单个保存属性的紧凑 authoring 事实。
40
+ *
41
+ * 事实只证明目标控件真实物化了该保存属性;宿主仍必须通过自己的版本化策略准入写入。
42
+ * createDefaultValue 与 absentRuntimeValue 分别描述“新建”与“历史缺失”语义,不能互换。
43
+ */
44
+ export interface ControlAuthoringPropertyFact {
45
+ controlType: string;
46
+ propertyKey: string;
47
+ savedPropertyKey: string;
48
+ createDefaultValue: JsonValue;
49
+ absentRuntimeValue: ControlAuthoringAbsentRuntimeValueFact;
50
+ valueTypes?: ControlCatalogValueType[];
51
+ /** Designer setting/schema 提供的候选提示;未声明完整性,不能作为穷举值域拒绝输入。 */
52
+ optionHints?: JsonValue[];
53
+ min?: number;
54
+ max?: number;
55
+ constraintCompleteness?: ControlAuthoringConstraintCompleteness;
56
+ /** 该属性是否出现在当前 Designer setting 可见面;false 不等于禁止,由宿主策略决定。 */
57
+ settingExposed: boolean;
58
+ /** 显式构造是否能由 headless 工厂完整表达;保存态 Patch 不因此自动获得授权。 */
59
+ explicitConstructionSupported: boolean;
60
+ }
61
+ /** 单控件窄投影,不包含 defaultSchema、完整 propsSchema、settings 或组件实现。 */
62
+ export interface ControlAuthoringFacts {
63
+ controlType: string;
64
+ baseType: ModelDrivenBaseControlType;
65
+ fieldType?: string;
66
+ catalogRevision: string;
67
+ properties: ControlAuthoringPropertyFact[];
68
+ }
69
+ export interface ResolvedControlSavedPropertyValue {
70
+ propertyKey: string;
71
+ savedPropertyKey: string;
72
+ value: JsonValue;
73
+ source: 'explicit' | 'absent_runtime_value';
74
+ }
24
75
  /** 由 i18n_messages 发布生成的紧凑文案事实,不包含运行时 i18n 实例。 */
25
76
  export interface ControlLocaleMessageFact {
26
77
  key: string;
@@ -92,6 +143,8 @@ export interface ControlDefinition {
92
143
  /** 显式构造存在无法确定性表达的副作用,headless 对这些输入 fail-closed。 */
93
144
  unsupportedExplicitProps: string[];
94
145
  propertyNameMap: Record<string, string>;
146
+ /** 仅登记已核实的“保存属性缺失时 Runtime 如何解释”事实。 */
147
+ absentRuntimeDefaults?: Record<string, JsonValue>;
95
148
  settings: JsonObject[];
96
149
  settingFacts: ControlSettingFact[];
97
150
  eventKeys: string[];
@@ -246,6 +246,13 @@ interface SubTablePropertyInterface<Mode extends MODE | 'Schema', Control extend
246
246
  }
247
247
  declare class SubTableControlProperty<Mode extends MODE | 'Schema', Control extends object = ControlType<Mode>> extends ListControlProperty<Mode, Control> implements SubTablePropertyInterface<Mode, Control> {
248
248
  static readonly Rules: typeof SubTableControlPropertyRules;
249
+ /**
250
+ * 历史页面未保存 label_position 时,Runtime 一直按左右布局解释。
251
+ * 新建控件仍使用构造器中的 top;catalog 将两类语义分开发布,供 Designer 对齐历史运行态。
252
+ */
253
+ static readonly catalogAbsentRuntimeDefaults: {
254
+ readonly labelPosition: "left";
255
+ };
249
256
  static readonly RuntimeRules: typeof SubtableControlRuntimeRules;
250
257
  /**
251
258
  * 标题
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@byteluck-fe/model-driven-controls",
3
- "version": "7.1.0-beta.2",
3
+ "version": "7.1.0-beta.4",
4
4
  "description": "> TODO: description",
5
5
  "author": "郝晨光 <2293885211@qq.com>",
6
6
  "homepage": "",
@@ -49,10 +49,10 @@
49
49
  "postpublish": "node ../../scripts/postpublish.js"
50
50
  },
51
51
  "dependencies": {
52
- "@byteluck-fe/model-driven-core": "7.1.0-beta.2",
53
- "@byteluck-fe/model-driven-settings": "7.1.0-beta.2",
54
- "@byteluck-fe/model-driven-shared": "7.1.0-beta.2",
52
+ "@byteluck-fe/model-driven-core": "7.1.0-beta.4",
53
+ "@byteluck-fe/model-driven-settings": "7.1.0-beta.4",
54
+ "@byteluck-fe/model-driven-shared": "7.1.0-beta.4",
55
55
  "async-validator": "3.5.1"
56
56
  },
57
- "gitHead": "68b8a947f7a0bc1b0e4ec68a71aafac5e0e7cd37"
57
+ "gitHead": "82847b31dd60becd6a77ed5d831c12f57b3dc7aa"
58
58
  }