soma-core 1.3.4 → 1.4.0
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 +20 -7
- package/app/SomaPageClient.tsx +4 -4
- package/app/components/SomaHostPage.tsx +5 -5
- package/app/components/SomaHydrationShell.tsx +4 -7
- package/app/globals.css +126 -3
- package/app/soma/page/route.ts +17 -2
- package/core/build/{v2 → blocks}/block-compile.ts +17 -17
- package/core/build/{v2/soma-file-loader.ts → blocks/block-container.ts} +28 -28
- package/core/build/{v2 → blocks}/block-loader.ts +1 -1
- package/core/build/{v2 → blocks}/html-index.ts +1 -1
- package/core/build/{v2/migrate-v1.ts → blocks/migrate-flat.ts} +28 -28
- package/core/build/compiler/host-config-sync.cjs +2 -9
- package/core/build/compiler/page-declaration-compiler.ts +2 -2
- package/core/build/compiler/soma-manifest-webpack-plugin.js +1 -1
- package/core/build/compiler/soma-precompile.js +17 -17
- package/core/build/compiler/soma-precompile.ts +2 -2
- package/core/client/component/ai-catalog.ts +4 -4
- package/core/client/component/contract-compat.ts +32 -3
- package/core/client/component/{example-v2.ts → example-blocks.ts} +19 -19
- package/core/client/engine/soma-bootstrap.ts +21 -2
- package/core/client/engine/style-binder.ts +1 -1
- package/core/client/infra/notify/DomNotifyService.ts +2 -1
- package/core/client/infra/notify/INotifyTheme.ts +1 -1
- package/core/client/parser/{v2 → blocks}/namespace.ts +1 -1
- package/core/client/parser/{v2 → blocks}/page-parser.ts +16 -16
- package/core/client/parser/{v2 → blocks}/use-parser.ts +20 -14
- package/core/client/parser/style-config-parser.ts +7 -7
- package/core/client/parser/value-lang.ts +1 -1
- package/core/client/registry/index.ts +8 -0
- package/core/client/registry/page-lifecycle.ts +1 -1
- package/core/client/security/attribute-presence.ts +16 -1
- package/core/client/theme/theme-engine.ts +42 -14
- package/core/client/typography/typography-base.ts +1 -1
- package/core/index.ts +25 -13
- package/core/server/host/csp-nonce-metadata.ts +1 -1
- package/core/server/host/published-page-assets.ts +30 -0
- package/core/server/host/soma-page-compile.ts +1 -1
- package/core/server/index.ts +2 -2
- package/core/server/registry/page-registry-store.ts +1 -1
- package/core/shared/published-page-route.ts +61 -0
- package/core/shared/types/adaptive.types.ts +1 -1
- package/core/shared/types/data-config.types.ts +30 -2
- package/core/shared/types/scope-manifest.types.ts +11 -15
- package/core/shared/types/style-config.types.ts +4 -4
- package/dist/cli/soma.js +15 -2
- package/dist/core/index.cjs +171 -77
- package/dist/types/build/{v2 → blocks}/block-compile.d.ts +7 -7
- package/dist/types/build/{v2/soma-file-loader.d.ts → blocks/block-container.d.ts} +6 -6
- package/dist/types/build/{v2/migrate-v1.d.ts → blocks/migrate-flat.d.ts} +6 -6
- package/dist/types/client/component/contract-compat.d.ts +2 -2
- package/dist/types/client/component/example-blocks.d.ts +9 -0
- package/dist/types/client/infra/notify/DomNotifyService.d.ts +2 -1
- package/dist/types/client/infra/notify/INotifyTheme.d.ts +1 -1
- package/dist/types/client/parser/{v2 → blocks}/page-parser.d.ts +2 -2
- package/dist/types/client/parser/{v2 → blocks}/use-parser.d.ts +1 -1
- package/dist/types/client/parser/style-config-parser.d.ts +1 -1
- package/dist/types/client/registry/index.d.ts +1 -0
- package/dist/types/client/theme/theme-engine.d.ts +11 -0
- package/dist/types/index.d.ts +8 -7
- package/dist/types/server/host/published-page-assets.d.ts +20 -0
- package/dist/types/server/index.d.ts +1 -1
- package/dist/types/server/registry/page-registry-store.d.ts +1 -1
- package/dist/types/shared/published-page-route.d.ts +21 -0
- package/dist/types/shared/types/data-config.types.d.ts +18 -2
- package/dist/types/shared/types/scope-manifest.types.d.ts +11 -11
- package/dist/types/shared/types/style-config.types.d.ts +4 -4
- package/package.json +1 -6
- package/tsconfig.json +20 -7
- package/dist/types/client/component/example-v2.d.ts +0 -9
- package/postcss.config.js +0 -6
- package/tailwind.config.ts +0 -43
- /package/dist/types/build/{v2 → blocks}/block-loader.d.ts +0 -0
- /package/dist/types/build/{v2 → blocks}/html-index.d.ts +0 -0
- /package/dist/types/client/parser/{v2 → blocks}/namespace.d.ts +0 -0
|
@@ -3,7 +3,15 @@
|
|
|
3
3
|
// 数据对象是业务抽象出的命名数据(如 order),来源是一个或多个后端接口;
|
|
4
4
|
// 组件与页面只认对象与字段,不认接口协议。
|
|
5
5
|
|
|
6
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* 字段类型枚举(决定 soma-ui 双态映射走哪个渲染组件)。
|
|
8
|
+
*
|
|
9
|
+
* **这是字段类型的唯一真源。** 块声明的 `fields.type` 与 soma-ui 的双态映射表
|
|
10
|
+
* 都必须消费它,不得各自再抄一份——此前正是抄成了三份:
|
|
11
|
+
* 数据对象层 11 型、soma-ui 11 型(逐字重复)、块声明 9 型(已漂)。
|
|
12
|
+
* 后果是 `type: url` 在块声明里被解析器拒收,而 `type: percent` 能过解析器
|
|
13
|
+
* 却在 soma-ui 侧没有映射、静默按 text 渲染出来。
|
|
14
|
+
*/
|
|
7
15
|
export type SomaDataFieldType =
|
|
8
16
|
| 'text'
|
|
9
17
|
| 'int'
|
|
@@ -15,7 +23,27 @@ export type SomaDataFieldType =
|
|
|
15
23
|
| 'datetime'
|
|
16
24
|
| 'image'
|
|
17
25
|
| 'url'
|
|
18
|
-
| 'richtext'
|
|
26
|
+
| 'richtext'
|
|
27
|
+
// 以下三型原本只在块声明侧存在,收编进唯一真源:
|
|
28
|
+
// percent 与 progress 是同一份数据的两种读法(前者出文字、后者出进度条)
|
|
29
|
+
| 'percent'
|
|
30
|
+
| 'progress';
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* 类型别名:块声明历史上用 `number` 表示小数,与本表的 `float` 同义。
|
|
34
|
+
* 保留为可接受拼写而不是二选一,是因为两边都有存量声明——
|
|
35
|
+
* 归一到 `float` 由解析器做,词汇表只认一个概念。
|
|
36
|
+
*/
|
|
37
|
+
export const SOMA_DATA_FIELD_TYPE_ALIASES: Readonly<Record<string, SomaDataFieldType>> = {
|
|
38
|
+
number: 'float',
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/** 全部合法字段类型(含别名),供解析器做封闭集校验 */
|
|
42
|
+
export const SOMA_DATA_FIELD_TYPES: readonly string[] = [
|
|
43
|
+
'text', 'int', 'float', 'money', 'bool', 'enum', 'date', 'datetime',
|
|
44
|
+
'image', 'url', 'richtext', 'percent', 'progress',
|
|
45
|
+
...Object.keys(SOMA_DATA_FIELD_TYPE_ALIASES),
|
|
46
|
+
];
|
|
19
47
|
|
|
20
48
|
/** 字段权限:r 只读 / w 可写(决定双态映射走 show 还是 edit 形态) */
|
|
21
49
|
export type SomaDataFieldPermission = 'r' | 'w';
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import type { SomaCompiledBinding, SomaCompiledEvent
|
|
1
|
+
import type { SomaCompiledBinding, SomaCompiledEvent } from './manifest.types';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* 作用域清单树(组件体系 P0)。
|
|
5
5
|
*
|
|
6
|
-
* 设计规范:soma-core/doc/soma 作用域清单树.md
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* 设计规范:soma-core/doc/archive/soma 作用域清单树.md(事实已并入《运行时引擎详设》)。
|
|
7
|
+
*
|
|
8
|
+
* **状态:目标模型,尚未物化。** 当前运行时以「实例级迷你运行时」承载同一语义
|
|
9
|
+
* (见《soma 运行时引擎详设》§4);本文件先把节点形状定下来,随契约编译器落地。
|
|
10
|
+
* 除下面的管道类型外,其余类型暂无消费者——改动它们不会影响运行行为。
|
|
9
11
|
*
|
|
10
12
|
* 节点结构保持可 JSON 序列化(仅数组/普通对象,无 Map)——构建期产物与
|
|
11
|
-
*
|
|
13
|
+
* 运行期客户端编译产物必须深度相等,索引一律在运行时装配。
|
|
12
14
|
*/
|
|
13
15
|
|
|
14
16
|
export type SomaScopeKind = 'page' | 'list' | 'component';
|
|
@@ -77,20 +79,14 @@ export interface SomaScopeNode {
|
|
|
77
79
|
listVar?: string;
|
|
78
80
|
/** 异构列表模板选择器的绑定路径(DSL 扩展规范 2.1,行模板后缀 = 该路径取值) */
|
|
79
81
|
roleBy?: string;
|
|
80
|
-
/**
|
|
82
|
+
/** 本作用域直属锚点的绑定(结构与扁平清单逐字段同构) */
|
|
81
83
|
bindings: SomaCompiledBinding[];
|
|
82
84
|
events: SomaCompiledEvent[];
|
|
83
85
|
children: SomaScopeNode[];
|
|
84
86
|
}
|
|
85
87
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
+
/** 作用域树形态的运行清单(目标模型,尚无产出者与消费者) */
|
|
89
|
+
export interface SomaScopeManifest {
|
|
88
90
|
root: SomaScopeNode;
|
|
89
91
|
initProps?: Record<string, unknown>;
|
|
90
92
|
}
|
|
91
|
-
|
|
92
|
-
export type SomaAnyRuntimeManifest = SomaRuntimeManifest | SomaRuntimeManifestV2;
|
|
93
|
-
|
|
94
|
-
export function isManifestV2(manifest: SomaAnyRuntimeManifest): manifest is SomaRuntimeManifestV2 {
|
|
95
|
-
return (manifest as SomaRuntimeManifestV2).version === 2;
|
|
96
|
-
}
|
|
@@ -19,7 +19,7 @@ export interface StyleStateRule {
|
|
|
19
19
|
condition: string;
|
|
20
20
|
/** 目标值(基础类型:string | number | boolean | null) */
|
|
21
21
|
value: string | number | boolean | null;
|
|
22
|
-
/** 匹配时应用的
|
|
22
|
+
/** 匹配时应用的 CSS 类名;具体样式由宿主样式系统提供 */
|
|
23
23
|
apply: string;
|
|
24
24
|
}
|
|
25
25
|
|
|
@@ -40,7 +40,7 @@ export type TransitionTrigger =
|
|
|
40
40
|
export interface StyleTransition {
|
|
41
41
|
/** 触发方式 */
|
|
42
42
|
trigger: TransitionTrigger;
|
|
43
|
-
/** 应用的
|
|
43
|
+
/** 应用的 CSS 动画/过渡类名;具体样式由宿主样式系统提供 */
|
|
44
44
|
apply: string;
|
|
45
45
|
/** active_state 类型时的条件路径 */
|
|
46
46
|
condition?: string;
|
|
@@ -59,7 +59,7 @@ export interface ThemeStatesOverride {
|
|
|
59
59
|
* 单个主题配置
|
|
60
60
|
*/
|
|
61
61
|
export interface ThemeConfig {
|
|
62
|
-
/** 基础类名覆盖:somaId →
|
|
62
|
+
/** 基础类名覆盖:somaId → CSS 类名 */
|
|
63
63
|
base: Record<string, string>;
|
|
64
64
|
/** 状态规则覆盖 */
|
|
65
65
|
states: ThemeStatesOverride;
|
|
@@ -74,7 +74,7 @@ export interface ThemeConfig {
|
|
|
74
74
|
export interface StyleConfig {
|
|
75
75
|
/** 所属的业务对象标识(对应 data-soma-host) */
|
|
76
76
|
host: string;
|
|
77
|
-
/** 基础静态样式映射:somaId →
|
|
77
|
+
/** 基础静态样式映射:somaId → CSS 类名 */
|
|
78
78
|
base: Record<string, string>;
|
|
79
79
|
/** 状态驱动样式:somaId → 规则数组 */
|
|
80
80
|
states: Record<string, StyleStateRule[]>;
|
package/dist/cli/soma.js
CHANGED
|
@@ -76,6 +76,20 @@ function linkOrCopy(targetPath, linkPath, type) {
|
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
|
+
/** Remove only the old framework-owned style config links from a generated workspace. */
|
|
80
|
+
function removeLegacyStyleConfigLinks(workspaceDir) {
|
|
81
|
+
for (const fileName of ['postcss.config.js', 'tailwind.config.ts']) {
|
|
82
|
+
const linkPath = node_path_1.default.join(workspaceDir, fileName);
|
|
83
|
+
const stat = lstatIfPresent(linkPath);
|
|
84
|
+
if (!stat?.isSymbolicLink())
|
|
85
|
+
continue;
|
|
86
|
+
const linkedTarget = node_path_1.default.resolve(node_path_1.default.dirname(linkPath), node_fs_1.default.readlinkSync(linkPath));
|
|
87
|
+
const legacyTarget = node_path_1.default.resolve(node_path_1.default.join(packageRoot, fileName));
|
|
88
|
+
if (linkedTarget === legacyTarget) {
|
|
89
|
+
node_fs_1.default.unlinkSync(linkPath);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
79
93
|
function copyDirectory(targetPath, destPath) {
|
|
80
94
|
const existingDest = rejectWorkspaceSymlink(destPath);
|
|
81
95
|
if (existingDest) {
|
|
@@ -394,13 +408,12 @@ function ensureNextWorkspace(hostDir) {
|
|
|
394
408
|
node_fs_1.default.mkdirSync(workspaceDir, { recursive: true });
|
|
395
409
|
writeFileIfChanged(node_path_1.default.join(workspaceDir, 'package.json'), JSON.stringify({ private: true, name: 'soma-next-workspace' }, null, 2) + '\n');
|
|
396
410
|
copyDirectory(node_path_1.default.join(packageRoot, 'app'), node_path_1.default.join(workspaceDir, 'app'));
|
|
411
|
+
removeLegacyStyleConfigLinks(workspaceDir);
|
|
397
412
|
linkOrCopy(node_path_1.default.join(packageRoot, 'core'), node_path_1.default.join(workspaceDir, 'core'), 'dir');
|
|
398
413
|
const legacyMiddleware = node_path_1.default.join(workspaceDir, 'middleware.ts');
|
|
399
414
|
if (lstatIfPresent(legacyMiddleware))
|
|
400
415
|
node_fs_1.default.unlinkSync(legacyMiddleware);
|
|
401
416
|
linkOrCopy(node_path_1.default.join(packageRoot, 'proxy.ts'), node_path_1.default.join(workspaceDir, 'proxy.ts'), 'file');
|
|
402
|
-
linkOrCopy(node_path_1.default.join(packageRoot, 'postcss.config.js'), node_path_1.default.join(workspaceDir, 'postcss.config.js'), 'file');
|
|
403
|
-
linkOrCopy(node_path_1.default.join(packageRoot, 'tailwind.config.ts'), node_path_1.default.join(workspaceDir, 'tailwind.config.ts'), 'file');
|
|
404
417
|
linkOrCopy(node_path_1.default.join(packageRoot, 'global.d.ts'), node_path_1.default.join(workspaceDir, 'global.d.ts'), 'file');
|
|
405
418
|
ensureHostPublicAssets(hostDir, workspaceDir);
|
|
406
419
|
const hasWorkspaceNodeModules = ensureWorkspaceNodeModules(workspaceDir);
|