soma-core 1.3.5 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (169) hide show
  1. package/README.md +20 -7
  2. package/app/SomaPageClient.tsx +4 -4
  3. package/app/components/SomaHostPage.tsx +5 -5
  4. package/app/components/SomaHydrationShell.tsx +4 -7
  5. package/app/globals.css +126 -3
  6. package/core/build/{v2 → blocks}/block-compile.ts +47 -18
  7. package/core/build/{v2/soma-file-loader.ts → blocks/block-container.ts} +28 -37
  8. package/core/build/{v2 → blocks}/block-loader.ts +1 -1
  9. package/core/build/{v2 → blocks}/html-index.ts +1 -1
  10. package/core/build/{v2/migrate-v1.ts → blocks/migrate-flat.ts} +27 -27
  11. package/core/build/compiler/host-config-sync.cjs +2 -9
  12. package/core/build/compiler/page-declaration-compiler.ts +32 -4
  13. package/core/build/compiler/soma-manifest-webpack-plugin.js +1 -1
  14. package/core/build/compiler/soma-precompile.js +2057 -35
  15. package/core/build/compiler/soma-precompile.ts +2 -2
  16. package/core/build/component/component-graph.ts +208 -0
  17. package/core/build/eject/component-eject.ts +473 -0
  18. package/core/build/eject/component-upgrade.ts +359 -0
  19. package/core/build/layout/constraint-solver.ts +235 -0
  20. package/core/build/layout/css-emitter.ts +116 -0
  21. package/core/build/layout/page-layout.ts +85 -0
  22. package/core/build/pack/pack-init.ts +265 -0
  23. package/core/client/base/SomaPageRootBase.ts +61 -0
  24. package/core/client/component/ai-catalog.ts +83 -8
  25. package/core/client/component/component-defaults.ts +100 -0
  26. package/core/client/component/component-definition.types.ts +39 -0
  27. package/core/client/component/component-manager.ts +79 -4
  28. package/core/client/component/component-pack.ts +126 -2
  29. package/core/client/component/contract-compat.ts +32 -3
  30. package/core/client/component/{example-v2.ts → example-blocks.ts} +19 -19
  31. package/core/client/component/keyboard-matrix.ts +144 -0
  32. package/core/client/component/pack-styles.ts +59 -1
  33. package/core/client/component/style-features.ts +131 -0
  34. package/core/client/component/theme-component-tokens.ts +83 -0
  35. package/core/client/data/data-object-resolver.ts +407 -4
  36. package/core/client/data/reaction-engine.ts +176 -0
  37. package/core/client/data/window-engine.ts +477 -0
  38. package/core/client/engine/event-engine.ts +98 -0
  39. package/core/client/engine/soma-bootstrap.ts +286 -7
  40. package/core/client/engine/step-runner.ts +134 -0
  41. package/core/client/engine/style-binder.ts +1 -1
  42. package/core/client/infra/notify/DomNotifyService.ts +2 -1
  43. package/core/client/infra/notify/INotifyTheme.ts +1 -1
  44. package/core/client/parser/{v2 → blocks}/namespace.ts +1 -1
  45. package/core/client/parser/{v2 → blocks}/page-parser.ts +30 -16
  46. package/core/client/parser/{v2 → blocks}/use-parser.ts +24 -25
  47. package/core/client/parser/data-config-parser.ts +316 -8
  48. package/core/client/parser/duration.ts +16 -0
  49. package/core/client/parser/layout-parser.ts +157 -0
  50. package/core/client/parser/page-state-parser.ts +166 -0
  51. package/core/client/parser/pipeline-parser.ts +76 -1
  52. package/core/client/parser/reaction-parser.ts +459 -0
  53. package/core/client/parser/reaction-sugar.ts +47 -0
  54. package/core/client/parser/step-parser.ts +359 -0
  55. package/core/client/parser/style-config-parser.ts +7 -7
  56. package/core/client/parser/ui-config-parser.ts +59 -0
  57. package/core/client/parser/value-lang.ts +1 -1
  58. package/core/client/parser/window-parser.ts +294 -0
  59. package/core/client/registry/index.ts +8 -0
  60. package/core/client/theme/theme-engine.ts +144 -16
  61. package/core/client/typography/typography-base.ts +1 -1
  62. package/core/index.ts +188 -13
  63. package/core/server/host/csp-nonce-metadata.ts +1 -1
  64. package/core/server/host/published-page-assets.ts +3 -8
  65. package/core/server/host/soma-page-compile.ts +1 -1
  66. package/core/server/index.ts +2 -2
  67. package/core/shared/block-errors.ts +11 -0
  68. package/core/shared/calc/coerce.ts +29 -0
  69. package/core/shared/calc/errors.ts +43 -0
  70. package/core/shared/calc/evaluator.ts +101 -0
  71. package/core/shared/calc/index.ts +12 -0
  72. package/core/shared/calc/lexer.ts +194 -0
  73. package/core/shared/calc/parser.ts +204 -0
  74. package/core/shared/calc/typer.ts +184 -0
  75. package/core/shared/path-algebra.ts +169 -0
  76. package/core/shared/predicates/index.ts +527 -0
  77. package/core/shared/published-page-route.ts +61 -0
  78. package/core/shared/types/adaptive.types.ts +1 -1
  79. package/core/shared/types/component-contract.types.ts +128 -2
  80. package/core/shared/types/data-config.types.ts +149 -2
  81. package/core/shared/types/domain.types.ts +13 -0
  82. package/core/shared/types/event.types.ts +22 -2
  83. package/core/shared/types/layout-constraint.types.ts +73 -0
  84. package/core/shared/types/page-state.types.ts +60 -0
  85. package/core/shared/types/reaction.types.ts +144 -0
  86. package/core/shared/types/scope-manifest.types.ts +11 -15
  87. package/core/shared/types/step.types.ts +91 -0
  88. package/core/shared/types/style-config.types.ts +4 -4
  89. package/core/shared/types/ui-config.types.ts +18 -0
  90. package/core/shared/types/window.types.ts +177 -0
  91. package/dist/cli/soma.js +28 -3
  92. package/dist/core/index.cjs +4829 -405
  93. package/dist/types/build/{v2 → blocks}/block-compile.d.ts +7 -7
  94. package/dist/types/build/{v2/soma-file-loader.d.ts → blocks/block-container.d.ts} +6 -11
  95. package/dist/types/build/{v2/migrate-v1.d.ts → blocks/migrate-flat.d.ts} +6 -6
  96. package/dist/types/build/compiler/page-declaration-compiler.d.ts +2 -0
  97. package/dist/types/build/component/component-graph.d.ts +85 -0
  98. package/dist/types/build/eject/component-eject.d.ts +121 -0
  99. package/dist/types/build/eject/component-upgrade.d.ts +43 -0
  100. package/dist/types/build/layout/constraint-solver.d.ts +36 -0
  101. package/dist/types/build/layout/css-emitter.d.ts +18 -0
  102. package/dist/types/build/layout/page-layout.d.ts +24 -0
  103. package/dist/types/build/pack/pack-init.d.ts +8 -0
  104. package/dist/types/client/base/SomaPageRootBase.d.ts +28 -0
  105. package/dist/types/client/component/ai-catalog.d.ts +24 -1
  106. package/dist/types/client/component/component-defaults.d.ts +15 -0
  107. package/dist/types/client/component/component-definition.types.d.ts +38 -0
  108. package/dist/types/client/component/component-manager.d.ts +36 -0
  109. package/dist/types/client/component/component-pack.d.ts +32 -2
  110. package/dist/types/client/component/contract-compat.d.ts +2 -2
  111. package/dist/types/client/component/example-blocks.d.ts +9 -0
  112. package/dist/types/client/component/keyboard-matrix.d.ts +24 -0
  113. package/dist/types/client/component/pack-styles.d.ts +21 -0
  114. package/dist/types/client/component/style-features.d.ts +26 -0
  115. package/dist/types/client/component/theme-component-tokens.d.ts +14 -0
  116. package/dist/types/client/data/data-object-resolver.d.ts +106 -1
  117. package/dist/types/client/data/reaction-engine.d.ts +21 -0
  118. package/dist/types/client/data/window-engine.d.ts +27 -0
  119. package/dist/types/client/engine/event-engine.d.ts +15 -0
  120. package/dist/types/client/engine/soma-bootstrap.d.ts +70 -0
  121. package/dist/types/client/engine/step-runner.d.ts +24 -0
  122. package/dist/types/client/infra/notify/DomNotifyService.d.ts +2 -1
  123. package/dist/types/client/infra/notify/INotifyTheme.d.ts +1 -1
  124. package/dist/types/client/parser/{v2 → blocks}/page-parser.d.ts +2 -2
  125. package/dist/types/client/parser/{v2 → blocks}/use-parser.d.ts +3 -3
  126. package/dist/types/client/parser/duration.d.ts +1 -0
  127. package/dist/types/client/parser/layout-parser.d.ts +9 -0
  128. package/dist/types/client/parser/page-state-parser.d.ts +32 -0
  129. package/dist/types/client/parser/reaction-parser.d.ts +16 -0
  130. package/dist/types/client/parser/reaction-sugar.d.ts +13 -0
  131. package/dist/types/client/parser/step-parser.d.ts +23 -0
  132. package/dist/types/client/parser/style-config-parser.d.ts +1 -1
  133. package/dist/types/client/parser/ui-config-parser.d.ts +5 -0
  134. package/dist/types/client/parser/window-parser.d.ts +25 -0
  135. package/dist/types/client/registry/index.d.ts +1 -0
  136. package/dist/types/client/theme/theme-engine.d.ts +37 -0
  137. package/dist/types/index.d.ts +40 -9
  138. package/dist/types/server/host/published-page-assets.d.ts +3 -2
  139. package/dist/types/server/index.d.ts +1 -1
  140. package/dist/types/shared/block-errors.d.ts +5 -0
  141. package/dist/types/shared/calc/coerce.d.ts +4 -0
  142. package/dist/types/shared/calc/errors.d.ts +14 -0
  143. package/dist/types/shared/calc/evaluator.d.ts +2 -0
  144. package/dist/types/shared/calc/index.d.ts +6 -0
  145. package/dist/types/shared/calc/lexer.d.ts +20 -0
  146. package/dist/types/shared/calc/parser.d.ts +49 -0
  147. package/dist/types/shared/calc/typer.d.ts +16 -0
  148. package/dist/types/shared/path-algebra.d.ts +56 -0
  149. package/dist/types/shared/predicates/index.d.ts +79 -0
  150. package/dist/types/shared/published-page-route.d.ts +21 -0
  151. package/dist/types/shared/types/component-contract.types.d.ts +112 -0
  152. package/dist/types/shared/types/data-config.types.d.ts +132 -2
  153. package/dist/types/shared/types/domain.types.d.ts +12 -0
  154. package/dist/types/shared/types/event.types.d.ts +8 -2
  155. package/dist/types/shared/types/layout-constraint.types.d.ts +52 -0
  156. package/dist/types/shared/types/page-state.types.d.ts +49 -0
  157. package/dist/types/shared/types/reaction.types.d.ts +115 -0
  158. package/dist/types/shared/types/scope-manifest.types.d.ts +11 -11
  159. package/dist/types/shared/types/step.types.d.ts +76 -0
  160. package/dist/types/shared/types/style-config.types.d.ts +4 -4
  161. package/dist/types/shared/types/ui-config.types.d.ts +18 -0
  162. package/dist/types/shared/types/window.types.d.ts +171 -0
  163. package/package.json +2 -6
  164. package/dist/types/client/component/example-v2.d.ts +0 -9
  165. package/postcss.config.js +0 -6
  166. package/tailwind.config.ts +0 -43
  167. /package/dist/types/build/{v2 → blocks}/block-loader.d.ts +0 -0
  168. /package/dist/types/build/{v2 → blocks}/html-index.d.ts +0 -0
  169. /package/dist/types/client/parser/{v2 → blocks}/namespace.d.ts +0 -0
@@ -0,0 +1,76 @@
1
+ import type { SomaFieldPredicate } from '../predicates';
2
+ import type { ParsedEvent } from './event.types';
3
+ /** 出错之后怎么走:停 / 继续 / 跳到第 n 步(只许向后,见 AO-1) */
4
+ export type SomaStepOnError = 'stop' | 'continue' | `goto:${number}`;
5
+ /** 单步:一条管道 + 可选的条件、输出槽与错误去向 */
6
+ export interface SomaDoStep {
7
+ when?: SomaFieldPredicate;
8
+ do: string;
9
+ output?: string;
10
+ on_error?: SomaStepOnError;
11
+ }
12
+ /** 分支:取第一个成立的 `when`;`otherwise` 可选且只能有一个、且必须在末尾 */
13
+ export interface SomaSwitchStep {
14
+ when?: SomaFieldPredicate;
15
+ switch: Array<{
16
+ when?: SomaFieldPredicate;
17
+ otherwise?: true;
18
+ do: string;
19
+ output?: string;
20
+ }>;
21
+ }
22
+ /** 并行:分支之间**不许互引输出槽**(互引就意味着有顺序,那它就不是并行) */
23
+ export interface SomaParallelStep {
24
+ parallel: SomaStep[];
25
+ }
26
+ /** 遍历:`over` 必须是有界的(数组型输出槽或事件载荷里的数组) */
27
+ export interface SomaForEachStep {
28
+ for_each: {
29
+ over: string;
30
+ as: string;
31
+ steps: SomaStep[];
32
+ };
33
+ }
34
+ export type SomaStep = SomaDoStep | SomaSwitchStep | SomaParallelStep | SomaForEachStep;
35
+ /** 输出槽:本次事件内的具名中间结果 */
36
+ export interface SomaStepSlot {
37
+ /** 声明它的步骤序号(引用只许向后,见 AO-2) */
38
+ declaredAt: number;
39
+ /** 产出它的动作类型,用于「这个槽是不是数组」这类判断 */
40
+ producedBy: string;
41
+ /** 是否已知为数组(`for_each.over` 只认这种) */
42
+ bounded: boolean;
43
+ }
44
+ /** 编译后的一步:管道已解析,条件已校验 */
45
+ export interface SomaCompiledStep {
46
+ index: number;
47
+ kind: 'do' | 'switch' | 'parallel' | 'for_each';
48
+ when?: SomaFieldPredicate;
49
+ /** kind='do' */
50
+ pipeline?: Omit<ParsedEvent, 'somaId' | 'domEvent'>;
51
+ output?: string;
52
+ onError: SomaStepOnError;
53
+ /** kind='switch' */
54
+ branches?: Array<{
55
+ when?: SomaFieldPredicate;
56
+ otherwise: boolean;
57
+ pipeline: Omit<ParsedEvent, 'somaId' | 'domEvent'>;
58
+ output?: string;
59
+ }>;
60
+ /** kind='parallel' / 'for_each' */
61
+ children?: SomaCompiledStep[];
62
+ /** kind='for_each' */
63
+ over?: string;
64
+ as?: string;
65
+ }
66
+ /**
67
+ * 编译产物:纯数据,可画、可 diff、可进目录快照(AO-4)。
68
+ *
69
+ * `edges` 是顺序边与 `goto` 边的并集——它存在的唯一理由是**能被画出来**:
70
+ * 一张编排图如果只能靠读 YAML 想象,那它和写在代码里的 handler 没有区别。
71
+ */
72
+ export interface SomaStepGraph {
73
+ steps: SomaCompiledStep[];
74
+ slots: Record<string, SomaStepSlot>;
75
+ edges: Array<[number, number]>;
76
+ }
@@ -15,7 +15,7 @@ export interface StyleStateRule {
15
15
  condition: string;
16
16
  /** 目标值(基础类型:string | number | boolean | null) */
17
17
  value: string | number | boolean | null;
18
- /** 匹配时应用的 Tailwind 类名 */
18
+ /** 匹配时应用的 CSS 类名;具体样式由宿主样式系统提供 */
19
19
  apply: string;
20
20
  }
21
21
  /**
@@ -28,7 +28,7 @@ export type TransitionTrigger = 'hover' | 'focus' | 'active' | 'enter' | 'leave'
28
28
  export interface StyleTransition {
29
29
  /** 触发方式 */
30
30
  trigger: TransitionTrigger;
31
- /** 应用的 Tailwind 动画/过渡类名 */
31
+ /** 应用的 CSS 动画/过渡类名;具体样式由宿主样式系统提供 */
32
32
  apply: string;
33
33
  /** active_state 类型时的条件路径 */
34
34
  condition?: string;
@@ -45,7 +45,7 @@ export interface ThemeStatesOverride {
45
45
  * 单个主题配置
46
46
  */
47
47
  export interface ThemeConfig {
48
- /** 基础类名覆盖:somaId → Tailwind 类名 */
48
+ /** 基础类名覆盖:somaId → CSS 类名 */
49
49
  base: Record<string, string>;
50
50
  /** 状态规则覆盖 */
51
51
  states: ThemeStatesOverride;
@@ -59,7 +59,7 @@ export interface ThemeConfig {
59
59
  export interface StyleConfig {
60
60
  /** 所属的业务对象标识(对应 data-soma-host) */
61
61
  host: string;
62
- /** 基础静态样式映射:somaId → Tailwind 类名 */
62
+ /** 基础静态样式映射:somaId → CSS 类名 */
63
63
  base: Record<string, string>;
64
64
  /** 状态驱动样式:somaId → 规则数组 */
65
65
  states: Record<string, StyleStateRule[]>;
@@ -1,5 +1,7 @@
1
1
  import type { OnChangeRule } from './watcher.types';
2
2
  import type { SomaAdaptiveConfig } from './adaptive.types';
3
+ import type { SomaPageStateConfig } from './page-state.types';
4
+ import type { SomaLayoutConstraint } from './layout-constraint.types';
3
5
  /**
4
6
  * 作用域声明
5
7
  * 定义数据源路径和当前作用域别名
@@ -90,6 +92,22 @@ export interface UiConfig {
90
92
  * 所以此键必须保持可选,且缺席时不得在下游产生任何默认值。
91
93
  */
92
94
  adaptive?: SomaAdaptiveConfig;
95
+ /**
96
+ * 页面态切片声明(REQ-010 F-37,保留键,可选)。
97
+ * 与 `adaptive` 同一条纪律:未声明时编译产物与迁移前字节级一致。
98
+ */
99
+ state?: SomaPageStateConfig;
100
+ /**
101
+ * 约束布局声明(REQ-010 S3 / REQ-011 接线,保留键,可选):锚点 id → 一行的约束。
102
+ *
103
+ * 这是**声明**;它的产物是 `layoutCss`。求解只在构建期(`compilePageDeclaration`)发生,
104
+ * 运行时收到的是已经解好的 CSS(`layout_css`),浏览器一行 JS 都不用算。
105
+ * 运行时若收到的是 `layout` 而不是 `layout_css`,说明页面没走构建期编译——
106
+ * 引擎只告警、不求解(CL-4:求解器不进 client)。
107
+ */
108
+ layout?: Record<string, SomaLayoutConstraint>;
109
+ /** 构建期求解产物:只含容器查询 + flex 的 CSS(CL-2),运行时按页注入一次 */
110
+ layoutCss?: string;
93
111
  }
94
112
  /**
95
113
  * 解析后的 show 条目
@@ -0,0 +1,171 @@
1
+ import type { SomaFieldPredicateOp } from '../predicates';
2
+ import type { SomaDataSubmitResult } from './data-config.types';
3
+ /**
4
+ * 过滤 AST:递归的 `join + conditions`,叶子复用谓词图的算子闭集。
5
+ *
6
+ * 复用而不是另立一套算子,是因为同一个「状态在已付/已发货里」的判断,在字段显隐
7
+ * (RG 的 `when`)与列表过滤(这里)上必须是同一个意思。两套算子表迟早会有一套先长出
8
+ * 第 13 个算子。
9
+ */
10
+ export type SomaFilterNode = {
11
+ join: 'and' | 'or';
12
+ conditions: SomaFilterNode[];
13
+ } | {
14
+ field: string;
15
+ op: SomaFieldPredicateOp;
16
+ value?: unknown;
17
+ };
18
+ /** 排序意图:多列,声明序即优先级 */
19
+ export interface SomaWindowSort {
20
+ field: string;
21
+ order: 'asc' | 'desc';
22
+ }
23
+ /** 聚合函数闭集;`count` 之外都只对数值型字段(声明期配对) */
24
+ export declare const SOMA_AGGREGATE_FNS: readonly ["sum", "avg", "min", "max", "count"];
25
+ export type SomaAggregateFn = typeof SOMA_AGGREGATE_FNS[number];
26
+ export interface SomaWindowAggregate {
27
+ field: string;
28
+ fn: SomaAggregateFn;
29
+ }
30
+ /**
31
+ * 全选语义三档。
32
+ *
33
+ * `all` 与 `filtered` 的差别只在后端:前者是「库里所有行」,后者是「当前过滤条件命中的行」。
34
+ * 前端表现一样(都是 `base: 'all'`),但一个批量删除操作在这两档之间的差别是灾难性的,
35
+ * 所以它必须是显式声明,不能靠"当时有没有过滤条件"猜。
36
+ */
37
+ export declare const SOMA_SELECT_ALL_MODES: readonly ["all", "filtered", "current_page"];
38
+ export type SomaSelectAllMode = typeof SOMA_SELECT_ALL_MODES[number];
39
+ /**
40
+ * 选择态:基线 + 反选集。
41
+ *
42
+ * 十万行里「全选后取消三行」,朴素做法要传九万九千九百九十七个 id。
43
+ * 记成 `{ base: 'all', toggled: [3 个] }` 之后载荷是 O(反选数) —— 这也是
44
+ * 后端唯一能高效解释的形状(它自己知道 `all` 是哪些行)。
45
+ */
46
+ export interface SomaWindowSelection {
47
+ base: 'none' | 'all';
48
+ toggled: string[];
49
+ }
50
+ export interface SomaWindowBlockConfig {
51
+ /** 一块多少行(SSRM cacheBlockSize 等价) */
52
+ size: number;
53
+ /** 最多缓存几块,超出按 LRU 淘汰;当前视口覆盖的块永不淘汰 */
54
+ max_blocks: number;
55
+ /** 合并快速滚动期间的中间块请求(毫秒) */
56
+ debounce_ms: number;
57
+ }
58
+ /** 解析产物:声明期已把所有缺省补齐、所有引用对着字典校验过 */
59
+ export interface SomaWindowConfig {
60
+ /** 只有服务端窗口。客户端窗口与「业务逻辑归后端」冲突,不做 */
61
+ mode: 'server';
62
+ block: SomaWindowBlockConfig;
63
+ sort: SomaWindowSort[];
64
+ filter: SomaFilterNode | null;
65
+ group: {
66
+ by: string[];
67
+ keys: string[];
68
+ } | null;
69
+ aggregate: SomaWindowAggregate[];
70
+ selection: SomaWindowSelection;
71
+ select_all: SomaSelectAllMode;
72
+ cache: {
73
+ ttl_ms: number | null;
74
+ keep_previous: boolean;
75
+ };
76
+ revalidate_ms: number | null;
77
+ /**
78
+ * 字段字典的稳定哈希(字段名 + 类型 + 权限)。
79
+ * 随请求下发,后端据此拒收「按一份它不认识的字典发来的意图」。
80
+ */
81
+ dict_hash: string;
82
+ }
83
+ /**
84
+ * 请求体:**纯 JSON**(DW-2)。
85
+ *
86
+ * 这里不许出现函数、Set、Map、DOM 引用——它要能 `JSON.stringify` 往返相等,
87
+ * 因为它同时是网络载荷、缓存键和排障时贴进工单的那段文本。
88
+ */
89
+ export interface SomaWindowRequest {
90
+ start: number;
91
+ end: number;
92
+ sort: SomaWindowSort[];
93
+ filter: SomaFilterNode | null;
94
+ group: {
95
+ by: string[];
96
+ keys: string[];
97
+ } | null;
98
+ aggregate: SomaWindowAggregate[];
99
+ dict_hash: string;
100
+ }
101
+ export interface SomaWindowResponse {
102
+ rows: unknown[];
103
+ /** 后端不知道总数时可省略:滚动条按「至少还有一块」的语义给初值 */
104
+ total?: number;
105
+ group_info?: Record<string, unknown>;
106
+ grand_total?: Record<string, unknown>;
107
+ }
108
+ /**
109
+ * 写通道事务体(对齐 AG Grid ServerSideTransaction)。
110
+ * 一次提交是一个 patch 集,不是一个对象——批量编辑的天然形状。
111
+ */
112
+ export interface SomaTransaction {
113
+ /** 分组路径:改的是哪一层的行 */
114
+ route?: string[];
115
+ add?: Array<Record<string, unknown>>;
116
+ remove?: Array<Record<string, unknown>>;
117
+ update?: Array<Record<string, unknown>>;
118
+ }
119
+ /** 组件消费面:自治组件与受控组件都只认这一个把手 */
120
+ export interface SomaWindowHandle {
121
+ readonly spec: SomaWindowConfig;
122
+ /** 展示值:已提交值 ⊕ 未提交编辑(pending) */
123
+ readonly rows: readonly unknown[];
124
+ readonly total: number | undefined;
125
+ readonly selection: SomaWindowSelection;
126
+ readonly loading: boolean;
127
+ readonly error: string;
128
+ /** 当前缓存块数(DW-6 的观测面) */
129
+ readonly blockCount: number;
130
+ /** 当前视口 [start, end):`rows` 就是这一段;受控组件按 `start` 还原真实行号 */
131
+ readonly start: number;
132
+ readonly end: number;
133
+ /** 当前生效的排序 / 过滤意图(声明起步,之后随 request(patch) 改写) */
134
+ readonly sort: SomaWindowSort[];
135
+ readonly filter: SomaFilterNode | null;
136
+ /** 改意图或挪视口;改 sort/filter/group/aggregate 任一项都会清空缓存并回到第 0 行 */
137
+ request(patch: SomaWindowRequestPatch): Promise<void>;
138
+ /** 翻转选择:`toggle` 逐个翻,`base` 换基线并清空反选集 */
139
+ select(patch: {
140
+ toggle?: string[];
141
+ base?: 'none' | 'all';
142
+ }): void;
143
+ isSelected(id: string): boolean;
144
+ /** 未提交的单元格编辑(受控编辑:组件只发意图,不写数据) */
145
+ edit(id: string, field: string, value: unknown): void;
146
+ readonly pendingCount: number;
147
+ commit(tx?: SomaTransaction): Promise<SomaDataSubmitResult>;
148
+ savepoint(): number;
149
+ revertTo(id: number): void;
150
+ /**
151
+ * 分组下钻(F-33):展开到 `keys` 这一层,拿它自己的窗口。
152
+ * 没声明 `group:` 段、或路径比分组层数还深时返回 null。
153
+ * 子窗口继承父的排序与过滤,**不继承**选择态。
154
+ */
155
+ drillDown(keys: readonly string[]): SomaWindowHandle | null;
156
+ /** 已展开的子窗口路径(诊断用) */
157
+ readonly childPaths: string[];
158
+ /** 对象级 reload 时销毁(连同子分组窗口) */
159
+ destroy(): void;
160
+ }
161
+ export interface SomaWindowRequestPatch {
162
+ start?: number;
163
+ end?: number;
164
+ sort?: SomaWindowSort[];
165
+ filter?: SomaFilterNode | null;
166
+ group?: {
167
+ by: string[];
168
+ keys: string[];
169
+ } | null;
170
+ aggregate?: SomaWindowAggregate[];
171
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "soma-core",
3
- "version": "1.3.5",
3
+ "version": "1.4.1",
4
4
  "description": "SOMA — Semantic Oriented Modular Architecture. A declarative frontend framework runtime built on Next.js 16 App Router.",
5
5
  "keywords": [
6
6
  "soma",
@@ -107,8 +107,6 @@
107
107
  "dist/vscode/",
108
108
  "proxy.ts",
109
109
  "next.config.js",
110
- "tailwind.config.ts",
111
- "postcss.config.js",
112
110
  "tsconfig.json",
113
111
  "global.d.ts"
114
112
  ],
@@ -158,17 +156,15 @@
158
156
  "@types/ws": "^8.5.13",
159
157
  "@vitest/coverage-v8": "^3.2.7",
160
158
  "ajv-formats": "3.0.1",
161
- "autoprefixer": "^10.4.17",
162
159
  "esbuild": "^0.25.12",
163
160
  "js-yaml": "^4.3.1",
164
161
  "jsdom": "^26.1.0",
165
162
  "next": "16.3.1",
166
163
  "playwright": "^1.62.1",
167
- "postcss": "^8.4.33",
168
164
  "react": "^18.3.0",
169
165
  "react-dom": "^18.3.0",
170
166
  "semver": "^7.8.5",
171
- "tailwindcss": "^3.4.1",
167
+ "tsx": "^4.23.13",
172
168
  "typescript": "^5.3.3",
173
169
  "vite": "6.4.3",
174
170
  "vitest": "^3.2.7",
@@ -1,9 +0,0 @@
1
- /**
2
- * 由 v1 示例派生一行 v2 写法;换算不出来时返回 null。
3
- *
4
- * 产出的是**块声明**片段(写进 `_ui.yaml` 的 `{{ … }}` 之内),
5
- * html 那一行 v1 v2 通用,不重复。
6
- */
7
- export declare function deriveV2Example(componentName: string, example: string): string | null;
8
- /** 示例里的 html 行(v1 v2 通用),供 v2 段复用而不重复贴一遍 */
9
- export declare function exampleHtmlLine(example: string): string | null;
package/postcss.config.js DELETED
@@ -1,6 +0,0 @@
1
- module.exports = {
2
- plugins: {
3
- tailwindcss: {},
4
- autoprefixer: {},
5
- },
6
- };
@@ -1,43 +0,0 @@
1
- import type { Config } from 'tailwindcss';
2
- import fs from 'node:fs';
3
- import path from 'node:path';
4
- import { createRequire } from 'node:module';
5
- import { fileURLToPath } from 'node:url';
6
- import { getSomaAssetSources } from './core/server/host/source-packages';
7
-
8
- /**
9
- * Framework Tailwind config (loaded with soma-core / Next).
10
- * Host theme/plugins come from SOMA_HOST_DIR/tailwind.config.cjs/js via presets.
11
- */
12
- if (!process.env.SOMA_HOST_DIR) {
13
- throw new Error('[soma-core] tailwind: SOMA_HOST_DIR is not set');
14
- }
15
- const hostDir = path.resolve(process.env.SOMA_HOST_DIR);
16
- const require = createRequire(fileURLToPath(import.meta.url));
17
-
18
- function loadHostPreset(): Config | null {
19
- for (const name of ['tailwind.config.cjs', 'tailwind.config.js']) {
20
- const cfgPath = path.join(hostDir, name);
21
- if (!fs.existsSync(cfgPath)) continue;
22
- const mod = require(cfgPath) as Config | { default: Config };
23
- return ('default' in mod && mod.default) ? mod.default : (mod as Config);
24
- }
25
- return null;
26
- }
27
-
28
- const hostPreset = loadHostPreset();
29
- const sourceContent = getSomaAssetSources(hostDir).flatMap((source) => [
30
- path.join(source.assetRoot, 'html/**/*.html'),
31
- path.join(source.assetRoot, 'styles/**/*.css'),
32
- ]);
33
-
34
- const config: Config = {
35
- ...(hostPreset ? { presets: [hostPreset] } : {}),
36
- content: [
37
- './app/**/*.{js,ts,jsx,tsx,mdx}',
38
- './core/**/*.{js,ts,jsx,tsx}',
39
- ...sourceContent,
40
- ],
41
- };
42
-
43
- export default config;
File without changes