soma-core 1.3.3 → 1.3.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.
- package/README.md +7 -6
- package/app/SomaPageClient.tsx +2 -72
- package/bin/soma-lsp.cjs +1 -4
- package/core/build/compiler/full-manifest-builder.ts +17 -26
- package/core/build/compiler/html-include-expander.ts +56 -0
- package/core/build/compiler/page-assets.ts +26 -0
- package/core/build/compiler/page-declaration-compiler.ts +85 -0
- package/core/build/compiler/rollup-plugin-soma.ts +4 -19
- package/core/build/compiler/route-builder.ts +0 -2
- package/core/build/compiler/rspack-plugin-soma.js +1 -10
- package/core/build/compiler/soma-manifest-webpack-plugin.js +54 -13
- package/core/build/compiler/soma-precompile.js +74 -0
- package/core/build/compiler/soma-precompile.ts +13 -0
- package/core/build/compiler/soma-rspack-yaml-loader.js +5 -11
- package/core/build/compiler/soma-webpack-loader.js +6 -21
- package/core/build/compiler/vite-plugin-soma.ts +9 -31
- package/core/build/component/pack-from-dir.ts +58 -0
- package/core/build/component/package-loader.ts +158 -12
- package/core/build/eject/plan-eject.ts +15 -21
- package/core/build/lsp/cross-file-diagnostics.cjs +82 -113
- package/core/build/lsp/extra-completion.cjs +14 -8
- package/core/build/lsp/lsp-navigation.cjs +50 -43
- package/core/build/lsp/soma-declaration.cjs +85 -0
- package/core/build/lsp/ui-yaml-completion.cjs +98 -104
- package/core/build/v2/block-compile.ts +200 -0
- package/core/build/v2/block-loader.ts +33 -0
- package/core/build/v2/html-index.ts +120 -0
- package/core/build/v2/migrate-v1.ts +370 -0
- package/core/build/v2/soma-file-loader.ts +216 -0
- package/core/client/component/ai-catalog.ts +15 -0
- package/core/client/component/component-pack.ts +205 -31
- package/core/client/component/contract-compat.ts +132 -0
- package/core/client/component/example-v2.ts +132 -0
- package/core/client/engine/dom-renderer.ts +14 -8
- package/core/client/engine/reactive-proxy.ts +8 -7
- package/core/client/engine/soma-bootstrap.ts +23 -5
- package/core/client/parser/v2/namespace.ts +182 -0
- package/core/client/parser/v2/page-parser.ts +359 -0
- package/core/client/parser/v2/use-parser.ts +412 -0
- package/core/client/parser/value-lang.ts +340 -0
- package/core/client/pipes/pipe-registry.ts +1 -1
- package/core/client/registry/declaration-renderer.ts +17 -15
- package/core/client/theme/harmony.ts +307 -0
- package/core/client/theme/scene-tokens.ts +134 -0
- package/core/client/theme/theme-axes.ts +228 -0
- package/core/client/theme/theme-engine.ts +333 -73
- package/core/client/theme/tone-solver.ts +118 -0
- package/core/index.ts +74 -2
- package/core/server/host/server-page-assets.ts +33 -16
- package/core/server/host/soma-page-compile.ts +33 -0
- package/core/server/index.ts +15 -0
- package/core/server/registry/declaration-precompiler.ts +24 -54
- package/core/server/registry/page-registry-store.ts +38 -9
- package/core/server/registry/services/pages/Get.ts +19 -9
- package/core/server/registry/validation/compile-gate.ts +14 -31
- package/core/server/registry/validation/cross-check.ts +7 -17
- package/core/server/registry/validation/declaration-safety-scan.ts +2 -2
- package/core/shared/types/component-contract.types.ts +10 -0
- package/dist/core/index.cjs +2138 -154
- package/dist/types/build/compiler/full-manifest-builder.d.ts +4 -4
- package/dist/types/build/compiler/html-include-expander.d.ts +19 -0
- package/dist/types/build/compiler/page-assets.d.ts +3 -0
- package/dist/types/build/compiler/page-declaration-compiler.d.ts +33 -0
- package/dist/types/build/compiler/rollup-plugin-soma.d.ts +0 -3
- package/dist/types/build/compiler/route-builder.d.ts +0 -1
- package/dist/types/build/compiler/soma-precompile.d.ts +8 -0
- package/dist/types/build/compiler/vite-plugin-soma.d.ts +2 -10
- package/dist/types/build/component/pack-from-dir.d.ts +17 -0
- package/dist/types/build/component/package-loader.d.ts +33 -2
- package/dist/types/build/v2/block-compile.d.ts +28 -0
- package/dist/types/build/v2/block-loader.d.ts +9 -0
- package/dist/types/build/v2/html-index.d.ts +37 -0
- package/dist/types/build/v2/migrate-v1.d.ts +32 -0
- package/dist/types/build/v2/soma-file-loader.d.ts +45 -0
- package/dist/types/client/component/component-pack.d.ts +23 -3
- package/dist/types/client/component/contract-compat.d.ts +16 -0
- package/dist/types/client/component/example-v2.d.ts +9 -0
- package/dist/types/client/engine/dom-renderer.d.ts +2 -0
- package/dist/types/client/engine/soma-bootstrap.d.ts +3 -1
- package/dist/types/client/parser/v2/namespace.d.ts +52 -0
- package/dist/types/client/parser/v2/page-parser.d.ts +21 -0
- package/dist/types/client/parser/v2/use-parser.d.ts +72 -0
- package/dist/types/client/parser/value-lang.d.ts +63 -0
- package/dist/types/client/registry/declaration-renderer.d.ts +1 -2
- package/dist/types/client/theme/harmony.d.ts +77 -0
- package/dist/types/client/theme/scene-tokens.d.ts +25 -0
- package/dist/types/client/theme/theme-axes.d.ts +81 -0
- package/dist/types/client/theme/theme-engine.d.ts +29 -1
- package/dist/types/client/theme/tone-solver.d.ts +47 -0
- package/dist/types/index.d.ts +13 -2
- package/dist/types/server/host/server-page-assets.d.ts +1 -4
- package/dist/types/server/host/soma-page-compile.d.ts +7 -0
- package/dist/types/server/index.d.ts +3 -1
- package/dist/types/server/registry/declaration-precompiler.d.ts +3 -3
- package/dist/types/server/registry/page-registry-store.d.ts +4 -4
- package/dist/types/server/registry/validation/compile-gate.d.ts +2 -0
- package/dist/types/server/registry/validation/cross-check.d.ts +4 -4
- package/dist/types/shared/types/component-contract.types.d.ts +10 -0
- package/editor/vscode/package.json +1 -24
- package/global.d.ts +1 -11
- package/next.config.js +32 -50
- package/package.json +3 -2
- package/tailwind.config.ts +0 -1
- package/core/build/lsp/event-yaml-completion.cjs +0 -106
- package/core/client/host-bridge/empty-host/data/README.md +0 -17
- package/editor/vscode/syntaxes/soma-event-yaml.tmLanguage.json +0 -30
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// 干跑编译闸门:注册期把声明真的过一遍解析器,编不过即拒。
|
|
2
2
|
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
3
|
+
// 为什么必须有:注册中心不能只做静态扫描与体积预算——直到某个访客打开页面
|
|
4
|
+
// 才在浏览器里炸。声明是"注册即生效"的资产,
|
|
5
5
|
// 失败面必须前移到注册这一刻,而不是留给每一个访客各撞一次。
|
|
6
6
|
//
|
|
7
7
|
// 与预编译缓存的分工(两件事,别混):
|
|
@@ -16,19 +16,16 @@
|
|
|
16
16
|
// 2. 拒绝文案**原样带上解析器自己的报错**。看到"缺少必填字段 show"就知道是声明的事;
|
|
17
17
|
// 看到不像声明问题的内部错误,那就该去查产物是不是陈旧了。
|
|
18
18
|
//
|
|
19
|
-
//
|
|
20
|
-
// dataYaml 也不在:交叉校验为了取出接口路径本来就要解析它,失败在那边如实报出。
|
|
19
|
+
// HTML 与统一声明必须一起编译,因为锚点归属是语言语义的一部分。
|
|
21
20
|
|
|
22
|
-
import {
|
|
23
|
-
compileEventConfig,
|
|
24
|
-
compileStyleConfig,
|
|
25
|
-
compileUiConfig,
|
|
26
|
-
} from '../../../build/compiler/soma-precompile';
|
|
21
|
+
import { compilePageDeclaration } from '../../../build/compiler/page-declaration-compiler';
|
|
27
22
|
|
|
28
23
|
export interface CompilableDeclaration {
|
|
24
|
+
html: string;
|
|
29
25
|
uiYaml: string;
|
|
30
26
|
eventYaml?: string;
|
|
31
27
|
styleYaml?: string;
|
|
28
|
+
dataYaml?: string;
|
|
32
29
|
}
|
|
33
30
|
|
|
34
31
|
function message(error: unknown): string {
|
|
@@ -42,30 +39,16 @@ function message(error: unknown): string {
|
|
|
42
39
|
export function dryRunCompile(declaration: CompilableDeclaration): string[] {
|
|
43
40
|
const issues: string[] = [];
|
|
44
41
|
|
|
45
|
-
// ui.yaml 必编:运行时没有它就渲染不出任何东西
|
|
46
42
|
try {
|
|
47
|
-
|
|
43
|
+
compilePageDeclaration({
|
|
44
|
+
html: declaration.html ?? '',
|
|
45
|
+
uiYaml: declaration.uiYaml ?? '',
|
|
46
|
+
...(declaration.eventYaml ? { eventYaml: declaration.eventYaml } : {}),
|
|
47
|
+
...(declaration.styleYaml ? { styleYaml: declaration.styleYaml } : {}),
|
|
48
|
+
...(declaration.dataYaml ? { dataYaml: declaration.dataYaml } : {}),
|
|
49
|
+
});
|
|
48
50
|
} catch (error) {
|
|
49
|
-
issues.push(`[编译]
|
|
51
|
+
issues.push(`[编译] SOMA DSL 声明编译不过:${message(error)}`);
|
|
50
52
|
}
|
|
51
|
-
|
|
52
|
-
// event.yaml 可以为空(纯展示页),给了就必须编得过
|
|
53
|
-
const eventYaml = declaration.eventYaml ?? '';
|
|
54
|
-
if (eventYaml.trim()) {
|
|
55
|
-
try {
|
|
56
|
-
compileEventConfig(eventYaml);
|
|
57
|
-
} catch (error) {
|
|
58
|
-
issues.push(`[编译] event.yaml 编译不过:${message(error)}`);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
if (declaration.styleYaml?.trim()) {
|
|
63
|
-
try {
|
|
64
|
-
compileStyleConfig(declaration.styleYaml);
|
|
65
|
-
} catch (error) {
|
|
66
|
-
issues.push(`[编译] style.yaml 编译不过:${message(error)}`);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
53
|
return issues;
|
|
71
54
|
}
|
|
@@ -6,12 +6,11 @@
|
|
|
6
6
|
// 而不是靠模型自觉:安全边界由校验闸门数学保证。
|
|
7
7
|
//
|
|
8
8
|
// 两个刻意的设计:
|
|
9
|
-
// 1.
|
|
10
|
-
// YAML 怎么写(缩进/flow 式/引号)都不影响判定;顺带 dataYaml 语法错误也在这里暴露。
|
|
9
|
+
// 1. **消费统一编译产物,不用正则**:声明只编译一次,再从 SomaDataConfig 收集路径。
|
|
11
10
|
// 2. **匹配键是路径不是注册名**:页面声明里写的就是路径,注册名只是人和清单用的标识。
|
|
12
11
|
// 查询串与 hash 在比较前剥掉——`/api/orders?page=1` 与 `/api/orders` 是同一个接口。
|
|
13
12
|
|
|
14
|
-
import {
|
|
13
|
+
import type { SomaDataConfig } from '../../../shared/types/data-config.types';
|
|
15
14
|
import { getApiRegistryStore } from '../api-registry-store';
|
|
16
15
|
|
|
17
16
|
/** 已注册路径的来源;测试与特殊宿主可替换(默认读共享 API 注册表) */
|
|
@@ -35,12 +34,10 @@ export function normalizeApiPath(raw: string): string {
|
|
|
35
34
|
}
|
|
36
35
|
|
|
37
36
|
/**
|
|
38
|
-
*
|
|
39
|
-
* dataYaml 为空或解析不出对象时返回空数组——没有取数就没有可校验的东西。
|
|
37
|
+
* 收集统一声明编译产物里引用到的全部接口路径(已归一化,去重、有序)。
|
|
40
38
|
*/
|
|
41
|
-
export function collectDeclaredApiPaths(
|
|
42
|
-
if (!
|
|
43
|
-
const config = compileDataConfig(dataYaml);
|
|
39
|
+
export function collectDeclaredApiPaths(config: SomaDataConfig | undefined): string[] {
|
|
40
|
+
if (!config) return [];
|
|
44
41
|
const paths = new Set<string>();
|
|
45
42
|
for (const object of Object.values(config.objects ?? {})) {
|
|
46
43
|
for (const source of object.from ?? []) {
|
|
@@ -56,15 +53,8 @@ export function collectDeclaredApiPaths(dataYaml: string | undefined): string[]
|
|
|
56
53
|
* 交叉校验,返回中文问题清单(空数组 = 通过)。
|
|
57
54
|
* 与安全扫描同款约定:命中即拒,清单点名到具体路径与数据对象,便于自修复。
|
|
58
55
|
*/
|
|
59
|
-
export function crossCheckDeclaredApis(
|
|
60
|
-
|
|
61
|
-
try {
|
|
62
|
-
declared = collectDeclaredApiPaths(dataYaml);
|
|
63
|
-
} catch (error) {
|
|
64
|
-
// dataYaml 自己就编不过:这同样是"声明不合格",在这里如实说出来而不是放行
|
|
65
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
66
|
-
return [`[取数] data.yaml 解析失败:${message}`];
|
|
67
|
-
}
|
|
56
|
+
export function crossCheckDeclaredApis(config: SomaDataConfig | undefined): string[] {
|
|
57
|
+
const declared = collectDeclaredApiPaths(config);
|
|
68
58
|
if (declared.length === 0) return [];
|
|
69
59
|
|
|
70
60
|
const registered = registeredPaths();
|
|
@@ -64,14 +64,14 @@ export function scanDeclarationSafety(declaration: ScannableDeclaration): string
|
|
|
64
64
|
if (forbidden.length > 0) {
|
|
65
65
|
issues.push(
|
|
66
66
|
`[安全] html 含禁用标签 ${forbidden.map((tag) => `<${tag}>`).join('、')}`
|
|
67
|
-
+ '
|
|
67
|
+
+ '——声明态页面不许自带脚本与外链资源;样式状态与事件必须写进 canonical _ui.yaml,受信任能力封装为 Host 组件',
|
|
68
68
|
);
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
if (INLINE_HANDLER_RE.test(html)) {
|
|
72
72
|
issues.push(
|
|
73
73
|
'[安全] html 含内联事件属性(on*=…)'
|
|
74
|
-
+ '——innerHTML
|
|
74
|
+
+ '——innerHTML 挂载时这类属性会立刻执行,事件一律写入 canonical _ui.yaml 的四动词 Pipeline',
|
|
75
75
|
);
|
|
76
76
|
}
|
|
77
77
|
|
|
@@ -107,4 +107,14 @@ export interface SomaComponentContract {
|
|
|
107
107
|
emits?: Record<string, SomaContractEmit>;
|
|
108
108
|
slots?: Record<string, SomaContractSlot>;
|
|
109
109
|
ai?: SomaContractAiSection;
|
|
110
|
+
/**
|
|
111
|
+
* 声明式覆盖:本组件有意替换该包里的同名组件(值为被覆盖组件的来源包名,如 'soma-ui')。
|
|
112
|
+
*
|
|
113
|
+
* 为什么写在契约上而不是宿主 bootstrap 里:覆盖意图与组件同处、随组件评审、
|
|
114
|
+
* 宿主零维护。合成时 `composeComponentPacks` 收集本字段构建覆盖表,并强制过
|
|
115
|
+
* 契约兼容闸门(props 超集 + emit 全保留),保证"优化存量组件、页面零改动"。
|
|
116
|
+
*
|
|
117
|
+
* 未声明的跨包撞名一律抛错——写出来的覆盖是设计决定,猜出来的覆盖是事故。
|
|
118
|
+
*/
|
|
119
|
+
overrides?: string;
|
|
110
120
|
}
|