soma-core 1.4.0 → 1.4.2
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 +1 -1
- package/core/build/blocks/block-compile.ts +31 -2
- package/core/build/blocks/block-container.ts +2 -11
- package/core/build/compiler/page-declaration-compiler.ts +30 -2
- package/core/build/compiler/soma-precompile.js +2053 -23
- package/core/build/component/component-graph.ts +208 -0
- package/core/build/component/package-loader.ts +32 -0
- package/core/build/eject/component-eject.ts +473 -0
- package/core/build/eject/component-upgrade.ts +359 -0
- package/core/build/layout/constraint-solver.ts +235 -0
- package/core/build/layout/css-emitter.ts +116 -0
- package/core/build/layout/page-layout.ts +85 -0
- package/core/build/pack/pack-init.ts +270 -0
- package/core/client/base/SomaHttpClient.ts +34 -1
- package/core/client/base/SomaPageRootBase.ts +61 -0
- package/core/client/component/ai-catalog.ts +121 -4
- package/core/client/component/component-defaults.ts +100 -0
- package/core/client/component/component-definition.types.ts +39 -0
- package/core/client/component/component-manager.ts +79 -4
- package/core/client/component/component-pack.ts +126 -2
- package/core/client/component/keyboard-matrix.ts +144 -0
- package/core/client/component/pack-styles.ts +59 -1
- package/core/client/component/style-features.ts +131 -0
- package/core/client/component/theme-component-tokens.ts +83 -0
- package/core/client/component/verify-pack.ts +120 -1
- package/core/client/container/SomaContainerAdapter.ts +6 -2
- package/core/client/data/data-object-resolver.ts +407 -4
- package/core/client/data/reaction-engine.ts +176 -0
- package/core/client/data/window-engine.ts +477 -0
- package/core/client/engine/event-engine.ts +98 -0
- package/core/client/engine/soma-bootstrap.ts +265 -5
- package/core/client/engine/step-runner.ts +134 -0
- package/core/client/infra/http/SomaHttpService.ts +2 -2
- package/core/client/parser/blocks/page-parser.ts +15 -1
- package/core/client/parser/blocks/use-parser.ts +5 -12
- package/core/client/parser/data-config-parser.ts +316 -8
- package/core/client/parser/duration.ts +16 -0
- package/core/client/parser/layout-parser.ts +157 -0
- package/core/client/parser/page-state-parser.ts +166 -0
- package/core/client/parser/pipeline-parser.ts +76 -1
- package/core/client/parser/reaction-parser.ts +459 -0
- package/core/client/parser/reaction-sugar.ts +47 -0
- package/core/client/parser/step-parser.ts +359 -0
- package/core/client/parser/ui-config-parser.ts +59 -0
- package/core/client/parser/window-parser.ts +294 -0
- package/core/client/theme/theme-engine.ts +102 -2
- package/core/index.ts +184 -0
- package/core/shared/block-errors.ts +11 -0
- package/core/shared/calc/coerce.ts +29 -0
- package/core/shared/calc/errors.ts +43 -0
- package/core/shared/calc/evaluator.ts +101 -0
- package/core/shared/calc/index.ts +12 -0
- package/core/shared/calc/lexer.ts +194 -0
- package/core/shared/calc/parser.ts +204 -0
- package/core/shared/calc/typer.ts +184 -0
- package/core/shared/component/derive-sample.ts +105 -0
- package/core/shared/component/field-lines.ts +473 -0
- package/core/shared/path-algebra.ts +169 -0
- package/core/shared/predicates/index.ts +527 -0
- package/core/shared/types/component-contract.types.ts +151 -9
- package/core/shared/types/data-config.types.ts +120 -1
- package/core/shared/types/domain.types.ts +13 -0
- package/core/shared/types/event.types.ts +22 -2
- package/core/shared/types/layout-constraint.types.ts +73 -0
- package/core/shared/types/page-state.types.ts +60 -0
- package/core/shared/types/reaction.types.ts +144 -0
- package/core/shared/types/step.types.ts +91 -0
- package/core/shared/types/ui-config.types.ts +18 -0
- package/core/shared/types/window.types.ts +177 -0
- package/dist/cli/soma.js +13 -1
- package/dist/core/index.cjs +5529 -631
- package/dist/types/build/blocks/block-container.d.ts +1 -6
- package/dist/types/build/compiler/page-declaration-compiler.d.ts +2 -0
- package/dist/types/build/component/component-graph.d.ts +85 -0
- package/dist/types/build/eject/component-eject.d.ts +121 -0
- package/dist/types/build/eject/component-upgrade.d.ts +43 -0
- package/dist/types/build/layout/constraint-solver.d.ts +36 -0
- package/dist/types/build/layout/css-emitter.d.ts +18 -0
- package/dist/types/build/layout/page-layout.d.ts +24 -0
- package/dist/types/build/pack/pack-init.d.ts +8 -0
- package/dist/types/client/base/SomaHttpClient.d.ts +8 -0
- package/dist/types/client/base/SomaPageRootBase.d.ts +28 -0
- package/dist/types/client/component/ai-catalog.d.ts +33 -1
- package/dist/types/client/component/component-defaults.d.ts +15 -0
- package/dist/types/client/component/component-definition.types.d.ts +38 -0
- package/dist/types/client/component/component-manager.d.ts +36 -0
- package/dist/types/client/component/component-pack.d.ts +32 -2
- package/dist/types/client/component/keyboard-matrix.d.ts +24 -0
- package/dist/types/client/component/pack-styles.d.ts +21 -0
- package/dist/types/client/component/style-features.d.ts +26 -0
- package/dist/types/client/component/theme-component-tokens.d.ts +14 -0
- package/dist/types/client/component/verify-pack.d.ts +10 -0
- package/dist/types/client/data/data-object-resolver.d.ts +106 -1
- package/dist/types/client/data/reaction-engine.d.ts +21 -0
- package/dist/types/client/data/window-engine.d.ts +27 -0
- package/dist/types/client/engine/event-engine.d.ts +15 -0
- package/dist/types/client/engine/soma-bootstrap.d.ts +70 -0
- package/dist/types/client/engine/step-runner.d.ts +24 -0
- package/dist/types/client/parser/blocks/use-parser.d.ts +2 -2
- package/dist/types/client/parser/duration.d.ts +1 -0
- package/dist/types/client/parser/layout-parser.d.ts +9 -0
- package/dist/types/client/parser/page-state-parser.d.ts +32 -0
- package/dist/types/client/parser/reaction-parser.d.ts +16 -0
- package/dist/types/client/parser/reaction-sugar.d.ts +13 -0
- package/dist/types/client/parser/step-parser.d.ts +23 -0
- package/dist/types/client/parser/ui-config-parser.d.ts +5 -0
- package/dist/types/client/parser/window-parser.d.ts +25 -0
- package/dist/types/client/theme/theme-engine.d.ts +26 -0
- package/dist/types/index.d.ts +35 -2
- package/dist/types/shared/block-errors.d.ts +5 -0
- package/dist/types/shared/calc/coerce.d.ts +4 -0
- package/dist/types/shared/calc/errors.d.ts +14 -0
- package/dist/types/shared/calc/evaluator.d.ts +2 -0
- package/dist/types/shared/calc/index.d.ts +6 -0
- package/dist/types/shared/calc/lexer.d.ts +20 -0
- package/dist/types/shared/calc/parser.d.ts +49 -0
- package/dist/types/shared/calc/typer.d.ts +16 -0
- package/dist/types/shared/component/derive-sample.d.ts +23 -0
- package/dist/types/shared/component/field-lines.d.ts +19 -0
- package/dist/types/shared/path-algebra.d.ts +56 -0
- package/dist/types/shared/predicates/index.d.ts +79 -0
- package/dist/types/shared/types/component-contract.types.d.ts +134 -6
- package/dist/types/shared/types/data-config.types.d.ts +115 -1
- package/dist/types/shared/types/domain.types.d.ts +12 -0
- package/dist/types/shared/types/event.types.d.ts +8 -2
- package/dist/types/shared/types/layout-constraint.types.d.ts +52 -0
- package/dist/types/shared/types/page-state.types.d.ts +49 -0
- package/dist/types/shared/types/reaction.types.d.ts +115 -0
- package/dist/types/shared/types/step.types.d.ts +76 -0
- package/dist/types/shared/types/ui-config.types.d.ts +18 -0
- package/dist/types/shared/types/window.types.d.ts +171 -0
- package/package.json +3 -2
|
@@ -11,6 +11,20 @@ export interface SomaComponentPackStyles {
|
|
|
11
11
|
deps?: Record<string, string[]>;
|
|
12
12
|
/** 包级基座 CSS(恒定注入;克制使用——它是每个页面首屏都要付的钱) */
|
|
13
13
|
base?: string;
|
|
14
|
+
/**
|
|
15
|
+
* 样式补丁(REQ-009 M-4):给**别的包**的组件追加 CSS。
|
|
16
|
+
*
|
|
17
|
+
* 解决的是「官方组件 90% 合适、改 10%」——此前这类诉求只有整组件覆盖一条路,
|
|
18
|
+
* 为了挪一处间距就要接手整个组件的维护。补丁在目标组件分片与其特性分片**之后**注入。
|
|
19
|
+
*
|
|
20
|
+
* 四条硬规矩(compose 期判定,见 collectPatches):
|
|
21
|
+
* ① 目标必须属于别的包(本包组件直接改分片,不需要补丁);
|
|
22
|
+
* ② 每条规则的首选择器必须以 `.soma-<组件名 kebab>` 开头——
|
|
23
|
+
* 补丁只能改目标组件内部,不能顺手改页面;
|
|
24
|
+
* ③ ≤ 1,200 字节(超了说明该 eject 或该覆盖,不该是补丁);
|
|
25
|
+
* ④ 能用组件令牌调的(圆角/高度/颜色)走令牌,不给补丁。
|
|
26
|
+
*/
|
|
27
|
+
patches?: Record<string, string>;
|
|
14
28
|
}
|
|
15
29
|
export interface SomaComponentPack {
|
|
16
30
|
/** 包标识(小写字母/数字/连字符) */
|
|
@@ -70,8 +84,8 @@ export interface ComposedComponentPacks {
|
|
|
70
84
|
components: Record<string, SomaComponentDefinition>;
|
|
71
85
|
/** 组件名 → 来源包名。排障、目录展示、闸门报错都用它 */
|
|
72
86
|
provenance: Record<string, string>;
|
|
73
|
-
/** 合成后的按需装配样式(键已按包做过冲突检查) */
|
|
74
|
-
styles: Required<Omit<SomaComponentPackStyles, 'base'>> & {
|
|
87
|
+
/** 合成后的按需装配样式(键已按包做过冲突检查)。补丁不在这里,它有自己的顶层字段 */
|
|
88
|
+
styles: Required<Omit<SomaComponentPackStyles, 'base' | 'patches'>> & {
|
|
75
89
|
base: string[];
|
|
76
90
|
};
|
|
77
91
|
/** 参与合成的包(顺序保留;目录生成用) */
|
|
@@ -82,7 +96,15 @@ export interface ComposedComponentPacks {
|
|
|
82
96
|
shadowed: string[];
|
|
83
97
|
source: 'contract' | 'allowOverride';
|
|
84
98
|
}>;
|
|
99
|
+
/** 生效的样式补丁(M-4):谁给谁打了什么。目录条目据此标注「被 X 包打了补丁」 */
|
|
100
|
+
patches: Array<{
|
|
101
|
+
target: string;
|
|
102
|
+
patchedBy: string;
|
|
103
|
+
css: string;
|
|
104
|
+
}>;
|
|
85
105
|
}
|
|
106
|
+
/** 单条补丁的字节上限:超了说明该 eject 或该整包覆盖,不该是补丁 */
|
|
107
|
+
export declare const PACK_PATCH_BYTE_LIMIT = 1200;
|
|
86
108
|
/**
|
|
87
109
|
* 合成多个组件包。
|
|
88
110
|
*
|
|
@@ -90,6 +112,14 @@ export interface ComposedComponentPacks {
|
|
|
90
112
|
* 样式分片同理:两个包提供同名共享分片时也拦下——那通常意味着有人复制了别人的资产。
|
|
91
113
|
*/
|
|
92
114
|
export declare function composeComponentPacks(packs: readonly SomaComponentPack[], options?: ComposePacksOptions): ComposedComponentPacks;
|
|
115
|
+
/**
|
|
116
|
+
* 找出补丁里第一条不以目标组件根类开头的规则。
|
|
117
|
+
*
|
|
118
|
+
* 只做静态扫描(去注释 → 按顶层 `}` 切规则 → 取选择器列表),不解析完整 CSS:
|
|
119
|
+
* 目的是拦住"顺手改页面"这类越界,不是实现一个 CSS parser。
|
|
120
|
+
* `@media` / `@supports` 这类块级 at 规则递归进去看里面的规则。
|
|
121
|
+
*/
|
|
122
|
+
export declare function findStraySelector(css: string, target: string): string | null;
|
|
93
123
|
/**
|
|
94
124
|
* 生成带来源标注的组件目录。
|
|
95
125
|
*
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { SomaContractKeyboard } from '../../shared/types/component-contract.types';
|
|
2
|
+
/** 引擎能兑现的意图闭集;矩阵里的每个键都落在这里面 */
|
|
3
|
+
export declare const SOMA_KEYBOARD_INTENTS: readonly ["next", "previous", "left", "right", "first", "last", "page_next", "page_previous", "expand", "collapse", "activate", "toggle_select", "search"];
|
|
4
|
+
export type SomaKeyboardIntent = (typeof SOMA_KEYBOARD_INTENTS)[number];
|
|
5
|
+
export interface SomaKeyboardMatrixRow {
|
|
6
|
+
/** 触发这个意图的按键(`KeyboardEvent.key` 值);多个键同义时并列 */
|
|
7
|
+
keys: string[];
|
|
8
|
+
intent: SomaKeyboardIntent;
|
|
9
|
+
/** 给目录看的一句话 */
|
|
10
|
+
desc: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* 由契约推出矩阵。纯函数、无 DOM:目录构建(Node)与浏览器接线读同一份。
|
|
14
|
+
*
|
|
15
|
+
* `layout: none` 出空表——这是"我不接管键盘"的显式声明,不是缺省。
|
|
16
|
+
*/
|
|
17
|
+
export declare function deriveKeyboardMatrix(keyboard: SomaContractKeyboard): SomaKeyboardMatrixRow[];
|
|
18
|
+
/**
|
|
19
|
+
* 目录用的一行紧凑键盘表。
|
|
20
|
+
*
|
|
21
|
+
* 一行而不是一张表:目录会被压成裸文本喂给模型,且每个分片有字节预算;
|
|
22
|
+
* 键盘表是"查得到"的信息,不是"读一遍"的信息。
|
|
23
|
+
*/
|
|
24
|
+
export declare function renderKeyboardMatrixLine(keyboard: SomaContractKeyboard): string;
|
|
@@ -1,11 +1,25 @@
|
|
|
1
1
|
import type { SomaComponentDefinition } from './component-definition.types';
|
|
2
|
+
import type { SomaComponentContract } from '../../shared/types/component-contract.types';
|
|
2
3
|
import type { ComposedComponentPacks } from './component-pack';
|
|
4
|
+
/**
|
|
5
|
+
* 组件令牌规则(M-1):把契约声明的可调旋钮写成一条挂在组件根类上的规则。
|
|
6
|
+
*
|
|
7
|
+
* 为什么是规则不是内联样式:一个组件一条,与实例数无关;
|
|
8
|
+
* 且 `ThemeScope` 或主题 `components` 段写出的 `--soma-<comp>-*` 层级更高,
|
|
9
|
+
* 靠 CSS 级联天然覆盖,不需要引擎逐实例改写。
|
|
10
|
+
*/
|
|
11
|
+
export declare function renderComponentTokenRule(contract: SomaComponentContract): string;
|
|
3
12
|
export interface PackStyleOptions {
|
|
4
13
|
/** CSP nonce;宿主启用严格 CSP 时必须给 */
|
|
5
14
|
nonce?: string | null;
|
|
6
15
|
}
|
|
7
16
|
/** 测试用:清空注入记录(jsdom 之间不共享 document,但模块级 Set 会跨用例残留) */
|
|
8
17
|
export declare function resetPackStyleInjection(): void;
|
|
18
|
+
/**
|
|
19
|
+
* 幂等注入一段 CSS(组件分片、特性分片与页面级布局产物共用同一个入口)。
|
|
20
|
+
* 同一个 key 只落一张 <style>;热更新重复执行不会堆出十几张同样的样式表。
|
|
21
|
+
*/
|
|
22
|
+
export declare function injectStyleOnce(key: string, css: string, options: PackStyleOptions): void;
|
|
9
23
|
/**
|
|
10
24
|
* 给合成结果里的每个组件接上按需样式。
|
|
11
25
|
*
|
|
@@ -20,3 +34,10 @@ export declare function attachPackStyles(composed: ComposedComponentPacks, optio
|
|
|
20
34
|
* 这里按包分别盖戳,便于排查"这段全局样式是谁带来的"。
|
|
21
35
|
*/
|
|
22
36
|
export declare function ensurePackBaseStyles(composed: ComposedComponentPacks, options?: PackStyleOptions): void;
|
|
37
|
+
/**
|
|
38
|
+
* 注入一片特性分片(M-3)。由 component-manager 在 prop 首次为真值时调用。
|
|
39
|
+
*
|
|
40
|
+
* key 用 `feature:<组件>#<特性>`,与 `component:<组件>` 同一个 injected 集合,
|
|
41
|
+
* 所以「注入一次」的保证是同一套,不需要组件自己记账。
|
|
42
|
+
*/
|
|
43
|
+
export declare function injectStyleFeature(componentName: string, featureName: string, css: string, options?: PackStyleOptions): void;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { SomaComponentDefinition, SomaStyleFeatureWhen } from './component-definition.types';
|
|
2
|
+
import { type PackStyleOptions } from './pack-styles';
|
|
3
|
+
/**
|
|
4
|
+
* 真值门控:`true`、非空数组,或**非空字符串**。`0` / `''` / `[]` 一律不算启用。
|
|
5
|
+
*
|
|
6
|
+
* 字符串这一路是后补的:`detail_api` / `submit_api` 这类"声明了接口就要这段样式"的
|
|
7
|
+
* prop 是自治组件里最常见的开关形态——给了路径就意味着这段界面会出现。
|
|
8
|
+
* 不认它的话,这类特性只能退回"所有页面都付这笔钱",机制等于白建
|
|
9
|
+
* (与枚举门控当初的处境完全一样)。
|
|
10
|
+
*/
|
|
11
|
+
export declare function isFeatureActive(value: unknown): boolean;
|
|
12
|
+
/** 开关名(两种形态共用的取 prop 名) */
|
|
13
|
+
export declare function featurePropOf(when: SomaStyleFeatureWhen): string;
|
|
14
|
+
/** 按当前 props 判定某个特性是否启用 */
|
|
15
|
+
export declare function isFeatureEnabled(when: SomaStyleFeatureWhen, props: Record<string, unknown>): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* 装配期校验:`when` 必须指向契约里真实存在的 prop,且形态要对得上——
|
|
18
|
+
* 真值门控只认 boolean / array,按值门控只认 enum 且取值必须在枚举内。
|
|
19
|
+
* 返回问题清单(空数组 = 通过),由 bootstrap 汇总后抛。
|
|
20
|
+
*/
|
|
21
|
+
export declare function validateStyleFeatures(definition: SomaComponentDefinition): string[];
|
|
22
|
+
/**
|
|
23
|
+
* 按当前 props 注入该启用的特性分片。实例创建与每次 setProps 后调用。
|
|
24
|
+
* 注入是幂等的(pack-styles 的 injected 集合负责),所以这里不用自己记账。
|
|
25
|
+
*/
|
|
26
|
+
export declare function ensureStyleFeatures(definition: SomaComponentDefinition, props: Record<string, unknown>, options?: PackStyleOptions): void;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { SomaComponentDefinition } from './component-definition.types';
|
|
2
|
+
export declare class SomaThemeComponentTokenError extends Error {
|
|
3
|
+
constructor(message: string);
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* 校验主题输入的 `components` / `darkComponents` 段是否与契约对得上。
|
|
7
|
+
* Host 在调 `applyTheme` 之前调用;不给组件表时(纯预览场景)跳过。
|
|
8
|
+
*/
|
|
9
|
+
export declare function validateThemeComponentTokens(input: {
|
|
10
|
+
components?: Record<string, Record<string, string>>;
|
|
11
|
+
darkComponents?: Record<string, Record<string, string>>;
|
|
12
|
+
}, components: Record<string, SomaComponentDefinition>): void;
|
|
13
|
+
/** 契约自检:令牌键名格式 + default 必须引用语义令牌。返回问题清单 */
|
|
14
|
+
export declare function validateContractTokens(definition: SomaComponentDefinition): string[];
|
|
@@ -6,6 +6,16 @@ export interface VerifyPackOptions {
|
|
|
6
6
|
* 换肤与 RTL 的正确性没有任何自动保障。
|
|
7
7
|
*/
|
|
8
8
|
skipStyleChecks?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* 要求 solution 层组件带得出样张(REQ-012,默认开)。
|
|
11
|
+
*
|
|
12
|
+
* 没有示例值的业务组件在展示页上只有一个空壳,在视觉矩阵里量不出真实高度,
|
|
13
|
+
* 在 AI 那边只剩一句 desc——三处都不报错,所以要在这里拦。
|
|
14
|
+
* 存量组件用 samplePending 豁免,清单只减不增。
|
|
15
|
+
*/
|
|
16
|
+
requireSamples?: boolean;
|
|
17
|
+
/** 样张待补清单(组件名):只减不增 */
|
|
18
|
+
samplePending?: readonly string[];
|
|
9
19
|
}
|
|
10
20
|
/**
|
|
11
21
|
* 自检一个组件包,返回中文问题清单(空数组 = 通过)。
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { type SomaPipeRegistry } from '../pipes/pipe-registry';
|
|
2
|
-
import type { SomaDataConfig, SomaDataDicts } from '../../shared/types/data-config.types';
|
|
2
|
+
import type { SomaDataConfig, SomaDataDicts, SomaDataFieldConfig, SomaDataPort, SomaDataSubmitResult } from '../../shared/types/data-config.types';
|
|
3
|
+
import type { SomaReactionGraph } from '../../shared/types/reaction.types';
|
|
4
|
+
import type { SomaTransaction, SomaWindowHandle } from '../../shared/types/window.types';
|
|
5
|
+
import type { SomaNamedPredicates } from '../../shared/predicates';
|
|
3
6
|
/** 数据对象依赖成环(`$<对象>.<字段>` 引用构成环路,无法拓扑排序) */
|
|
4
7
|
export declare class SomaDataCycleError extends Error {
|
|
5
8
|
/** 环上的对象名列表 */
|
|
@@ -16,6 +19,10 @@ export interface SomaDataHttpLike {
|
|
|
16
19
|
get<T = unknown>(url: string, config?: {
|
|
17
20
|
params?: Record<string, string>;
|
|
18
21
|
}): Promise<T>;
|
|
22
|
+
/** 写通道(§8):不实现时 submit 抛「本 Host 的 http 不支持写」而不是静默失败 */
|
|
23
|
+
post?<T = unknown>(url: string, body?: unknown): Promise<T>;
|
|
24
|
+
put?<T = unknown>(url: string, body?: unknown): Promise<T>;
|
|
25
|
+
patch?<T = unknown>(url: string, body?: unknown): Promise<T>;
|
|
19
26
|
}
|
|
20
27
|
export interface SomaDataResolverOptions {
|
|
21
28
|
/** 依赖注入的 http 服务(后端接口是唯一数据边界) */
|
|
@@ -55,6 +62,71 @@ export declare class SomaDataObjectResolver {
|
|
|
55
62
|
* 对象按依赖 DAG 拓扑分层:同层对象(互不依赖)并发解析;成环抛 SomaDataCycleError。
|
|
56
63
|
*/
|
|
57
64
|
resolve(): Promise<SomaDataResolveResult>;
|
|
65
|
+
/** 已解析对象的只读视图(data 端口的 getObject) */
|
|
66
|
+
getObject(name: string): unknown;
|
|
67
|
+
/** 字段字典(data 端口的 getDict);无字典时返回空表而不是 undefined */
|
|
68
|
+
getDict(name: string): Record<string, SomaDataFieldConfig>;
|
|
69
|
+
/**
|
|
70
|
+
* 反应图与具名谓词表(REQ-010 S1b)。
|
|
71
|
+
* 图在**解析期**就建好了(拓扑序、反向索引、回溯表都在里面),这里只是把它交出去;
|
|
72
|
+
* 没声明 `reactions:` 的对象返回 null,组件据此走「无联动」的老路。
|
|
73
|
+
*/
|
|
74
|
+
/**
|
|
75
|
+
* 数据窗口(REQ-010 S2):声了 `window:` 段的对象才有,按对象名单例。
|
|
76
|
+
*
|
|
77
|
+
* 惰性创建而不是 `resolve()` 后统一建:一个声明了窗口的对象未必这一屏就在用它
|
|
78
|
+
* (同一份 `_data.yaml` 服务多个页面是常态),提前建会平白多发一轮取数。
|
|
79
|
+
* 对象 `reload` 时整个销毁——窗口缓存的是"按某组意图取回的行",
|
|
80
|
+
* 而 reload 的意思正是"那些行已经不作数了"。
|
|
81
|
+
*/
|
|
82
|
+
window(name: string): SomaWindowHandle | null;
|
|
83
|
+
/**
|
|
84
|
+
* 行主键:写通道的 `version` 位不是主键,所以不能拿它顶。
|
|
85
|
+
* 按约定取 `id`;字典里没有 `id` 时取声明序第一个字段——比报错好:
|
|
86
|
+
* 主键猜错的后果是选择态与编辑按错的键归组,而报错的后果是整张表打不开。
|
|
87
|
+
* 猜了就要说出来。
|
|
88
|
+
*/
|
|
89
|
+
private primaryKeyOf;
|
|
90
|
+
/** 事务提交(REQ-010 F-36):窗口把整批改动交给写通道,编排复用 submit 那一套 */
|
|
91
|
+
commit(name: string, tx: SomaTransaction): Promise<SomaDataSubmitResult>;
|
|
92
|
+
getReactions(name: string): {
|
|
93
|
+
graph: SomaReactionGraph;
|
|
94
|
+
named: SomaNamedPredicates;
|
|
95
|
+
} | null;
|
|
96
|
+
/**
|
|
97
|
+
* 提交一个数据对象(§8.6 全链)。
|
|
98
|
+
*
|
|
99
|
+
* 编排全部在这里,组件只做「收值 → 调它 → 渲染返回的 fieldErrors」:
|
|
100
|
+
* ① 按 permission 白名单剔除只读字段(version 乐观锁位是唯一显式例外);
|
|
101
|
+
* ② map 平面改名;
|
|
102
|
+
* ③ 选端点:显式 mode 优先,否则按对象当前是否已有主键值自动判定;
|
|
103
|
+
* ④ 调接口;
|
|
104
|
+
* ⑤ 失败时把后端的字段级错误**逆映射**回表单键(否则表单认不出那是自己的哪个字段);
|
|
105
|
+
* ⑥ 成功后按 reload 重取。
|
|
106
|
+
*
|
|
107
|
+
* 前端按 permission 过滤是 UX 与声明自洽,**不是安全边界**——
|
|
108
|
+
* 后端仍须按自身权限模型校验(数据对象层原则 2)。
|
|
109
|
+
*/
|
|
110
|
+
submit(name: string, model: Record<string, unknown>, mode?: 'create' | 'update'): Promise<SomaDataSubmitResult>;
|
|
111
|
+
/** 手动重取(data 端口的 reload);不给名字时重取全部 */
|
|
112
|
+
reload(names?: string[]): Promise<void>;
|
|
113
|
+
/**
|
|
114
|
+
* 自动判定 create / update:对象已有值(读通道取回过一条记录)即为更新。
|
|
115
|
+
* 显式 write_mode 永远优先——自动判定只是缺省,不是规则。
|
|
116
|
+
*/
|
|
117
|
+
private inferWriteMode;
|
|
118
|
+
/** 构造请求体:剔除只读字段 → map 改名 → 补乐观锁位 */
|
|
119
|
+
private buildRequestBody;
|
|
120
|
+
private methodOf;
|
|
121
|
+
private reloadAfterWrite;
|
|
122
|
+
/**
|
|
123
|
+
* 后端错误 → 表单可渲染的结果(§8.3)。
|
|
124
|
+
*
|
|
125
|
+
* 逆映射是关键的一步:后端按请求体键报错(`order_no`),
|
|
126
|
+
* 而表单只认自己的字段键(`orderNo`)。不逆映射的话错误会挂不上任何一个字段,
|
|
127
|
+
* 于是「提交失败」有文案却没有红框,用户不知道该改哪里。
|
|
128
|
+
*/
|
|
129
|
+
private mapSubmitError;
|
|
58
130
|
/** Kahn 分层拓扑排序:返回逐层对象名(每层内部无依赖,可并发);残留节点即环 */
|
|
59
131
|
private buildTopologicalLayers;
|
|
60
132
|
private resolveObject;
|
|
@@ -67,5 +139,38 @@ export declare class SomaDataObjectResolver {
|
|
|
67
139
|
private readQuery;
|
|
68
140
|
private readPage;
|
|
69
141
|
/** 按 "字段路径 | 管道链" 补派生字段(复用 pipe-registry 链式执行) */
|
|
142
|
+
/** 派生列 AST 缓存:对象名 → 字段名 → AST */
|
|
143
|
+
private readonly derivedAsts;
|
|
144
|
+
/** 数据窗口:对象名 → 窗口实例(惰性建,reload 时销毁) */
|
|
145
|
+
private readonly windows;
|
|
146
|
+
/** 窗口内容变化时通知宿主重渲(由 bootstrap 注入) */
|
|
147
|
+
private onWindowChange;
|
|
148
|
+
/** 由 bootstrap 接上:窗口自己的取数完成后要能推动页面渲染 */
|
|
149
|
+
setWindowChangeHandler(handler: () => void): void;
|
|
150
|
+
/**
|
|
151
|
+
* 取数收尾:先算派生列,再跑展示管道。
|
|
152
|
+
*
|
|
153
|
+
* 次序不能反:`calc` 产出的是带类型的值(能排序、能求和),`transform` 产出的是
|
|
154
|
+
* 给人看的串。先格式化再算式的话,`[金额] - [折扣]` 拿到的是 "¥1,000.00" 这样的串。
|
|
155
|
+
*/
|
|
156
|
+
private finalize;
|
|
70
157
|
private applyTransform;
|
|
158
|
+
/**
|
|
159
|
+
* 派生列求值(REQ-010 F-10):把 `fields.<x>.calc` 算出来挂到值上。
|
|
160
|
+
*
|
|
161
|
+
* 与 `transform:` 的分工:`transform` 是**展示管道**(金额加千分位、日期换格式),
|
|
162
|
+
* 产出的是字符串;`calc` 是**算式**,产出的是带类型的值,能参与排序、聚合与比较。
|
|
163
|
+
* 混成一个的话,「利润」既是一个能求和的数、又是一个格式化过的串,取决于谁先跑。
|
|
164
|
+
*
|
|
165
|
+
* 只作用于普通对象与对象数组两种形状——其余形状(标量、嵌套聚合)原样返回:
|
|
166
|
+
* 猜一个结构去写值,写错的地方不会报错,只会多出一个没人认识的键。
|
|
167
|
+
*/
|
|
168
|
+
private applyDerived;
|
|
71
169
|
}
|
|
170
|
+
/**
|
|
171
|
+
* 把解析器包成注入给自治组件的 data 端口(§8.4)。
|
|
172
|
+
*
|
|
173
|
+
* 为什么是包一层而不是直接注入解析器:解析器还有 resolve / 内部拓扑等大量能力,
|
|
174
|
+
* 组件不该看得见。端口是刻意收窄的四个方法——读态、字典、提交、重取。
|
|
175
|
+
*/
|
|
176
|
+
export declare function createSomaDataPort(resolver: SomaDataObjectResolver): SomaDataPort;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { SomaReactionGraph, SomaReactionPhase, SomaReactionResult } from '../../shared/types/reaction.types';
|
|
2
|
+
import { type SomaNamedPredicates } from '../../shared/predicates';
|
|
3
|
+
export interface ReactionRunInput {
|
|
4
|
+
graph: SomaReactionGraph;
|
|
5
|
+
/** 当前值(不会被修改) */
|
|
6
|
+
values: Record<string, unknown>;
|
|
7
|
+
/** 本次变更的字段;空数组表示「全量重算」(挂载时用) */
|
|
8
|
+
changed?: readonly string[];
|
|
9
|
+
phase?: SomaReactionPhase;
|
|
10
|
+
named?: SomaNamedPredicates;
|
|
11
|
+
/** `on: field_validate_*` 的判定面:当前校验失败的字段 */
|
|
12
|
+
failedFields?: readonly string[];
|
|
13
|
+
}
|
|
14
|
+
export declare function runReactions(input: ReactionRunInput): SomaReactionResult;
|
|
15
|
+
/**
|
|
16
|
+
* 打印一条字段的回溯链——诊断面。
|
|
17
|
+
*
|
|
18
|
+
* amis 的 `${x}` 只能沿运行时数据链向上找,给不出这个;这是「可静态回溯」
|
|
19
|
+
* 在人能看见的那一端的落点。
|
|
20
|
+
*/
|
|
21
|
+
export declare function explainField(graph: SomaReactionGraph, field: string): string;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { SomaWindowConfig, SomaWindowHandle, SomaWindowResponse, SomaTransaction } from '../../shared/types/window.types';
|
|
2
|
+
import type { SomaDataSubmitResult } from '../../shared/types/data-config.types';
|
|
3
|
+
/**
|
|
4
|
+
* 引擎只要 GET;写走宿主注入的 commit(写通道的编排不在这里复制一份)。
|
|
5
|
+
*
|
|
6
|
+
* 返回类型写死成窗口响应而不是泛型 `<T>`:引擎知道自己要什么,而泛型只会把
|
|
7
|
+
* 「这个 http 桩返回的形状对不对」这个判断推给每一个调用方(和每一个测试桩)。
|
|
8
|
+
* `SomaDataHttpLike` 的泛型 get 仍然结构兼容它。
|
|
9
|
+
*/
|
|
10
|
+
export interface SomaWindowHttpLike {
|
|
11
|
+
get(url: string, config?: {
|
|
12
|
+
params?: Record<string, string>;
|
|
13
|
+
}): Promise<SomaWindowResponse>;
|
|
14
|
+
}
|
|
15
|
+
export interface SomaWindowDeps {
|
|
16
|
+
http: SomaWindowHttpLike;
|
|
17
|
+
api: string;
|
|
18
|
+
/** 行主键字段名:选择态与编辑双通道都按它认行 */
|
|
19
|
+
idField: string;
|
|
20
|
+
/** 任何 rows / total / loading / selection 变化都会调一次(由解析器转成页面 render) */
|
|
21
|
+
onChange?: () => void;
|
|
22
|
+
/** 写通道:事务体交给它,引擎不重复实现提交编排 */
|
|
23
|
+
commit?: (tx: SomaTransaction) => Promise<SomaDataSubmitResult>;
|
|
24
|
+
/** 定时器注入(测试用;缺省用全局) */
|
|
25
|
+
now?: () => number;
|
|
26
|
+
}
|
|
27
|
+
export declare function createWindow(spec: SomaWindowConfig, deps: SomaWindowDeps): SomaWindowHandle;
|
|
@@ -62,9 +62,24 @@ export declare class SomaEventEngine<TContext extends Record<string, unknown> =
|
|
|
62
62
|
execute(config: SomaCompiledEvent, element: HTMLElement, originalEvent: Event): Promise<void>;
|
|
63
63
|
destroy(): void;
|
|
64
64
|
private executeNow;
|
|
65
|
+
/**
|
|
66
|
+
* 编排里的一步:执行一条已解析的管道,返回 handler 的返回值(进输出槽)。
|
|
67
|
+
*
|
|
68
|
+
* 复用与单管道同一条执行路径的**语义**,但不复用 `executeNow`——那里有确认框、
|
|
69
|
+
* 键盘修饰符、诊断打点、事务开合,都是"一次交互"级别的事情。一步不是一次交互。
|
|
70
|
+
*/
|
|
71
|
+
private dispatchPipeline;
|
|
72
|
+
/** 具名动作注册表(AO-3):由 bootstrap 注入 */
|
|
73
|
+
private namedActions;
|
|
74
|
+
setNamedActions(actions: Record<string, (payload: Record<string, unknown>) => Promise<unknown> | unknown>): void;
|
|
65
75
|
private getContext;
|
|
66
76
|
private preCheck;
|
|
67
77
|
private postAction;
|
|
68
78
|
private handleInteraction;
|
|
79
|
+
/**
|
|
80
|
+
* 原生可聚焦:这几种标签不需要补 tabindex。
|
|
81
|
+
* 补了也不算错(tabindex="-1" 不改变它们的 Tab 序),但改动 DOM 属性这件事
|
|
82
|
+
* 能不做就不做——它会出现在别人的 diff 与快照里。
|
|
83
|
+
*/
|
|
69
84
|
private resolveFunction;
|
|
70
85
|
}
|
|
@@ -17,6 +17,7 @@ import type { SomaStyleBinder } from './style-binder';
|
|
|
17
17
|
import type { SomaDataConfig, SomaDataDicts } from '../../shared/types/data-config.types';
|
|
18
18
|
import type { WatchCallback, WatcherOptions } from '../../shared/types/watcher.types';
|
|
19
19
|
import type { SomaComponentDefinition } from '../component/component-definition.types';
|
|
20
|
+
import { type SomaComponentDefaults } from '../component/component-defaults';
|
|
20
21
|
import { type SomaPipeFn } from '../pipes/pipe-registry';
|
|
21
22
|
import { type SomaErrorEvent, type SomaPageIdentity } from '../observability/error-reporter';
|
|
22
23
|
export interface SomaPageAssets {
|
|
@@ -87,6 +88,26 @@ export interface SomaBootstrapOptions {
|
|
|
87
88
|
* 对该 Host 的所有页面生效;页面资产 components 同名时覆盖 Host 级定义。
|
|
88
89
|
*/
|
|
89
90
|
components?: Record<string, SomaComponentDefinition>;
|
|
91
|
+
/**
|
|
92
|
+
* Host 级默认 props(REQ-009 M-2):组件名 → { prop: 默认值 }。
|
|
93
|
+
* 「本站所有表格都要 size: sm」这类站点级口径的落点,
|
|
94
|
+
* 优先级为「页面声明 > 本表 > 契约 default」。
|
|
95
|
+
* 键与值在 bootstrap 期按契约逐条校验,未知组件 / 未知 prop / 枚举外值一律抛。
|
|
96
|
+
*/
|
|
97
|
+
componentDefaults?: SomaComponentDefaults;
|
|
98
|
+
/** 组件样式注入的 CSP nonce(透传给特性分片注入,M-3) */
|
|
99
|
+
componentStyleNonce?: string | null;
|
|
100
|
+
/**
|
|
101
|
+
* 具名动作注册表(REQ-010 F-20 / AO-3):`{ 名字: 实现 }`。
|
|
102
|
+
*
|
|
103
|
+
* 声明里写 `do: ACTION | exportOrders`,实现登记在这里。这是 amis `custom(script)`
|
|
104
|
+
* 的替代——同样能接任意 Host 逻辑,但它**有名字、要注册、未注册即在 bootstrap 期抛**,
|
|
105
|
+
* 声明层因此仍然零脚本、CSP 仍然不需要 unsafe-eval。
|
|
106
|
+
*
|
|
107
|
+
* 装配期会把页面里出现的每一个 `ACTION | <名字>` 对着这张表查一遍:
|
|
108
|
+
* 对不上就抛。留到运行期才发现的话,那是用户点了按钮之后什么都没发生。
|
|
109
|
+
*/
|
|
110
|
+
actions?: Record<string, (payload: Record<string, unknown>) => Promise<unknown> | unknown>;
|
|
90
111
|
/**
|
|
91
112
|
* Host 自定义格式化管道(模块 7 U4):{ 管道名: 纯函数 },与内置管道合并。
|
|
92
113
|
* 内置:money / tpl / date / percent / plural。
|
|
@@ -144,6 +165,13 @@ export declare class SomaBootstrap {
|
|
|
144
165
|
private domainInstance;
|
|
145
166
|
private componentManager;
|
|
146
167
|
private hostComponents;
|
|
168
|
+
private componentDefaults?;
|
|
169
|
+
/**
|
|
170
|
+
* 当前页的数据对象解析器(写通道 §8.4 的真身)。
|
|
171
|
+
* 它在 loadDataObjects 里被换掉——每次重取都是一个新解析器。
|
|
172
|
+
*/
|
|
173
|
+
private dataResolver;
|
|
174
|
+
private componentStyleNonce?;
|
|
147
175
|
private pipeRegistry;
|
|
148
176
|
/** 阶梯词汇表:Host 级注册,对该 Host 全部页面生效;未注册时恒为 undefined */
|
|
149
177
|
private readonly adaptiveVocabulary?;
|
|
@@ -162,6 +190,8 @@ export declare class SomaBootstrap {
|
|
|
162
190
|
private readonly errorReporting;
|
|
163
191
|
/** 错误采集句柄:mount 时装、cleanup 时摘,生命周期与页面严格同寿 */
|
|
164
192
|
private errorReporter;
|
|
193
|
+
/** 具名动作注册表(AO-3);构造期定下,运行中不换 */
|
|
194
|
+
private readonly namedActions;
|
|
165
195
|
constructor(options?: SomaBootstrapOptions);
|
|
166
196
|
mount(container: HTMLElement, assets: SomaPageAssets): Promise<void>;
|
|
167
197
|
hotSwap(overrides: Partial<SomaPageAssets>, options?: {
|
|
@@ -226,6 +256,46 @@ export declare class SomaBootstrap {
|
|
|
226
256
|
* 主题是引擎内建路径,不是 bootstrap 可注册能力。
|
|
227
257
|
*/
|
|
228
258
|
private applyHostTheme;
|
|
259
|
+
/**
|
|
260
|
+
* 组件可见的服务表:页面运行时服务 + data 端口(M-5)。
|
|
261
|
+
*
|
|
262
|
+
* data 不住在 `_services` 里,因为它不是 Domain 的能力而是**数据对象层的能力**——
|
|
263
|
+
* Domain 用 `this.data.*` 读、用 `_reloadData` 重取,不需要这个端口。
|
|
264
|
+
* 它只为自治组件而生,并且仍受 services 白名单管辖(组件不声明就拿不到)。
|
|
265
|
+
*/
|
|
266
|
+
private buildComponentServices;
|
|
267
|
+
/**
|
|
268
|
+
* 页面态装配(REQ-010 F-37)。
|
|
269
|
+
*
|
|
270
|
+
* 三个来源按优先级取:**URL > initial_state > 空**。
|
|
271
|
+
* URL 在最前是因为它是"用户此刻明确要求看到的那一屏"(分享链接、书签、回退按钮),
|
|
272
|
+
* 而 `initial_state` 只是作者写的缺省。反过来的话,分享链接打开后会被缺省覆盖,
|
|
273
|
+
* 而那正是分享链接唯一的用途。
|
|
274
|
+
*
|
|
275
|
+
* 版本对不上的 URL 状态整份丢弃并 warn 一次:恢复一份旧结构的状态会让界面进入
|
|
276
|
+
* 一个谁都没设计过的样子,而那种坏法是静默的(列还在、但顺序是乱的)。
|
|
277
|
+
*/
|
|
278
|
+
/**
|
|
279
|
+
* 约束布局产物注入(REQ-011 接线 / CL-4)。
|
|
280
|
+
*
|
|
281
|
+
* 运行时只认 `layout_css`——构建期解好的 CSS——按宿主类名注入一次。
|
|
282
|
+
* 收到的若是 `layout` 声明本身而没有产物,说明这页没走 `compilePageDeclaration`
|
|
283
|
+
* (直接把源 YAML 喂给了浏览器)。这里**不**代为求解:求解器在 core/build/,
|
|
284
|
+
* 进 client 就等于把「运行期零求解」这条结构性承诺撤回去。只把这件事说出来。
|
|
285
|
+
*/
|
|
286
|
+
private installLayoutCss;
|
|
287
|
+
private installPageState;
|
|
288
|
+
/** 当前路由路径;无 router 时回落 location */
|
|
289
|
+
private routerPath;
|
|
290
|
+
/**
|
|
291
|
+
* 页面里用到的每一个 `ACTION | <名字>` 都必须在注册表里(AO-3)。
|
|
292
|
+
*
|
|
293
|
+
* 为什么在装配期查而不是运行期:运行期查的话,一个拼错的动作名要等到用户
|
|
294
|
+
* 点了那个按钮才暴露,而暴露的形式是"点了没反应"——最难报障也最难复现的一种。
|
|
295
|
+
*/
|
|
296
|
+
private assertNamedActionsResolvable;
|
|
297
|
+
/** 稳定的 data 端口壳:每次调用现取当前解析器 */
|
|
298
|
+
private createStableDataPort;
|
|
229
299
|
/** 组件管理器装配:无 components 资产时保持 null,组件能力整体旁路 */
|
|
230
300
|
private setupComponentManager;
|
|
231
301
|
private buildRuntime;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ParsedEvent } from '../../shared/types/event.types';
|
|
2
|
+
import type { SomaStepGraph } from '../../shared/types/step.types';
|
|
3
|
+
export interface StepRunContext {
|
|
4
|
+
/** 事件载荷:`when` 的字段来源之一 */
|
|
5
|
+
payload: Record<string, unknown>;
|
|
6
|
+
/** 执行一条已解析的管道;返回值进输出槽 */
|
|
7
|
+
dispatch(pipeline: Omit<ParsedEvent, 'somaId' | 'domEvent'>): Promise<unknown>;
|
|
8
|
+
/** bootstrap 注册的具名动作 */
|
|
9
|
+
actions?: Record<string, (payload: Record<string, unknown>) => Promise<unknown> | unknown>;
|
|
10
|
+
/** 出错落点;不给就 console.error */
|
|
11
|
+
onError?(message: string, detail: {
|
|
12
|
+
step: number;
|
|
13
|
+
cause: unknown;
|
|
14
|
+
}): void;
|
|
15
|
+
}
|
|
16
|
+
export interface StepRunResult {
|
|
17
|
+
/** 实际执行过的步骤序号(顺序即执行序,`goto` 会让它跳号) */
|
|
18
|
+
executed: number[];
|
|
19
|
+
/** 事件结束时的槽(仅用于测试与诊断;运行期不外泄) */
|
|
20
|
+
slots: Record<string, unknown>;
|
|
21
|
+
/** 是否被 on_error: stop 中断 */
|
|
22
|
+
stopped: boolean;
|
|
23
|
+
}
|
|
24
|
+
export declare function runSteps(graph: SomaStepGraph, ctx: StepRunContext): Promise<StepRunResult>;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { ExtendedShowValue } from '../../../shared/types/ui-config.types';
|
|
2
|
+
import { parseDuration } from '../duration';
|
|
3
|
+
export { parseDuration };
|
|
2
4
|
import { type BlockScope } from './namespace';
|
|
3
5
|
export interface DataObjectDecl {
|
|
4
6
|
localName: string;
|
|
@@ -68,5 +70,3 @@ export interface ParseUseInput {
|
|
|
68
70
|
rowVars?: Iterable<string>;
|
|
69
71
|
}
|
|
70
72
|
export declare function parseUseBlock(input: ParseUseInput): UseBlockAst;
|
|
71
|
-
/** `30s` → 30000;单位封闭 ms/s/m,无单位报错(不猜) */
|
|
72
|
-
export declare function parseDuration(raw: string, where: string, fail: (m: string) => never): number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function parseDuration(raw: string, where: string, fail: (m: string) => never): number;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type SomaLayoutConstraint } from '../../shared/types/layout-constraint.types';
|
|
2
|
+
export interface LayoutParseInput {
|
|
3
|
+
raw: unknown;
|
|
4
|
+
path: string;
|
|
5
|
+
}
|
|
6
|
+
export interface LayoutParseDeps {
|
|
7
|
+
fail(message: string, path: string): never;
|
|
8
|
+
}
|
|
9
|
+
export declare function parseLayoutConstraint(input: LayoutParseInput, deps: LayoutParseDeps): SomaLayoutConstraint;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { SomaPageState, SomaPageStateConfig } from '../../shared/types/page-state.types';
|
|
2
|
+
export interface PageStateParseInput {
|
|
3
|
+
raw: unknown;
|
|
4
|
+
/** 已声明的数据对象名(`window` 切片只能指向它们) */
|
|
5
|
+
objectNames: readonly string[];
|
|
6
|
+
/** 页面上的锚点 id(`columns` 切片只能指向它们);不给就跳过这一层校验 */
|
|
7
|
+
anchorIds?: readonly string[];
|
|
8
|
+
path: string;
|
|
9
|
+
}
|
|
10
|
+
export interface PageStateParseDeps {
|
|
11
|
+
fail(message: string, path: string): never;
|
|
12
|
+
}
|
|
13
|
+
export declare function parsePageState(input: PageStateParseInput, deps: PageStateParseDeps): SomaPageStateConfig;
|
|
14
|
+
/**
|
|
15
|
+
* 校验一份具体的状态值(`initial_state`、URL 还原、`setState` 入参共用)。
|
|
16
|
+
*
|
|
17
|
+
* 越界的切片**丢弃并点名**,而不是整份拒收:一份来自旧版本 URL 的状态里多半只有
|
|
18
|
+
* 一两块对不上,整份丢掉等于让分享链接彻底失效——而它本来还能恢复大半。
|
|
19
|
+
*/
|
|
20
|
+
export declare function parseStateValue(raw: unknown, path: string, config: SomaPageStateConfig, fail: (message: string, at: string) => never): SomaPageState;
|
|
21
|
+
/**
|
|
22
|
+
* 页面态 ⇄ URL 的紧凑序列化。
|
|
23
|
+
*
|
|
24
|
+
* 用 base64url 包一层 JSON 而不是把每个切片摊成 query 参数:状态是树形的
|
|
25
|
+
* (`window.orders.filter` 是一棵递归 AST),摊平会得到一串 `window.orders.filter.conditions[0].op=in`
|
|
26
|
+
* 这样的东西——既难读,也会撞上 URL 长度与转义的一堆边角。
|
|
27
|
+
*
|
|
28
|
+
* 不用 `btoa`:它只吃 Latin-1,中文过滤值会直接抛。
|
|
29
|
+
*/
|
|
30
|
+
export declare function encodePageState(state: SomaPageState): string;
|
|
31
|
+
/** URL → 页面态;坏串返回 null(一条被截断的链接不该让页面打不开) */
|
|
32
|
+
export declare function decodePageState(encoded: string): SomaPageState | null;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { SomaReactionGraph } from '../../shared/types/reaction.types';
|
|
2
|
+
import type { SomaDataFieldConfig } from '../../shared/types/data-config.types';
|
|
3
|
+
import type { SomaNamedPredicates } from '../../shared/predicates';
|
|
4
|
+
/** 与 data-config-parser 同一个错误类;由调用方注入以免循环依赖 */
|
|
5
|
+
export interface ReactionParseDeps {
|
|
6
|
+
fail(message: string, path: string): never;
|
|
7
|
+
}
|
|
8
|
+
export interface ReactionParseInput {
|
|
9
|
+
raw: unknown;
|
|
10
|
+
fields: Record<string, SomaDataFieldConfig>;
|
|
11
|
+
named: SomaNamedPredicates;
|
|
12
|
+
/** 字段 → 来源接口(读通道 `from[].api`),用于回溯表 */
|
|
13
|
+
sourceApiOf?: Readonly<Record<string, string | undefined>>;
|
|
14
|
+
path: string;
|
|
15
|
+
}
|
|
16
|
+
export declare function parseReactions(input: ReactionParseInput, deps: ReactionParseDeps): SomaReactionGraph;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { SomaReactionConfig } from '../../shared/types/reaction.types';
|
|
2
|
+
/** 展开所需的最小字段形状(不绑定 UI 侧的字段声明类型) */
|
|
3
|
+
export interface SomaSugarField {
|
|
4
|
+
key: string;
|
|
5
|
+
visible_when?: unknown;
|
|
6
|
+
disabled_when?: unknown;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* `visible_when` 不成立时用 `display: none` 而不是 `hidden`——这是**行为等价**的要求:
|
|
10
|
+
* REQ-009 的 FormPanel 对隐藏字段既不渲染、也不校验、也不进提交载荷(`projected` 删键),
|
|
11
|
+
* 而 `hidden` 只是不给看、数据仍在。选错这一档,等价回归会红在提交载荷上。
|
|
12
|
+
*/
|
|
13
|
+
export declare function compileFieldSugar(fields: readonly SomaSugarField[]): SomaReactionConfig[];
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ParsedEvent } from '../../shared/types/event.types';
|
|
2
|
+
import type { SomaStepGraph } from '../../shared/types/step.types';
|
|
3
|
+
export interface StepParseInput {
|
|
4
|
+
raw: unknown;
|
|
5
|
+
/** 事件载荷里的字段名:`when` 的作用域起点 */
|
|
6
|
+
payloadFields: readonly string[];
|
|
7
|
+
/** bootstrap 注册的具名动作;给了就校验 `do: ACTION | <name>` 的名字存在 */
|
|
8
|
+
actionNames?: readonly string[];
|
|
9
|
+
path: string;
|
|
10
|
+
}
|
|
11
|
+
export interface StepParseDeps {
|
|
12
|
+
fail(message: string, path: string): never;
|
|
13
|
+
/**
|
|
14
|
+
* 单条管道的解析器(`pipeline-parser` 的 `parsePipelineBody`)。
|
|
15
|
+
*
|
|
16
|
+
* 由调用方注入而不是直接 import,是为了不成环:`pipeline-parser` 的
|
|
17
|
+
* `parseEventConfig` 要认 `{ steps: [...] }` 形态,于是它得调本模块;
|
|
18
|
+
* 本模块再反向 import 它就构成循环,而循环 import 在 ESM 下"多数时候能跑"
|
|
19
|
+
* ——它坏起来是模块初始化顺序变了之后的一个 undefined,跟本次改动毫无关联。
|
|
20
|
+
*/
|
|
21
|
+
parsePipeline(expression: string): Omit<ParsedEvent, 'somaId' | 'domEvent'>;
|
|
22
|
+
}
|
|
23
|
+
export declare function parseSteps(input: StepParseInput, deps: StepParseDeps): SomaStepGraph;
|