soma-core 1.3.2 → 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 +43 -0
- package/app/SomaPageClient.tsx +22 -68
- package/app/[...path]/page.tsx +7 -6
- package/app/api/[...path]/route.ts +3 -3
- package/app/api/soma-registry/[...path]/route.ts +67 -0
- package/app/components/SomaHostPage.tsx +3 -8
- package/app/components/SomaPageClientBoundary.tsx +13 -0
- package/app/layout.tsx +6 -1
- package/app/page.tsx +3 -3
- package/app/soma/manifest/route.ts +1 -0
- package/app/soma/page-object/route.ts +1 -1
- package/bin/soma-lsp.cjs +1 -4
- package/core/build/compiler/full-manifest-builder.ts +19 -23
- 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 -13
- 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 -9
- package/core/build/compiler/soma-precompile.js +3581 -2387
- package/core/build/compiler/soma-precompile.ts +44 -2
- package/core/build/compiler/soma-rspack-yaml-loader.js +5 -8
- package/core/build/compiler/soma-webpack-loader.js +6 -15
- package/core/build/compiler/vite-plugin-soma.ts +9 -21
- package/core/build/component/pack-from-dir.ts +58 -0
- package/core/build/component/package-loader.ts +281 -0
- package/core/build/eject/apply-eject.ts +133 -0
- package/core/build/eject/plan-eject.ts +133 -0
- 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/adaptive/flush-scheduler.ts +96 -0
- package/core/client/adaptive/hysteresis.ts +56 -0
- package/core/client/adaptive/index.ts +23 -0
- package/core/client/adaptive/observer-pool.ts +90 -0
- package/core/client/base/SomaPageRootBase.ts +50 -0
- package/core/client/compiler/adaptive-compile.ts +136 -0
- package/core/client/compiler/manifest-compiler.ts +155 -27
- package/core/client/component/ai-catalog.ts +277 -0
- package/core/client/component/component-definition.types.ts +65 -0
- package/core/client/component/component-expander.ts +119 -0
- package/core/client/component/component-manager.ts +933 -0
- package/core/client/component/component-pack.ts +445 -0
- package/core/client/component/component-registry.ts +71 -0
- package/core/client/component/contract-compat.ts +132 -0
- package/core/client/component/example-v2.ts +132 -0
- package/core/client/component/pack-styles.ts +94 -0
- package/core/client/component/scoped-adapter.ts +85 -0
- package/core/client/component/verify-pack.ts +247 -0
- package/core/client/container/MiniProgramContainerAdapter.ts +15 -1
- package/core/client/container/ReactNativeContainerAdapter.ts +15 -1
- package/core/client/container/SomaContainerAdapter.ts +186 -180
- package/core/client/data/data-object-resolver.ts +417 -0
- package/core/client/diagnostics/SomaDiagnostics.ts +187 -186
- package/core/client/diagnostics/boot-timings.ts +152 -0
- package/core/client/engine/asset-resolver.ts +12 -2
- package/core/client/engine/dom-renderer.ts +249 -24
- package/core/client/engine/emit-event.ts +21 -0
- package/core/client/engine/event-engine.ts +34 -4
- package/core/client/engine/on-change-engine.ts +1 -1
- package/core/client/engine/property-watcher.ts +1 -1
- package/core/client/engine/reactive-proxy.ts +11 -10
- package/core/client/engine/render-engine.ts +39 -4
- package/core/client/engine/runtime-builder.ts +23 -0
- package/core/client/engine/soma-bootstrap.ts +380 -7
- package/core/client/engine/style-binder.ts +47 -1
- package/core/client/observability/error-reporter.ts +173 -0
- package/core/client/parser/adaptive-parser.ts +264 -0
- package/core/client/parser/data-config-parser.ts +396 -0
- package/core/client/parser/pipeline-parser.ts +15 -3
- package/core/client/parser/style-config-parser.ts +65 -2
- package/core/client/parser/ui-config-parser.ts +52 -3
- 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 +249 -0
- package/core/client/quality/SomaQualityRegistry.ts +3 -0
- package/core/client/registry/declaration-renderer.ts +161 -0
- package/core/client/registry/index.ts +28 -0
- package/core/client/registry/page-lifecycle.ts +171 -0
- package/core/client/registry/remote-page.ts +139 -0
- package/core/client/runtime/SomaRuntimeServices.ts +24 -0
- package/core/client/security/attribute-presence.ts +70 -0
- package/core/client/security/html-sanitizer.ts +113 -0
- package/core/client/security/url-guard.ts +0 -0
- 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 +1196 -0
- package/core/client/theme/tone-solver.ts +118 -0
- package/core/client/typography/typography-base.ts +34 -0
- package/core/client/validation/contract-validator.ts +48 -5
- package/core/index.ts +262 -2
- package/core/server/api/IService.ts +18 -6
- package/core/server/api/load-host-service.ts +3 -3
- package/core/server/host/content-security-policy.ts +190 -0
- package/core/server/host/csp-nonce-metadata.ts +75 -0
- package/core/server/host/resolve-host-request-hook.ts +5 -0
- package/core/server/host/server-page-assets.ts +34 -7
- package/core/server/host/soma-page-compile.ts +33 -0
- package/core/server/index.ts +45 -1
- package/core/server/infra/cache/ServerFileCache.ts +1 -1
- package/core/server/mock/node/cli.mjs +2 -2
- package/core/server/registry/api-registry-store.ts +518 -0
- package/core/server/registry/conditional-object-store.ts +29 -0
- package/core/server/registry/declaration-precompiler.ts +99 -0
- package/core/server/registry/in-memory-conditional-object-store.ts +43 -0
- package/core/server/registry/index.ts +142 -0
- package/core/server/registry/page-registry-repository.ts +373 -0
- package/core/server/registry/page-registry-store.ts +932 -0
- package/core/server/registry/registry-error.ts +17 -0
- package/core/server/registry/registry-file-lock.ts +173 -0
- package/core/server/registry/registry-response.ts +71 -0
- package/core/server/registry/registry-subjects.ts +194 -0
- package/core/server/registry/registry-write-pipeline.ts +240 -0
- package/core/server/registry/request-body-limit.ts +99 -0
- package/core/server/registry/services/apis/Get.ts +25 -0
- package/core/server/registry/services/apis/List.ts +41 -0
- package/core/server/registry/services/apis/Register.ts +39 -0
- package/core/server/registry/services/apis/Unregister.ts +24 -0
- package/core/server/registry/services/index.ts +40 -0
- package/core/server/registry/services/pages/Get.ts +96 -0
- package/core/server/registry/services/pages/List.ts +53 -0
- package/core/server/registry/services/pages/Register.ts +49 -0
- package/core/server/registry/services/pages/Rollback.ts +36 -0
- package/core/server/registry/services/pages/Unregister.ts +23 -0
- package/core/server/registry/services/service-utils.ts +21 -0
- package/core/server/registry/validation/compile-gate.ts +54 -0
- package/core/server/registry/validation/component-existence.ts +55 -0
- package/core/server/registry/validation/credential-ban.ts +86 -0
- package/core/server/registry/validation/cross-check.ts +67 -0
- package/core/server/registry/validation/declaration-safety-scan.ts +102 -0
- package/core/shared/types/adaptive.types.ts +109 -0
- package/core/shared/types/component-contract.types.ts +120 -0
- package/core/shared/types/data-config.types.ts +105 -0
- package/core/shared/types/domain.types.ts +6 -0
- package/core/shared/types/engine.types.ts +41 -35
- package/core/shared/types/manifest.types.ts +55 -32
- package/core/shared/types/scope-manifest.types.ts +96 -0
- package/core/shared/types/style-config.types.ts +9 -0
- package/core/shared/types/ui-config.types.ts +118 -98
- package/dist/cli/soma.js +20 -5
- package/dist/core/index.cjs +7811 -1380
- package/dist/types/build/compiler/full-manifest-builder.d.ts +6 -2
- 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 -2
- package/dist/types/build/compiler/route-builder.d.ts +0 -1
- package/dist/types/build/compiler/soma-precompile.d.ts +17 -0
- package/dist/types/build/compiler/vite-plugin-soma.d.ts +2 -7
- package/dist/types/build/component/pack-from-dir.d.ts +17 -0
- package/dist/types/build/component/package-loader.d.ts +40 -0
- package/dist/types/build/eject/apply-eject.d.ts +22 -0
- package/dist/types/build/eject/plan-eject.d.ts +32 -0
- 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/adaptive/flush-scheduler.d.ts +13 -0
- package/dist/types/client/adaptive/hysteresis.d.ts +16 -0
- package/dist/types/client/adaptive/index.d.ts +5 -0
- package/dist/types/client/adaptive/observer-pool.d.ts +15 -0
- package/dist/types/client/base/SomaPageRootBase.d.ts +33 -0
- package/dist/types/client/compiler/adaptive-compile.d.ts +26 -0
- package/dist/types/client/compiler/manifest-compiler.d.ts +13 -2
- package/dist/types/client/component/ai-catalog.d.ts +73 -0
- package/dist/types/client/component/component-definition.types.d.ts +54 -0
- package/dist/types/client/component/component-expander.d.ts +25 -0
- package/dist/types/client/component/component-manager.d.ts +160 -0
- package/dist/types/client/component/component-pack.d.ts +110 -0
- package/dist/types/client/component/component-registry.d.ts +12 -0
- 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/component/pack-styles.d.ts +22 -0
- package/dist/types/client/component/scoped-adapter.d.ts +18 -0
- package/dist/types/client/component/verify-pack.d.ts +14 -0
- package/dist/types/client/data/data-object-resolver.d.ts +71 -0
- package/dist/types/client/diagnostics/SomaDiagnostics.d.ts +2 -1
- package/dist/types/client/diagnostics/boot-timings.d.ts +30 -0
- package/dist/types/client/engine/asset-resolver.d.ts +7 -1
- package/dist/types/client/engine/dom-renderer.d.ts +51 -1
- package/dist/types/client/engine/emit-event.d.ts +6 -0
- package/dist/types/client/engine/event-engine.d.ts +6 -0
- package/dist/types/client/engine/render-engine.d.ts +25 -1
- package/dist/types/client/engine/runtime-builder.d.ts +7 -0
- package/dist/types/client/engine/soma-bootstrap.d.ts +118 -0
- package/dist/types/client/observability/error-reporter.d.ts +51 -0
- package/dist/types/client/parser/adaptive-parser.d.ts +28 -0
- package/dist/types/client/parser/data-config-parser.d.ts +34 -0
- package/dist/types/client/parser/pipeline-parser.d.ts +2 -0
- package/dist/types/client/parser/style-config-parser.d.ts +5 -3
- package/dist/types/client/parser/ui-config-parser.d.ts +22 -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/pipes/pipe-registry.d.ts +38 -0
- package/dist/types/client/registry/declaration-renderer.d.ts +50 -0
- package/dist/types/client/registry/index.d.ts +10 -0
- package/dist/types/client/registry/page-lifecycle.d.ts +61 -0
- package/dist/types/client/registry/remote-page.d.ts +52 -0
- package/dist/types/client/runtime/SomaRuntimeServices.d.ts +16 -0
- package/dist/types/client/security/attribute-presence.d.ts +7 -0
- package/dist/types/client/security/html-sanitizer.d.ts +37 -0
- package/dist/types/client/security/url-guard.d.ts +11 -0
- 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 +77 -0
- package/dist/types/client/theme/tone-solver.d.ts +47 -0
- package/dist/types/client/typography/typography-base.d.ts +15 -0
- package/dist/types/client/validation/contract-validator.d.ts +2 -0
- package/dist/types/index.d.ts +47 -2
- package/dist/types/server/api/IService.d.ts +18 -6
- package/dist/types/server/host/content-security-policy.d.ts +53 -0
- package/dist/types/server/host/csp-nonce-metadata.d.ts +32 -0
- package/dist/types/server/host/resolve-host-request-hook.d.ts +5 -0
- package/dist/types/server/host/server-page-assets.d.ts +2 -0
- package/dist/types/server/host/soma-page-compile.d.ts +7 -0
- package/dist/types/server/index.d.ts +6 -1
- package/dist/types/server/registry/api-registry-store.d.ts +141 -0
- package/dist/types/server/registry/conditional-object-store.d.ts +27 -0
- package/dist/types/server/registry/declaration-precompiler.d.ts +30 -0
- package/dist/types/server/registry/in-memory-conditional-object-store.d.ts +8 -0
- package/dist/types/server/registry/index.d.ts +29 -0
- package/dist/types/server/registry/page-registry-repository.d.ts +58 -0
- package/dist/types/server/registry/page-registry-store.d.ts +259 -0
- package/dist/types/server/registry/registry-error.d.ts +12 -0
- package/dist/types/server/registry/registry-file-lock.d.ts +20 -0
- package/dist/types/server/registry/registry-response.d.ts +18 -0
- package/dist/types/server/registry/registry-subjects.d.ts +59 -0
- package/dist/types/server/registry/registry-write-pipeline.d.ts +48 -0
- package/dist/types/server/registry/request-body-limit.d.ts +31 -0
- package/dist/types/server/registry/services/apis/Get.d.ts +10 -0
- package/dist/types/server/registry/services/apis/List.d.ts +10 -0
- package/dist/types/server/registry/services/apis/Register.d.ts +13 -0
- package/dist/types/server/registry/services/apis/Unregister.d.ts +12 -0
- package/dist/types/server/registry/services/index.d.ts +3 -0
- package/dist/types/server/registry/services/pages/Get.d.ts +10 -0
- package/dist/types/server/registry/services/pages/List.d.ts +13 -0
- package/dist/types/server/registry/services/pages/Register.d.ts +11 -0
- package/dist/types/server/registry/services/pages/Rollback.d.ts +9 -0
- package/dist/types/server/registry/services/pages/Unregister.d.ts +9 -0
- package/dist/types/server/registry/services/service-utils.d.ts +10 -0
- package/dist/types/server/registry/validation/compile-gate.d.ts +12 -0
- package/dist/types/server/registry/validation/component-existence.d.ts +14 -0
- package/dist/types/server/registry/validation/credential-ban.d.ts +15 -0
- package/dist/types/server/registry/validation/cross-check.d.ts +16 -0
- package/dist/types/server/registry/validation/declaration-safety-scan.d.ts +15 -0
- package/dist/types/shared/types/adaptive.types.d.ts +88 -0
- package/dist/types/shared/types/component-contract.types.d.ts +78 -0
- package/dist/types/shared/types/data-config.types.d.ts +81 -0
- package/dist/types/shared/types/domain.types.d.ts +6 -0
- package/dist/types/shared/types/engine.types.d.ts +6 -0
- package/dist/types/shared/types/manifest.types.d.ts +23 -0
- package/dist/types/shared/types/scope-manifest.types.d.ts +82 -0
- package/dist/types/shared/types/style-config.types.d.ts +8 -0
- package/dist/types/shared/types/ui-config.types.d.ts +20 -0
- package/editor/vscode/package.json +1 -24
- package/global.d.ts +5 -11
- package/next.config.js +85 -28
- package/package.json +33 -11
- package/proxy.ts +62 -0
- package/tailwind.config.ts +0 -1
- package/core/build/lsp/event-yaml-completion.cjs +0 -106
- package/core/client/engine/theme-variables.ts +0 -37
- package/dist/tsconfig.types.tsbuildinfo +0 -1
- package/dist/types/client/engine/theme-variables.d.ts +0 -3
- package/editor/vscode/syntaxes/soma-event-yaml.tmLanguage.json +0 -30
- package/middleware.ts +0 -33
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
// 色调求解(REQ-007 S2):明度是**解出来的**,不是写死的。
|
|
2
|
+
//
|
|
3
|
+
// 现状引擎里同一段 WCAG 循环出现了五次(主色、info、secondary/accent/neutral 的
|
|
4
|
+
// ensureBrandTone、successFg、warningFg),每次都是"不达标就推明度、最多 16 轮"。
|
|
5
|
+
// 本模块把那个循环提炼成一个原语 `pushLightnessUntil`,让五处共用一份实现——
|
|
6
|
+
// 五份拷贝里改对四份是这类代码的经典事故。
|
|
7
|
+
//
|
|
8
|
+
// 更重要的是方向反转:现状是"先写死明度、不达标再兜底修正",
|
|
9
|
+
// 本模块提供"给定目标对比度、正向解出明度"(Adobe Leonardo 的路线)。
|
|
10
|
+
// 这让 contrast 轴的三档成为**目标对比度的三组值**,而不是三组写死的明度常量。
|
|
11
|
+
//
|
|
12
|
+
// 纯函数模块:零全局、零缓存(memo 归编排者,沿用既有 onSoftMemo 的位置)。
|
|
13
|
+
|
|
14
|
+
import type { SomaAxisParams, SomaContrastTargets } from './theme-axes';
|
|
15
|
+
|
|
16
|
+
export interface Oklch { l: number; c: number; h: number }
|
|
17
|
+
|
|
18
|
+
/** 求解需要的色彩原语由编排者注入——本模块不 import theme-engine,避免循环依赖 */
|
|
19
|
+
export interface ToneSolverDeps {
|
|
20
|
+
oklchToHex(c: Oklch): string;
|
|
21
|
+
hexToOklch(hex: string): Oklch;
|
|
22
|
+
contrastRatio(a: string, b: string): number;
|
|
23
|
+
bestFg(bg: string): string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** 与现状五处循环一致的上限:推 16 轮仍不达标就交出当前最优 */
|
|
27
|
+
export const MAX_SOLVE_ITER = 16;
|
|
28
|
+
/** 与现状五处循环一致的步长 */
|
|
29
|
+
const STEP = 0.04;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* 沿明度方向推色直到谓词满足。
|
|
33
|
+
*
|
|
34
|
+
* **幂等**:谓词一开始就满足时原值返回——这条性质让"S3 推过色相后回跑 S2"
|
|
35
|
+
* 成为无脑安全的操作(未被推动的语气原样穿过,不会因为多跑一次而漂移)。
|
|
36
|
+
*/
|
|
37
|
+
export function pushLightnessUntil(
|
|
38
|
+
color: Oklch,
|
|
39
|
+
satisfied: (candidate: Oklch) => boolean,
|
|
40
|
+
direction: 'lighten' | 'darken',
|
|
41
|
+
maxIter: number = MAX_SOLVE_ITER,
|
|
42
|
+
): Oklch {
|
|
43
|
+
let current = color;
|
|
44
|
+
const delta = direction === 'lighten' ? STEP : -STEP;
|
|
45
|
+
for (let i = 0; i < maxIter && !satisfied(current); i += 1) {
|
|
46
|
+
current = { ...current, l: current.l + delta };
|
|
47
|
+
}
|
|
48
|
+
return current;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* 现状五处循环的等价封装:不达 AA 就推明度,推的方向按当前明暗自适应。
|
|
53
|
+
*
|
|
54
|
+
* 保留"方向按 l > 0.55 判定"这个既有行为——它不是随手写的:
|
|
55
|
+
* 亮色推更亮、暗色推更暗,才不会把一个中亮度的色推穿到对面去。
|
|
56
|
+
*/
|
|
57
|
+
export function ensureContrast(
|
|
58
|
+
bg: string,
|
|
59
|
+
deps: ToneSolverDeps,
|
|
60
|
+
minRatio = 4.5,
|
|
61
|
+
maxIter = MAX_SOLVE_ITER,
|
|
62
|
+
forceDirection?: 'lighten' | 'darken',
|
|
63
|
+
): { bg: string; fg: string } {
|
|
64
|
+
let current = bg;
|
|
65
|
+
let fg = deps.bestFg(current);
|
|
66
|
+
for (let i = 0; i < maxIter && deps.contrastRatio(current, fg) < minRatio; i += 1) {
|
|
67
|
+
const cur = deps.hexToOklch(current);
|
|
68
|
+
// 缺省的方向启发(亮色推更亮、暗色推更暗)在**分离场景下必须被覆盖**:
|
|
69
|
+
// 分离闸把一个语气推离品牌明度之后,若求解器按自己的启发把它又拉回去,
|
|
70
|
+
// 两个约束就在打架,结果是闸"推了但没推动"(terminalHacker 的绿品牌
|
|
71
|
+
// 实测停在 ΔL=0.105,差 0.015 达不到阈值)。有分离意图时方向由闸说了算。
|
|
72
|
+
const lighten = forceDirection ? forceDirection === 'lighten' : cur.l > 0.55;
|
|
73
|
+
current = deps.oklchToHex({ ...cur, l: lighten ? cur.l + STEP : cur.l - STEP });
|
|
74
|
+
fg = deps.bestFg(current);
|
|
75
|
+
}
|
|
76
|
+
return { bg: current, fg };
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* 解一个语气的实心底:命中 toneOnPage 目标。
|
|
81
|
+
*
|
|
82
|
+
* 前景(-fg)仍由既有 ④ 系代码解——那部分是实测校准过的 AA 保障,不在此重复。
|
|
83
|
+
*
|
|
84
|
+
* **裁决**:粉彩带约束与对比度目标冲突时**对比度赢**(AA 底线不随 contrast 档
|
|
85
|
+
* 移动,是《主题属性设计》§3 原则 4 的承诺)。带被突破时通过返回值旁路上报,
|
|
86
|
+
* 由编排者收进 meta,供观测——不报错,因为"带"是气质偏好不是硬约束。
|
|
87
|
+
*/
|
|
88
|
+
export function solveTone(
|
|
89
|
+
seed: Oklch,
|
|
90
|
+
pageHex: string,
|
|
91
|
+
target: SomaContrastTargets,
|
|
92
|
+
band: readonly [number, number] | null,
|
|
93
|
+
deps: ToneSolverDeps,
|
|
94
|
+
): { tone: Oklch; bandBroken: boolean } {
|
|
95
|
+
const meets = (candidate: Oklch): boolean =>
|
|
96
|
+
deps.contrastRatio(deps.oklchToHex(candidate), pageHex) >= target.toneOnPage;
|
|
97
|
+
|
|
98
|
+
// 带存在时先把种子夹进带内,再朝"离页面底更远"的方向推到达标
|
|
99
|
+
let start = seed;
|
|
100
|
+
let bandBroken = false;
|
|
101
|
+
if (band) {
|
|
102
|
+
start = { ...seed, l: Math.min(band[1], Math.max(band[0], seed.l)) };
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const pageL = deps.hexToOklch(pageHex).l;
|
|
106
|
+
const direction = start.l > pageL ? 'lighten' : 'darken';
|
|
107
|
+
const solved = pushLightnessUntil(start, meets, direction);
|
|
108
|
+
|
|
109
|
+
if (band && (solved.l < band[0] - 1e-6 || solved.l > band[1] + 1e-6)) {
|
|
110
|
+
bandBroken = true;
|
|
111
|
+
}
|
|
112
|
+
return { tone: solved, bandBroken };
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** 彩度个性:把 chroma 轴的乘数应用到一个种子彩度上(下限护栏防止推成死灰) */
|
|
116
|
+
export function applyChroma(baseChroma: number, params: SomaAxisParams): number {
|
|
117
|
+
return Math.max(0.02, baseChroma * params.chromaMul);
|
|
118
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// core/client/typography/typography-base.ts — 中文排版基线(F-05 / 契约 C2)
|
|
2
|
+
//
|
|
3
|
+
// 归属理由(arch/契约与边界.md §1):不用组件库的纯声明页面也应具备中文排版基线,
|
|
4
|
+
// 所以它是地基能力而不是组件资产。soma-ui 基座**引用而不复制**这个常量——
|
|
5
|
+
// 复制即产生第二份事实,G6 同源门判红。
|
|
6
|
+
//
|
|
7
|
+
// 作用域挂 `[data-soma-host]` 而不是 `:root`:core 是被宿主集成的框架,
|
|
8
|
+
// 污染宿主全局是越界;挂宿主根既覆盖全部 soma 渲染内容,又不碰宿主自有区域。
|
|
9
|
+
//
|
|
10
|
+
// 渐进增强,零兜底:四条款全部是"支持则更好",浏览器不支持时渲染即现状。
|
|
11
|
+
// **明确不做特性检测与 JS polyfill**——排版兜底的收益远低于其复杂度与性能代价,
|
|
12
|
+
// 因此本资产的运行时成本恒为零(无 JS、无监听、无测量)。
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* 中文排版基线样式。Host 集成时随主题一并注入。
|
|
16
|
+
*
|
|
17
|
+
* 条款与理由:
|
|
18
|
+
* - `text-autospace`:中西文之间的自动空隙(盘古之白)。
|
|
19
|
+
* 由排版引擎产生,手敲空格是内容污染——空格会进搜索索引、进复制粘贴、进后端字段。
|
|
20
|
+
* - `line-break: strict`:行首行尾禁则(避免"。"落行首、"("落行尾)。
|
|
21
|
+
* - `word-break: normal` + `overflow-wrap: break-word`:
|
|
22
|
+
* 中文按正常规则断,长 URL / 哈希这类无空格长串才允许强断,两者缺一都会出问题。
|
|
23
|
+
* - `hanging-punctuation: first last`:标点悬挂,让首尾行的文字边缘对齐。
|
|
24
|
+
*
|
|
25
|
+
* 不承诺竖排(`writing-mode`);繁体 / 日文的禁则差异走 i18n 层 locale 排版参数,
|
|
26
|
+
* 本资产只预留概念位。
|
|
27
|
+
*/
|
|
28
|
+
export const TYPOGRAPHY_BASE_CSS = `[data-soma-host] {
|
|
29
|
+
text-autospace: normal;
|
|
30
|
+
line-break: strict;
|
|
31
|
+
word-break: normal;
|
|
32
|
+
overflow-wrap: break-word;
|
|
33
|
+
hanging-punctuation: first last;
|
|
34
|
+
}`;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { SomaScopeResolver } from '../engine/scope-resolver';
|
|
2
|
+
import { hasPipes, parsePipedValue } from '../pipes/pipe-registry';
|
|
2
3
|
import type { ParsedEvent } from '../../shared/types/event.types';
|
|
3
4
|
import type {
|
|
4
5
|
ExtendedShowValue,
|
|
@@ -121,6 +122,29 @@ export class SomaContractValidator {
|
|
|
121
122
|
return { anchors, duplicates };
|
|
122
123
|
}
|
|
123
124
|
|
|
125
|
+
/** 展示值可携带格式化管道:仅校验管道前的基础路径与绑定型实参路径 */
|
|
126
|
+
private validatePipedPath(
|
|
127
|
+
rawValue: string,
|
|
128
|
+
currentPath: string,
|
|
129
|
+
resolver: SomaScopeResolver,
|
|
130
|
+
rootInstance: object,
|
|
131
|
+
report: SomaContractReport,
|
|
132
|
+
): void {
|
|
133
|
+
if (!hasPipes(rawValue)) {
|
|
134
|
+
this.validateReadablePath(rawValue, currentPath, resolver, rootInstance, report);
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
try {
|
|
138
|
+
const parsed = parsePipedValue(rawValue, (seg) => resolver.hasVar(seg));
|
|
139
|
+
this.validateReadablePath(parsed.basePath, currentPath, resolver, rootInstance, report);
|
|
140
|
+
for (const argPath of parsed.argPaths) {
|
|
141
|
+
this.validateReadablePath(argPath, `${currentPath}(pipe-arg)`, resolver, rootInstance, report);
|
|
142
|
+
}
|
|
143
|
+
} catch (error) {
|
|
144
|
+
this.addError(report, `${currentPath}: ${(error as Error).message}`);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
124
148
|
private validateShowMapping(
|
|
125
149
|
show: ShowMapping,
|
|
126
150
|
anchors: Set<string>,
|
|
@@ -132,6 +156,16 @@ export class SomaContractValidator {
|
|
|
132
156
|
for (const [rawKey, value] of Object.entries(show)) {
|
|
133
157
|
report.bindingCount += 1;
|
|
134
158
|
const currentPath = `${basePath}.${rawKey}`;
|
|
159
|
+
|
|
160
|
+
// 异构列表分组键(item:变体):本身不是锚点,仅递归校验子映射
|
|
161
|
+
if (/^item:.+/.test(rawKey)) {
|
|
162
|
+
const sub = (value as ExtendedShowValue | undefined)?.show;
|
|
163
|
+
if (sub) {
|
|
164
|
+
this.validateShowMapping(sub, anchors, resolver, rootInstance, report, currentPath);
|
|
165
|
+
}
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
|
|
135
169
|
const somaId = this.extractSomaId(rawKey);
|
|
136
170
|
|
|
137
171
|
if (!anchors.has(somaId)) {
|
|
@@ -139,7 +173,7 @@ export class SomaContractValidator {
|
|
|
139
173
|
}
|
|
140
174
|
|
|
141
175
|
if (typeof value === 'string') {
|
|
142
|
-
this.
|
|
176
|
+
this.validatePipedPath(value, currentPath, resolver, rootInstance, report);
|
|
143
177
|
continue;
|
|
144
178
|
}
|
|
145
179
|
|
|
@@ -164,7 +198,7 @@ export class SomaContractValidator {
|
|
|
164
198
|
|
|
165
199
|
if (this.isExtendedShowValue(value)) {
|
|
166
200
|
if (value.text) {
|
|
167
|
-
this.
|
|
201
|
+
this.validatePipedPath(
|
|
168
202
|
value.text,
|
|
169
203
|
`${currentPath}.text`,
|
|
170
204
|
resolver,
|
|
@@ -226,10 +260,19 @@ export class SomaContractValidator {
|
|
|
226
260
|
|
|
227
261
|
for (const event of events) {
|
|
228
262
|
const eventKey = `${event.domEvent}:${event.somaId}`;
|
|
229
|
-
|
|
230
|
-
|
|
263
|
+
// 去重要带上按键修饰符:同一个输入框绑 ↑ ↓ ← → Enter Esc 各一条是
|
|
264
|
+
// listbox/tablist/tree 的 ARIA 键盘模式的常规写法,不是重复声明。
|
|
265
|
+
// 只有"同锚点 + 同事件 + 同按键"才是真重复。
|
|
266
|
+
const dedupeKey = `${eventKey}:${event.keyModifier ?? ''}`;
|
|
267
|
+
if (eventKeys.has(dedupeKey)) {
|
|
268
|
+
this.addError(
|
|
269
|
+
report,
|
|
270
|
+
event.keyModifier
|
|
271
|
+
? `event.${eventKey}.${event.keyModifier}: 重复声明的事件绑定`
|
|
272
|
+
: `event.${eventKey}: 重复声明的事件绑定`,
|
|
273
|
+
);
|
|
231
274
|
} else {
|
|
232
|
-
eventKeys.add(
|
|
275
|
+
eventKeys.add(dedupeKey);
|
|
233
276
|
}
|
|
234
277
|
|
|
235
278
|
if (!anchors.has(event.somaId)) {
|
package/core/index.ts
CHANGED
|
@@ -6,14 +6,156 @@ export * from './client/base/index';
|
|
|
6
6
|
export type { SomaAppConfig, SomaPageRoot } from './shared/types/domain.types';
|
|
7
7
|
|
|
8
8
|
// Host API service contract
|
|
9
|
-
export type { IService } from './server/api/IService';
|
|
9
|
+
export type { IService, SomaServiceRequest } from './server/api/IService';
|
|
10
10
|
|
|
11
11
|
// Bootstrap & runtime
|
|
12
12
|
export { SomaBootstrap } from './client/engine/soma-bootstrap';
|
|
13
|
-
export type {
|
|
13
|
+
export type {
|
|
14
|
+
SomaPageAssets,
|
|
15
|
+
SomaBootstrapOptions,
|
|
16
|
+
SomaBootstrapErrorReporting,
|
|
17
|
+
} from './client/engine/soma-bootstrap';
|
|
18
|
+
|
|
19
|
+
// ── 组件体系(模块 7) ──
|
|
20
|
+
export { SomaComponentRegistry } from './client/component/component-registry';
|
|
21
|
+
export { SomaComponentManager } from './client/component/component-manager';
|
|
22
|
+
export { generateAiCatalog, buildCatalogEntry } from './client/component/ai-catalog';
|
|
23
|
+
export type {
|
|
24
|
+
SomaAiCatalog,
|
|
25
|
+
SomaAiCatalogEntry,
|
|
26
|
+
GenerateAiCatalogOptions,
|
|
27
|
+
} from './client/component/ai-catalog';
|
|
28
|
+
export { SomaPipeRegistry, defaultPipeRegistry } from './client/pipes/pipe-registry';
|
|
29
|
+
export type { SomaPipeFn, SomaPipeContext } from './client/pipes/pipe-registry';
|
|
30
|
+
|
|
31
|
+
// ── 数据对象层(*_data.yaml,五件套可选件) ──
|
|
32
|
+
export {
|
|
33
|
+
SomaDataObjectResolver,
|
|
34
|
+
SomaDataCycleError,
|
|
35
|
+
isSomaMockEnabled,
|
|
36
|
+
} from './client/data/data-object-resolver';
|
|
37
|
+
export type {
|
|
38
|
+
SomaDataHttpLike,
|
|
39
|
+
SomaDataResolverOptions,
|
|
40
|
+
SomaDataResolveResult,
|
|
41
|
+
} from './client/data/data-object-resolver';
|
|
42
|
+
export {
|
|
43
|
+
parseDataConfig,
|
|
44
|
+
parseDataYaml,
|
|
45
|
+
parseDataRef,
|
|
46
|
+
normalizeDataPipeValue,
|
|
47
|
+
SomaDataConfigError,
|
|
48
|
+
} from './client/parser/data-config-parser';
|
|
49
|
+
export type { SomaDataRef } from './client/parser/data-config-parser';
|
|
50
|
+
export type {
|
|
51
|
+
SomaDataConfig,
|
|
52
|
+
SomaDataObjectConfig,
|
|
53
|
+
SomaDataSourceConfig,
|
|
54
|
+
SomaDataFieldConfig,
|
|
55
|
+
SomaDataFieldRule,
|
|
56
|
+
SomaDataFieldOption,
|
|
57
|
+
SomaDataFieldType,
|
|
58
|
+
SomaDataFieldPermission,
|
|
59
|
+
SomaDataDicts,
|
|
60
|
+
} from './shared/types/data-config.types';
|
|
61
|
+
export {
|
|
62
|
+
deriveTheme,
|
|
63
|
+
applyTheme,
|
|
64
|
+
contrastRatio,
|
|
65
|
+
THEME_SWITCHING_CLASS,
|
|
66
|
+
} from './client/theme/theme-engine';
|
|
67
|
+
export type { SomaThemeInput, SomaDerivedTheme, SomaThemeMeta } from './client/theme/theme-engine';
|
|
68
|
+
export { themeRootAttributes } from './client/theme/theme-engine';
|
|
69
|
+
// 主题轴(REQ-007):宿主与 soma-ui 的装配层要按名构造轴位,类型必须在包根可达
|
|
70
|
+
export type {
|
|
71
|
+
SomaPaletteAxes, SomaSceneAxes, SomaResolvedAxes,
|
|
72
|
+
SomaHarmony, SomaSemantics, SomaChroma, SomaContrast,
|
|
73
|
+
SomaField, SomaIntensity, SomaMaterial,
|
|
74
|
+
} from './client/theme/theme-axes';
|
|
75
|
+
|
|
76
|
+
// ── 中文排版基线(F-05 / 契约 C2)──
|
|
77
|
+
// soma-ui 基座引用而不复制:复制即第二份事实。
|
|
78
|
+
export { TYPOGRAPHY_BASE_CSS } from './client/typography/typography-base';
|
|
79
|
+
|
|
80
|
+
// ── 降级阶梯:声明语法 + 词汇注册 + 编译产物(F-07 – F-10 / 契约 C4 C5 C6)──
|
|
81
|
+
export {
|
|
82
|
+
parseAdaptiveConfig,
|
|
83
|
+
createAdaptiveVocabulary,
|
|
84
|
+
SomaAdaptiveConfigError,
|
|
85
|
+
} from './client/parser/adaptive-parser';
|
|
86
|
+
export {
|
|
87
|
+
compileAdaptive,
|
|
88
|
+
applyCompiledAdaptive,
|
|
89
|
+
SOMA_ADAPTIVE_PROFILE_ATTR,
|
|
90
|
+
} from './client/compiler/adaptive-compile';
|
|
91
|
+
export {
|
|
92
|
+
SOMA_ADAPTIVE_PROFILES,
|
|
93
|
+
SOMA_ADAPTIVE_MAX_LADDER,
|
|
94
|
+
} from './shared/types/adaptive.types';
|
|
95
|
+
export type {
|
|
96
|
+
SomaAdaptiveProfile,
|
|
97
|
+
SomaAdaptiveConfig,
|
|
98
|
+
SomaAdaptiveLevel,
|
|
99
|
+
SomaAdaptiveLevelKind,
|
|
100
|
+
SomaAdaptiveLevelDefinition,
|
|
101
|
+
SomaAdaptiveVocabulary,
|
|
102
|
+
SomaAdaptiveScopeClass,
|
|
103
|
+
SomaAdaptiveExecutorConfig,
|
|
104
|
+
SomaCompiledAdaptive,
|
|
105
|
+
} from './shared/types/adaptive.types';
|
|
106
|
+
|
|
107
|
+
// ── 自适应调度原语三件套(F-11 – F-14 / 契约 C7)──
|
|
108
|
+
// 也可经 `soma-core/adaptive` 子路径单独引入:不 attach 即不加载不执行。
|
|
109
|
+
export {
|
|
110
|
+
createAdaptiveObserverPool,
|
|
111
|
+
scheduleAdaptiveFlush,
|
|
112
|
+
resolveTierWithHysteresis,
|
|
113
|
+
SOMA_DEFAULT_HYSTERESIS,
|
|
114
|
+
} from './client/adaptive/index';
|
|
115
|
+
export type {
|
|
116
|
+
SomaAdaptiveObserverPool,
|
|
117
|
+
SomaAdaptiveSize,
|
|
118
|
+
SomaAdaptiveSizeCallback,
|
|
119
|
+
SomaAdaptiveTask,
|
|
120
|
+
} from './client/adaptive/index';
|
|
121
|
+
export type {
|
|
122
|
+
SomaComponentDefinition,
|
|
123
|
+
SomaComponentControllerContext,
|
|
124
|
+
SomaComponentControllerFactory,
|
|
125
|
+
} from './client/component/component-definition.types';
|
|
126
|
+
export type {
|
|
127
|
+
SomaComponentContract,
|
|
128
|
+
SomaComponentLayer,
|
|
129
|
+
SomaGeometryFamily,
|
|
130
|
+
SomaContractProp,
|
|
131
|
+
SomaContractEmit,
|
|
132
|
+
SomaContractSlot,
|
|
133
|
+
} from './shared/types/component-contract.types';
|
|
134
|
+
export { findNestedMutableContractDefault } from './shared/types/component-contract.types';
|
|
14
135
|
export { createDefaultRuntimeServices } from './client/runtime/SomaRuntimeServices';
|
|
15
136
|
export type { SomaRuntimeServices } from './client/runtime/SomaRuntimeServices';
|
|
16
137
|
export { SomaDiagnostics } from './client/diagnostics/SomaDiagnostics';
|
|
138
|
+
|
|
139
|
+
// 可观测性:前端错误采集(错误 → 页面名@版本 归因通道)
|
|
140
|
+
export { installSomaErrorReporter } from './client/observability/error-reporter';
|
|
141
|
+
export type {
|
|
142
|
+
SomaErrorEvent,
|
|
143
|
+
SomaPageIdentity,
|
|
144
|
+
SomaErrorReporterOptions,
|
|
145
|
+
SomaErrorReporterHandle,
|
|
146
|
+
} from './client/observability/error-reporter';
|
|
147
|
+
|
|
148
|
+
// 安全:属性写入闸(伪协议 URL / 事件处理器属性拦截,已内建于容器适配器)
|
|
149
|
+
export { sanitizeAttributeWrite, hasBlockedScheme, isEventHandlerAttribute } from './client/security/url-guard';
|
|
150
|
+
// 安全:@html 净化收口(宿主可注入 sanitizer,缺省转义降级)
|
|
151
|
+
export {
|
|
152
|
+
setSomaHtmlSanitizer,
|
|
153
|
+
resolveSomaHtmlSanitizer,
|
|
154
|
+
sanitizeSomaHtml,
|
|
155
|
+
escapeSomaHtml,
|
|
156
|
+
SOMA_PURIFY_PROFILE,
|
|
157
|
+
} from './client/security/html-sanitizer';
|
|
158
|
+
export type { SomaHtmlSanitizer, SomaHtmlSanitizeResult } from './client/security/html-sanitizer';
|
|
17
159
|
export type { SomaDiagnosticsSnapshot } from './client/diagnostics/SomaDiagnostics';
|
|
18
160
|
export { matchGlobPath } from './client/engine/property-watcher';
|
|
19
161
|
export { extractConfigFromDomainClass } from './client/parser/annotation-extractor';
|
|
@@ -24,6 +166,17 @@ export type { AsyncStateHost } from './client/base/runAsync';
|
|
|
24
166
|
export { SomaQualityRegistry } from './client/quality/SomaQualityRegistry';
|
|
25
167
|
export { SomaTelemetry } from './client/diagnostics/SomaTelemetry';
|
|
26
168
|
export { setActiveTelemetry, recordMetric } from './client/diagnostics/telemetry-context';
|
|
169
|
+
|
|
170
|
+
// 性能:首屏三段打点(资产就绪 → 编译完成 → 首次渲染完成),默认关闭零开销
|
|
171
|
+
export {
|
|
172
|
+
startBootTimings,
|
|
173
|
+
maybeStartBootTimings,
|
|
174
|
+
markBootPhase,
|
|
175
|
+
readBootTimings,
|
|
176
|
+
resetBootTimings,
|
|
177
|
+
isBootTimingsEnabled,
|
|
178
|
+
} from './client/diagnostics/boot-timings';
|
|
179
|
+
export type { SomaBootTimings, SomaBootPhase } from './client/diagnostics/boot-timings';
|
|
27
180
|
export type { IContainerAdapter, SomaAnchorStats } from './client/container/IContainerAdapter';
|
|
28
181
|
export { SomaContainerAdapter } from './client/container/SomaContainerAdapter';
|
|
29
182
|
export { ReactNativeContainerAdapter } from './client/container/ReactNativeContainerAdapter';
|
|
@@ -61,3 +214,110 @@ export {
|
|
|
61
214
|
findSomaDomainLoader,
|
|
62
215
|
loadSomaDomainModuleFromRegistry,
|
|
63
216
|
} from './client/host-bridge/soma-domain-loaders';
|
|
217
|
+
|
|
218
|
+
// 运行时注册中心 · 客户端(REQ-002)。
|
|
219
|
+
// 也有 `soma-core/registry` 子路径入口;宿主 Domain 请用本裸包名——
|
|
220
|
+
// 宿主的 webpack 上下文只解析裸包名与 @soma-host 别名,workspace 包的
|
|
221
|
+
// subpath exports 在那里不可达(与 'soma-core/compiler/precompile' 同款实弹教训)。
|
|
222
|
+
export {
|
|
223
|
+
createGeneratedPagePreview,
|
|
224
|
+
createSomaPageLifecycle,
|
|
225
|
+
renderPublishedPage,
|
|
226
|
+
SomaPageLifecycle,
|
|
227
|
+
type GeneratedPageDeclarations,
|
|
228
|
+
type GeneratedPagePreviewOptions,
|
|
229
|
+
type PrecompiledDeclarationAssets,
|
|
230
|
+
type PreviewHandle,
|
|
231
|
+
type PreviewObservabilityOptions,
|
|
232
|
+
type MountedPageInfo,
|
|
233
|
+
type PublishedPageHandle,
|
|
234
|
+
type PublishedPageRecord,
|
|
235
|
+
type RegisterDeclarationOptions,
|
|
236
|
+
type RenderPublishedPageOptions,
|
|
237
|
+
type SomaPageLifecycleOptions,
|
|
238
|
+
} from './client/registry/index';
|
|
239
|
+
|
|
240
|
+
// 组件包(业务拓展组件库):合成、查重、目录、自检。
|
|
241
|
+
// 接入指南见 external-docs/soma-组件包接入指南.md。
|
|
242
|
+
export {
|
|
243
|
+
composeComponentPacks,
|
|
244
|
+
generatePackCatalog,
|
|
245
|
+
ComponentPackError,
|
|
246
|
+
PACK_NAME_PATTERN,
|
|
247
|
+
type ComposedComponentPacks,
|
|
248
|
+
type ComposePacksOptions,
|
|
249
|
+
type SomaComponentPack,
|
|
250
|
+
type SomaComponentPackStyles,
|
|
251
|
+
type PackOverrideEvent,
|
|
252
|
+
} from './client/component/component-pack';
|
|
253
|
+
export { verifyComponentPack, type VerifyPackOptions } from './client/component/verify-pack';
|
|
254
|
+
|
|
255
|
+
// 值语言(DSL v2 · REQ-005 F4):算术六词元 + 管道链的唯一值规则。
|
|
256
|
+
// 规格见 doc/需求/REQ-005-DSL体验强化/UI业务组件DSL规格书.md §7;
|
|
257
|
+
// v2 其余部件未施工前,本模块可被 v1 路径独立复用(纯函数、无依赖)。
|
|
258
|
+
export {
|
|
259
|
+
parseValueSegment,
|
|
260
|
+
evaluateValueNode,
|
|
261
|
+
isArithSegment,
|
|
262
|
+
isPlainPath,
|
|
263
|
+
describeNode,
|
|
264
|
+
SomaValueLangError,
|
|
265
|
+
type ValueNode,
|
|
266
|
+
type PipedValue,
|
|
267
|
+
type ValuePosition,
|
|
268
|
+
type HasVarFn,
|
|
269
|
+
type EvalOptions,
|
|
270
|
+
} from './client/parser/value-lang';
|
|
271
|
+
|
|
272
|
+
// SOMA DSL 容器与块装载(外置块发现在 soma-core/server)。
|
|
273
|
+
export {
|
|
274
|
+
loadSomaFile,
|
|
275
|
+
SomaV2ParseError,
|
|
276
|
+
PAGE_BLOCK_ID,
|
|
277
|
+
type RawBlock,
|
|
278
|
+
type SomaFileLoadInput,
|
|
279
|
+
} from './build/v2/soma-file-loader';
|
|
280
|
+
export {
|
|
281
|
+
buildHtmlAnchorIndex,
|
|
282
|
+
type HtmlAnchorIndex,
|
|
283
|
+
type HtmlAnchorInfo,
|
|
284
|
+
} from './build/v2/html-index';
|
|
285
|
+
// 资产级入口:拿着原始 v2 声明的一方(服务端装载层/测试替身/预览器)先编译,
|
|
286
|
+
// 再把 v1 等价产物交给 mount——运行时只认 v1(两级编译、单一运行时)。
|
|
287
|
+
export { compilePageAssets } from './build/compiler/page-assets';
|
|
288
|
+
export {
|
|
289
|
+
compileSomaV2,
|
|
290
|
+
type CompiledSomaV2,
|
|
291
|
+
type CompileSomaV2Input,
|
|
292
|
+
} from './build/v2/block-compile';
|
|
293
|
+
export {
|
|
294
|
+
parsePageBlock,
|
|
295
|
+
type PageBlockAst,
|
|
296
|
+
} from './client/parser/v2/page-parser';
|
|
297
|
+
export {
|
|
298
|
+
parseUseBlock,
|
|
299
|
+
type UseBlockAst,
|
|
300
|
+
type DataObjectDecl,
|
|
301
|
+
type FieldDecl,
|
|
302
|
+
type ActionDecl,
|
|
303
|
+
} from './client/parser/v2/use-parser';
|
|
304
|
+
export {
|
|
305
|
+
buildBlockScope,
|
|
306
|
+
resolvePath,
|
|
307
|
+
resolveApiRef,
|
|
308
|
+
expandPath,
|
|
309
|
+
scopeHasVar,
|
|
310
|
+
SomaScopeError,
|
|
311
|
+
type BlockScope,
|
|
312
|
+
} from './client/parser/v2/namespace';
|
|
313
|
+
export {
|
|
314
|
+
checkOverrideCompat,
|
|
315
|
+
type ContractCompatIssue,
|
|
316
|
+
type ContractCompatIssueKind,
|
|
317
|
+
} from './client/component/contract-compat';
|
|
318
|
+
export {
|
|
319
|
+
attachPackStyles,
|
|
320
|
+
ensurePackBaseStyles,
|
|
321
|
+
resetPackStyleInjection,
|
|
322
|
+
type PackStyleOptions,
|
|
323
|
+
} from './client/component/pack-styles';
|
|
@@ -1,4 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* The service boundary deliberately uses the Web Request surface instead of a
|
|
3
|
+
* concrete NextRequest class. Hosts can resolve soma-core and Next.js through
|
|
4
|
+
* different workspace copies (for example a published AI package may use
|
|
5
|
+
* Next 14 while the host runs Next 16); those classes are structurally the
|
|
6
|
+
* same request at this boundary but are nominally incompatible in TypeScript.
|
|
7
|
+
*/
|
|
8
|
+
export interface SomaServiceRequest {
|
|
9
|
+
readonly headers: Headers;
|
|
10
|
+
readonly signal: AbortSignal;
|
|
11
|
+
readonly method: string;
|
|
12
|
+
readonly url: string;
|
|
13
|
+
}
|
|
2
14
|
|
|
3
15
|
/**
|
|
4
16
|
* SOMA 后端服务接口 —— 宿主项目 `api/service/` 下的服务类可实现此接口。
|
|
@@ -21,9 +33,9 @@ import { NextRequest } from 'next/server';
|
|
|
21
33
|
* ```
|
|
22
34
|
*/
|
|
23
35
|
export interface IService {
|
|
24
|
-
get?(req:
|
|
25
|
-
post?(req:
|
|
26
|
-
put?(req:
|
|
27
|
-
patch?(req:
|
|
28
|
-
delete?(req:
|
|
36
|
+
get?(req: SomaServiceRequest): Promise<Response>;
|
|
37
|
+
post?(req: SomaServiceRequest): Promise<Response>;
|
|
38
|
+
put?(req: SomaServiceRequest): Promise<Response>;
|
|
39
|
+
patch?(req: SomaServiceRequest): Promise<Response>;
|
|
40
|
+
delete?(req: SomaServiceRequest): Promise<Response>;
|
|
29
41
|
}
|
|
@@ -55,13 +55,13 @@ export function loadHostService(segments: string[]): IService | null {
|
|
|
55
55
|
const mod = getJiti(hostDir)(filePath) as { default?: new () => IService };
|
|
56
56
|
const ServiceClass = mod?.default;
|
|
57
57
|
if (!ServiceClass || typeof ServiceClass !== 'function') {
|
|
58
|
-
console.warn(`[soma-
|
|
58
|
+
console.warn(`[soma-core][接口] ${filePath} missing default export`);
|
|
59
59
|
return null;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
const instance = new ServiceClass();
|
|
63
63
|
if (!isService(instance)) {
|
|
64
|
-
console.warn(`[soma-
|
|
64
|
+
console.warn(`[soma-core][接口] ${filePath} does not implement IService`);
|
|
65
65
|
return null;
|
|
66
66
|
}
|
|
67
67
|
|
|
@@ -69,7 +69,7 @@ export function loadHostService(segments: string[]): IService | null {
|
|
|
69
69
|
return instance;
|
|
70
70
|
} catch (e: unknown) {
|
|
71
71
|
const message = e instanceof Error ? e.message : String(e);
|
|
72
|
-
console.error(`[soma-
|
|
72
|
+
console.error(`[soma-core][接口] failed to load ${filePath}:`, message);
|
|
73
73
|
return null;
|
|
74
74
|
}
|
|
75
75
|
}
|