soma-core 1.4.2 → 1.5.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/bin/component.cjs +240 -0
- package/bin/eject.cjs +174 -0
- package/bin/migrate.cjs +362 -0
- package/core/build/blocks/block-compile.ts +143 -17
- package/core/build/blocks/migrate-flat.ts +118 -25
- package/core/build/compiler/page-declaration-compiler.ts +149 -5
- package/core/build/compiler/route-builder.ts +0 -4
- package/core/build/compiler/soma-precompile.js +431 -26
- package/core/build/component/component-graph.ts +28 -105
- package/core/build/component/package-loader.ts +18 -4
- package/core/build/eject/component-eject.ts +8 -2
- package/core/build/layout/constraint-solver.ts +131 -16
- package/core/build/layout/css-emitter.ts +15 -9
- package/core/build/ooui/artifact/artifact.types.ts +275 -0
- package/core/build/ooui/artifact/emit-artifact.ts +269 -0
- package/core/build/ooui/artifact/emit-html.ts +204 -0
- package/core/build/ooui/artifact/index.ts +53 -0
- package/core/build/ooui/artifact/spatial-tree.ts +268 -0
- package/core/build/ooui/artifact/utility-class.ts +83 -0
- package/core/build/ooui/composition/candidate.types.ts +323 -0
- package/core/build/ooui/composition/control-model.ts +114 -0
- package/core/build/ooui/composition/registry.ts +520 -0
- package/core/build/ooui/composition/select.ts +232 -0
- package/core/build/ooui/diagnostics/codes.ts +230 -0
- package/core/build/ooui/diagnostics/error.ts +235 -0
- package/core/build/ooui/diagnostics/format.ts +106 -0
- package/core/build/ooui/diagnostics/index.ts +62 -0
- package/core/build/ooui/diagnostics/issue.types.ts +112 -0
- package/core/build/ooui/engine-slot.ts +184 -0
- package/core/build/ooui/index.ts +1427 -0
- package/core/build/ooui/intent/derive-intent.ts +450 -0
- package/core/build/ooui/intent/field-rules.ts +330 -0
- package/core/build/ooui/intent/intent.types.ts +476 -0
- package/core/build/ooui/intent/verb-events.ts +285 -0
- package/core/build/ooui/page/budget.ts +503 -0
- package/core/build/ooui/page/compose-page.ts +736 -0
- package/core/build/ooui/page/index.ts +66 -0
- package/core/build/ooui/page/page.types.ts +402 -0
- package/core/build/ooui/page/region-row.ts +241 -0
- package/core/build/ooui/semantic/expand-page-surface.ts +180 -0
- package/core/build/ooui/semantic/kernel.types.ts +187 -0
- package/core/build/ooui/semantic/normalize.ts +784 -0
- package/core/build/ooui/semantic/origin.types.ts +211 -0
- package/core/build/ooui/semantic/role-alias.ts +154 -0
- package/core/build/ooui/semantic/shorthand.ts +233 -0
- package/core/build/ooui/semantic/surface.types.ts +78 -0
- package/core/build/ooui/semantic/validate-request.ts +267 -0
- package/core/build/ooui/spatial/emit-utility.ts +480 -0
- package/core/build/ooui/spatial/ir.types.ts +443 -0
- package/core/build/ooui/spatial/registry.ts +565 -0
- package/core/build/ooui/spatial/solve.ts +769 -0
- package/core/build/ooui/spatial/utility.types.ts +242 -0
- package/core/build/ooui/trace/index.ts +40 -0
- package/core/build/ooui/trace/render.ts +190 -0
- package/core/build/ooui/trace/source.types.ts +69 -0
- package/core/build/ooui/trace/trace.types.ts +326 -0
- package/core/client/component/example-blocks.ts +1 -7
- package/core/client/component/theme-component-tokens.ts +12 -15
- package/core/client/data/data-object-resolver.ts +27 -8
- package/core/client/diagnostics/telemetry-context.ts +0 -4
- package/core/client/engine/asset-resolver.ts +0 -1
- package/core/client/engine/event-engine.ts +7 -3
- package/core/client/engine/soma-bootstrap.ts +292 -34
- package/core/client/engine/style-binder.ts +0 -1
- package/core/client/infra/http/IHttpClient.ts +0 -6
- package/core/client/infra/http/SomaHttpService.ts +4 -1
- package/core/client/infra/notify/DomNotifyService.ts +1 -1
- package/core/client/infra/router/router-path.ts +0 -6
- package/core/client/parser/annotation-extractor.ts +1 -1
- package/core/client/parser/blocks/namespace.ts +30 -5
- package/core/client/parser/blocks/page-parser.ts +44 -1
- package/core/client/parser/blocks/use-parser.ts +266 -46
- package/core/client/parser/data-config-parser.ts +71 -3
- package/core/client/parser/layout-parser.ts +4 -3
- package/core/client/parser/reaction-parser.ts +0 -1
- package/core/client/parser/ui-config-parser.ts +212 -74
- package/core/client/theme/scene-tokens.ts +9 -3
- package/core/client/theme/theme-axes.ts +74 -16
- package/core/client/theme/theme-engine.ts +280 -69
- package/core/client/theme/tone-solver.ts +9 -8
- package/core/index.ts +18 -4
- package/core/server/api/load-host-service.ts +8 -2
- package/core/server/declaration-safety.ts +11 -0
- package/core/server/host/page-response-request.ts +0 -2
- package/core/server/host/published-page-artifact-cache.ts +244 -0
- package/core/server/host/published-page-assets.ts +44 -5
- package/core/server/mock/node/cli.mjs +0 -1
- package/core/server/mock/node/schema-generator.mjs +0 -1
- package/core/server/ooui.ts +34 -0
- package/core/server/page-assets.ts +8 -0
- package/core/server/page-declaration.ts +18 -0
- package/core/server/registry/asset-store.ts +327 -0
- package/core/server/registry/declaration-precompiler.ts +49 -6
- package/core/server/registry/index.ts +47 -1
- package/core/server/registry/page-registry-repository.ts +6 -2
- package/core/server/registry/page-registry-store.ts +133 -19
- package/core/server/registry/publish-asset-pin.ts +557 -0
- package/core/server/registry/services/pages/List.ts +15 -3
- package/core/server/registry/validation/compile-gate.ts +180 -8
- package/core/server/registry/validation/declaration-safety-scan.ts +113 -23
- package/core/shared/component/derive-sample.ts +201 -16
- package/core/shared/component/field-lines.ts +98 -8
- package/core/shared/container-breakpoints.ts +46 -0
- package/core/shared/object-semantics.ts +240 -0
- package/core/shared/ooui-declaration.ts +235 -0
- package/core/shared/types/component-contract.types.ts +7 -6
- package/core/shared/types/data-config.types.ts +95 -0
- package/core/shared/types/domain.types.ts +0 -24
- package/core/shared/types/engine.types.ts +0 -5
- package/core/shared/types/layout-constraint.types.ts +16 -0
- package/core/shared/types/ui-config.types.ts +163 -13
- package/dist/cli/soma.js +24 -11
- package/dist/core/index.cjs +1563 -800
- package/dist/types/build/blocks/block-compile.d.ts +16 -1
- package/dist/types/build/blocks/migrate-flat.d.ts +17 -0
- package/dist/types/build/compiler/page-declaration-compiler.d.ts +46 -0
- package/dist/types/build/compiler/route-builder.d.ts +0 -1
- package/dist/types/build/component/component-graph.d.ts +17 -53
- package/dist/types/build/component/package-loader.d.ts +8 -1
- package/dist/types/build/layout/constraint-solver.d.ts +46 -4
- package/dist/types/build/ooui/artifact/artifact.types.d.ts +180 -0
- package/dist/types/build/ooui/artifact/emit-artifact.d.ts +58 -0
- package/dist/types/build/ooui/artifact/emit-html.d.ts +53 -0
- package/dist/types/build/ooui/artifact/index.d.ts +5 -0
- package/dist/types/build/ooui/artifact/spatial-tree.d.ts +48 -0
- package/dist/types/build/ooui/artifact/utility-class.d.ts +46 -0
- package/dist/types/build/ooui/composition/candidate.types.d.ts +206 -0
- package/dist/types/build/ooui/composition/control-model.d.ts +37 -0
- package/dist/types/build/ooui/composition/registry.d.ts +66 -0
- package/dist/types/build/ooui/composition/select.d.ts +63 -0
- package/dist/types/build/ooui/diagnostics/codes.d.ts +28 -0
- package/dist/types/build/ooui/diagnostics/error.d.ts +135 -0
- package/dist/types/build/ooui/diagnostics/format.d.ts +51 -0
- package/dist/types/build/ooui/diagnostics/index.d.ts +25 -0
- package/dist/types/build/ooui/diagnostics/issue.types.d.ts +56 -0
- package/dist/types/build/ooui/engine-slot.d.ts +41 -0
- package/dist/types/build/ooui/index.d.ts +286 -0
- package/dist/types/build/ooui/intent/derive-intent.d.ts +32 -0
- package/dist/types/build/ooui/intent/field-rules.d.ts +99 -0
- package/dist/types/build/ooui/intent/intent.types.d.ts +318 -0
- package/dist/types/build/ooui/intent/verb-events.d.ts +70 -0
- package/dist/types/build/ooui/page/budget.d.ts +28 -0
- package/dist/types/build/ooui/page/compose-page.d.ts +41 -0
- package/dist/types/build/ooui/page/index.d.ts +4 -0
- package/dist/types/build/ooui/page/page.types.d.ts +264 -0
- package/dist/types/build/ooui/page/region-row.d.ts +16 -0
- package/dist/types/build/ooui/semantic/expand-page-surface.d.ts +33 -0
- package/dist/types/build/ooui/semantic/kernel.types.d.ts +125 -0
- package/dist/types/build/ooui/semantic/normalize.d.ts +45 -0
- package/dist/types/build/ooui/semantic/origin.types.d.ts +95 -0
- package/dist/types/build/ooui/semantic/role-alias.d.ts +35 -0
- package/dist/types/build/ooui/semantic/shorthand.d.ts +60 -0
- package/dist/types/build/ooui/semantic/surface.types.d.ts +16 -0
- package/dist/types/build/ooui/semantic/validate-request.d.ts +19 -0
- package/dist/types/build/ooui/spatial/emit-utility.d.ts +43 -0
- package/dist/types/build/ooui/spatial/ir.types.d.ts +280 -0
- package/dist/types/build/ooui/spatial/registry.d.ts +110 -0
- package/dist/types/build/ooui/spatial/solve.d.ts +42 -0
- package/dist/types/build/ooui/spatial/utility.types.d.ts +191 -0
- package/dist/types/build/ooui/trace/index.d.ts +3 -0
- package/dist/types/build/ooui/trace/render.d.ts +42 -0
- package/dist/types/build/ooui/trace/source.types.d.ts +25 -0
- package/dist/types/build/ooui/trace/trace.types.d.ts +143 -0
- package/dist/types/client/component/example-blocks.d.ts +0 -2
- package/dist/types/client/component/theme-component-tokens.d.ts +8 -5
- package/dist/types/client/data/data-object-resolver.d.ts +10 -2
- package/dist/types/client/diagnostics/telemetry-context.d.ts +0 -1
- package/dist/types/client/engine/soma-bootstrap.d.ts +123 -10
- package/dist/types/client/infra/http/IHttpClient.d.ts +0 -5
- package/dist/types/client/infra/http/SomaHttpService.d.ts +1 -1
- package/dist/types/client/infra/router/router-path.d.ts +0 -2
- package/dist/types/client/parser/blocks/namespace.d.ts +20 -0
- package/dist/types/client/parser/blocks/page-parser.d.ts +9 -0
- package/dist/types/client/parser/blocks/use-parser.d.ts +38 -4
- package/dist/types/client/parser/data-config-parser.d.ts +13 -0
- package/dist/types/client/parser/ui-config-parser.d.ts +1 -11
- package/dist/types/client/theme/scene-tokens.d.ts +9 -3
- package/dist/types/client/theme/theme-axes.d.ts +64 -1
- package/dist/types/client/theme/theme-engine.d.ts +13 -8
- package/dist/types/client/theme/tone-solver.d.ts +9 -5
- package/dist/types/index.d.ts +4 -5
- package/dist/types/server/declaration-safety.d.ts +7 -0
- package/dist/types/server/host/page-response-request.d.ts +0 -1
- package/dist/types/server/host/published-page-artifact-cache.d.ts +64 -0
- package/dist/types/server/ooui.d.ts +18 -0
- package/dist/types/server/page-assets.d.ts +7 -0
- package/dist/types/server/page-declaration.d.ts +14 -0
- package/dist/types/server/registry/asset-store.d.ts +112 -0
- package/dist/types/server/registry/declaration-precompiler.d.ts +23 -3
- package/dist/types/server/registry/index.d.ts +3 -1
- package/dist/types/server/registry/page-registry-store.d.ts +57 -4
- package/dist/types/server/registry/publish-asset-pin.d.ts +166 -0
- package/dist/types/server/registry/services/pages/List.d.ts +9 -3
- package/dist/types/server/registry/validation/compile-gate.d.ts +63 -0
- package/dist/types/shared/component/derive-sample.d.ts +14 -0
- package/dist/types/shared/container-breakpoints.d.ts +42 -0
- package/dist/types/shared/object-semantics.d.ts +42 -0
- package/dist/types/shared/ooui-declaration.d.ts +135 -0
- package/dist/types/shared/types/component-contract.types.d.ts +7 -6
- package/dist/types/shared/types/data-config.types.d.ts +86 -0
- package/dist/types/shared/types/domain.types.d.ts +0 -21
- package/dist/types/shared/types/engine.types.d.ts +0 -4
- package/dist/types/shared/types/layout-constraint.types.d.ts +1 -0
- package/dist/types/shared/types/ui-config.types.d.ts +157 -12
- package/next.config.js +106 -13
- package/package.json +28 -2
- package/core/client/host-bridge/index.ts +0 -27
- package/core/client/parser/yaml-loader.ts +0 -36
- package/core/shared/manifest/manifest-contract.ts +0 -12
- package/dist/types/client/host-bridge/index.d.ts +0 -9
- package/dist/types/client/parser/yaml-loader.d.ts +0 -21
- package/dist/types/shared/manifest/manifest-contract.d.ts +0 -4
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type CompiledPageDeclaration } from '../../build/compiler/page-declaration-compiler';
|
|
1
2
|
import type { PageRegistryDeclaration } from './page-registry-store';
|
|
2
3
|
/**
|
|
3
4
|
* 编译器版本。与 soma-core 的包版本对齐——语义变更必然伴随版本号变化,
|
|
@@ -11,6 +12,11 @@ export declare const DECLARATION_COMPILER_VERSION: string;
|
|
|
11
12
|
/** 落库的完整运行时产物。 */
|
|
12
13
|
export interface CompiledDeclaration {
|
|
13
14
|
compilerVersion: string;
|
|
15
|
+
/**
|
|
16
|
+
* 供货指纹(词表版本那一维,可选)。缺席 = 编译那一刻宿主没报供货版本,
|
|
17
|
+
* 此时第三道闸**不判**——见文件头。只增不改:老产物没有这个键,判据自动降级为原来两条。
|
|
18
|
+
*/
|
|
19
|
+
assetSupplyKey?: string;
|
|
14
20
|
uiConfig?: unknown;
|
|
15
21
|
eventConfig?: unknown;
|
|
16
22
|
triggerConfig?: unknown;
|
|
@@ -21,10 +27,24 @@ export interface CompiledDeclaration {
|
|
|
21
27
|
/**
|
|
22
28
|
* 把统一声明一次编译成运行时可直接消费的完整配置对象。
|
|
23
29
|
* 编译失败返回 null,不产生可被误用的半成品。
|
|
30
|
+
*
|
|
31
|
+
* `compiledPage`:调用方手里已经有**这同一份** `declaration` 的编译结果时传进来
|
|
32
|
+
* (发布路径上编译闸门那一次,见 `page-registry-store` 的 `normalizeDeclaration`),
|
|
33
|
+
* 这里就不再编第二遍。产物由下面同一段映射得出,与自己编出来的逐字相同;
|
|
34
|
+
* 供货指纹仍在此刻读取,与自己编时同一时点。保证它编的是同一份声明,是传入方的责任。
|
|
24
35
|
*/
|
|
25
|
-
export declare function precompileDeclaration(declaration: PageRegistryDeclaration): CompiledDeclaration | null;
|
|
36
|
+
export declare function precompileDeclaration(declaration: PageRegistryDeclaration, compiledPage?: CompiledPageDeclaration): CompiledDeclaration | null;
|
|
26
37
|
/**
|
|
27
|
-
*
|
|
38
|
+
* 消费端的版本闸:编译器版本或供货版本对不上就整份丢弃。
|
|
28
39
|
* 这是"缓存不是真理"那条纪律的执行点。
|
|
40
|
+
*
|
|
41
|
+
* 三条判据:
|
|
42
|
+
* 1. 编译器版本(引擎那一维)必须逐字相同;
|
|
43
|
+
* 2. 结构必须齐(`uiConfig` / `eventConfig` 都在);
|
|
44
|
+
* 3. **供货指纹(词表那一维)不许相左**——但只在**两侧都有键**时才判。
|
|
45
|
+
* 单侧有键就不判是刻意的:老产物没有这个键,一律判假会让每次取页都重编译一遍
|
|
46
|
+
* (功能全对、只有耗时在涨,正是这条路径上最典型的静默退化);
|
|
47
|
+
* 而运行时问不到自己的供货版本时判假,等于拿"我不知道"当"不一致"。
|
|
48
|
+
* 失败方向仍然安全:第三道闸判假只导致**重新编译**,不导致拒绝。
|
|
29
49
|
*/
|
|
30
|
-
export declare function isCompiledUsable(compiled: CompiledDeclaration | null | undefined, runtimeVersion?: string): boolean;
|
|
50
|
+
export declare function isCompiledUsable(compiled: CompiledDeclaration | null | undefined, runtimeVersion?: string, runtimeSupplyKey?: string | undefined): boolean;
|
|
@@ -19,11 +19,13 @@ export { hasConfiguredCredentials, isRegistryDemoOpenDoor, looksLikeProduction,
|
|
|
19
19
|
export { setRegistryLockBackend, withRegistryLock, writeFileAtomic, type RegistryLockBackend, } from './registry-file-lock';
|
|
20
20
|
export { readJsonWithLimit, RequestBodyTooLargeError, REGISTRY_WRITE_MAX_BYTES, type BodyLimitedRequest, } from './request-body-limit';
|
|
21
21
|
export { precompileDeclaration, isCompiledUsable, DECLARATION_COMPILER_VERSION, type CompiledDeclaration, } from './declaration-precompiler';
|
|
22
|
+
export { assetIntakeIssues, assetRelativePath, defaultRegistryAssetDir, FileRegistryAssetStore, getRegistryAssetStore, InMemoryRegistryAssetStore, isSomaAssetDigest, REGISTRY_ASSET_MAX_BYTES, setRegistryAssetStore, somaAssetDigest, SOMA_ASSET_DIGEST_ALGO, SOMA_ASSET_DIGEST_PATTERN, type RegistryAssetStore, type SomaAssetKind, type SomaAssetRef, } from './asset-store';
|
|
23
|
+
export { ASSET_PIN_VERSION, assembleComponentCss, assetPinByteSize, assetSupplyDriftNotice, currentAssetSupply, currentAssetSupplyKey, pinnedAssetMembers, pinPublishedAssets, reconcilePinnedAssets, setPublishedAssetSource, type AssembledComponentCss, type PinnableDeclaration, type PinPublishedAssetsOptions, type PublishedAssetSource, type PublishedAssetSupply, type ReconcilableRecord, type SomaAssetPin, type SomaAssetReconciliation, type SomaAssetReconcileStatus, type SomaPinnedAsset, } from './publish-asset-pin';
|
|
22
24
|
export { scanDeclarationSafety, type ScannableDeclaration } from './validation/declaration-safety-scan';
|
|
23
25
|
export { RegistryError } from './registry-error';
|
|
24
26
|
export { ApiRegistryStore, ApiRegistryError, ApiRegistryErrorCodes, API_NAME_PATTERN, API_APP_PATTERN, API_METHODS, API_RECORD_MAX_BYTES, getApiRegistryStore, resetApiRegistryStore, type ApiMethod, type ApiRecord, type ApiRegisterInput, type ApiRegistryErrorCode, type ApiRegistryListItem, type ApiRegistryListOptions, type ApiRegistryListResult, type ApiRegistryStoreOptions, } from './api-registry-store';
|
|
25
27
|
export { scanCredentialLeak, type CredentialScannable } from './validation/credential-ban';
|
|
26
|
-
export { dryRunCompile, type CompilableDeclaration } from './validation/compile-gate';
|
|
28
|
+
export { dryRunCompile, dryRunCompileWithDiagnostics, type CompilableDeclaration, type CompileGateResult, type SomaCompileDiagnostic, type SomaCompileDiagnosticSource, } from './validation/compile-gate';
|
|
27
29
|
export { collectReferencedComponents, scanUnknownComponents, setKnownComponentsResolver, type KnownComponentsResolver, } from './validation/component-existence';
|
|
28
30
|
export { collectDeclaredApiPaths, crossCheckDeclaredApis, normalizeApiPath, setRegisteredPathsResolver, type RegisteredPathsResolver, } from './validation/cross-check';
|
|
29
31
|
export { resolveRegistryService } from './services/index';
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import type { CompiledPageDeclaration } from '../../build/compiler/page-declaration-compiler';
|
|
1
2
|
import { type CompiledDeclaration } from './declaration-precompiler';
|
|
3
|
+
import { type SomaAssetPin } from './publish-asset-pin';
|
|
2
4
|
import { RegistryError } from './registry-error';
|
|
5
|
+
import { type SomaCompileDiagnostic } from './validation/compile-gate';
|
|
3
6
|
/** 页面名约束:小写字母 / 数字 / 连字符,1~64 位(可直接用作文件名与 URL 片段) */
|
|
4
7
|
export declare const PAGE_NAME_PATTERN: RegExp;
|
|
5
8
|
/** 应用命名空间约束:与页面名同形(略短),缺省 'default' */
|
|
@@ -50,7 +53,15 @@ export declare const PageRegistryErrorCodes: {
|
|
|
50
53
|
export type PageRegistryErrorCode = (typeof PageRegistryErrorCodes)[keyof typeof PageRegistryErrorCodes];
|
|
51
54
|
export declare class PageRegistryError extends RegistryError {
|
|
52
55
|
readonly code: PageRegistryErrorCode;
|
|
53
|
-
|
|
56
|
+
/**
|
|
57
|
+
* 结构化诊断(可选):编译闸门命中时带上 `code` / `src` / `trace` / `remedy`。
|
|
58
|
+
*
|
|
59
|
+
* 为什么挂在错误上而不是只发字符串:`message` 是给人读的终点,
|
|
60
|
+
* 而这条错误的真实消费者是 AI 修订链——它要按 `remedy` 改哪一行。
|
|
61
|
+
* 字段可选、纯数据,现有 `catch (e) { e.message }` 的调用方一律不受影响。
|
|
62
|
+
*/
|
|
63
|
+
readonly diagnostics?: readonly SomaCompileDiagnostic[];
|
|
64
|
+
constructor(code: PageRegistryErrorCode, message: string, diagnostics?: readonly SomaCompileDiagnostic[]);
|
|
54
65
|
}
|
|
55
66
|
/** 页面声明本体:与 /api/ai-page/generate 的产物同构(dataYaml 为数据对象绑定拓展位) */
|
|
56
67
|
export interface PageRegistryDeclaration {
|
|
@@ -96,6 +107,18 @@ export interface PageVersionRecord {
|
|
|
96
107
|
* 由服务端从统一源声明重新编译(见 DeclarationPrecompiler.isCompiledUsable)。
|
|
97
108
|
*/
|
|
98
109
|
compiled?: CompiledDeclaration;
|
|
110
|
+
/**
|
|
111
|
+
* 资产钉子(可选):这一版**是对着哪一份组件 CSS 发布的**(内容摘要)。
|
|
112
|
+
*
|
|
113
|
+
* 与 `compiled` 平级而不是它的子键,因为两者性质相反:`compiled` 是缓存
|
|
114
|
+
* (编译失败即缺席,重编即可),钉子是真理(发布那一刻的事实,过后无从重建)。
|
|
115
|
+
* 塞进 `compiled` 会让一次编译失败连带丢掉钉子,而丢掉之后对账只会说"未钉住"——
|
|
116
|
+
* 通过,静默。详见 `publish-asset-pin.ts` 文件头。
|
|
117
|
+
*
|
|
118
|
+
* 缺席是正常状态:宿主没接样式供货来源(`setPublishedAssetSource`)、页面没引用构件、
|
|
119
|
+
* 或字节没能落库时都不钉。**钉子宁可缺席,不可说谎。**
|
|
120
|
+
*/
|
|
121
|
+
assets?: SomaAssetPin;
|
|
99
122
|
}
|
|
100
123
|
/** publish 的可选项(第三参也兼容旧的裸 status 字符串写法) */
|
|
101
124
|
export interface PageRegistryPublishOptions {
|
|
@@ -118,6 +141,12 @@ export interface PageVersionFields {
|
|
|
118
141
|
tags: string[];
|
|
119
142
|
meta?: PageRegistryMeta;
|
|
120
143
|
operator?: string;
|
|
144
|
+
/**
|
|
145
|
+
* 编译闸门对**这同一份** `declaration` 的编译结果(发布路径专用,可选)。
|
|
146
|
+
* 给了就直接复用,`createPageVersionRecord` 不再编第二遍;不给(rollback / archive
|
|
147
|
+
* 复制旧声明时没有闸门那一次)照旧自己编。它只是编译输入,不进版本记录。
|
|
148
|
+
*/
|
|
149
|
+
compiledPage?: CompiledPageDeclaration;
|
|
121
150
|
}
|
|
122
151
|
/** list() 返回的摘要条目(速记列直接可渲:状态 / 应用 / 标签 / 标题齐备) */
|
|
123
152
|
export interface PageRegistryListItem {
|
|
@@ -138,6 +167,19 @@ export interface PageRegistryListOptions {
|
|
|
138
167
|
keyword?: string;
|
|
139
168
|
/** 是否包含已归档页面(缺省 false:归档页从清单消失) */
|
|
140
169
|
includeArchived?: boolean;
|
|
170
|
+
/**
|
|
171
|
+
* 精确只看这一种状态——比 includeArchived 更具体的筛选。
|
|
172
|
+
*
|
|
173
|
+
* 与 includeArchived 的关系:includeArchived 只是"要不要把 archived 混进缺省清单"
|
|
174
|
+
* 的粗粒度开关;显式传了 status 就按它精筛,覆盖 includeArchived 的缺省收窄行为
|
|
175
|
+
* (例如 status: 'archived' 时无需再传 includeArchived: true)。不传 status 时,
|
|
176
|
+
* 行为完全由 includeArchived 决定,不受影响。
|
|
177
|
+
*
|
|
178
|
+
* 与 publishedOnly 的关系:**publishedOnly 是不可越权的可见性铁律,永远先于 status
|
|
179
|
+
* 生效**——非特权主体(publishedOnly: true)传 status: 'archived' 依旧看不到任何
|
|
180
|
+
* 已下架页面。这个可选查询参数不能绕开按主体分层的访问控制(见 publishedOnly 注释)。
|
|
181
|
+
*/
|
|
182
|
+
status?: Extract<PageRegistryStatus, 'published' | 'archived'>;
|
|
141
183
|
/**
|
|
142
184
|
* 只列已发布页面(匿名调用方的缺省视角)。
|
|
143
185
|
*
|
|
@@ -190,7 +232,8 @@ export declare class PageRegistryStore {
|
|
|
190
232
|
get(name: string, version?: number): PageVersionRecord;
|
|
191
233
|
/**
|
|
192
234
|
* 页面摘要清单(按页面名排序,分页协议 { pages, total })。
|
|
193
|
-
* 缺省排除已归档页面;支持 app /
|
|
235
|
+
* 缺省排除已归档页面;支持 app / 关键词 / status 精筛与 limit/offset 分页;
|
|
236
|
+
* status 语义见 PageRegistryListOptions.status 注释。
|
|
194
237
|
*/
|
|
195
238
|
list(options?: PageRegistryListOptions): PageRegistryListResult;
|
|
196
239
|
/** 回滚:把指定旧版本(声明 + 元数据 + app/tags)复制为新的 published 版本 */
|
|
@@ -245,8 +288,18 @@ export declare function assertPageName(name: unknown): string;
|
|
|
245
288
|
export declare function assertVersionNumber(version: unknown): asserts version is number;
|
|
246
289
|
/** publish 第三参归一化:裸 status 字符串(旧写法)或选项对象,逐字段校验 */
|
|
247
290
|
export declare function normalizePublishOptions(options: PageRegistryStatus | PageRegistryPublishOptions): PageRegistryPublishOptions;
|
|
248
|
-
/**
|
|
249
|
-
|
|
291
|
+
/**
|
|
292
|
+
* 声明归一化:HTML + 统一 SOMA DSL 必填;页面侧车字段只允许缺省或空串。
|
|
293
|
+
*
|
|
294
|
+
* 除了归一化后的声明,还把编译闸门那一次的编译结果(`compiledPage`)一并交出来,
|
|
295
|
+
* 供 `createPageVersionRecord` 落预编译产物时复用。闸门编的与预编译要编的是
|
|
296
|
+
* **同一份归一化声明**、同一个纯函数,发布路径上相邻两步——第二遍只是重付一次编译代价
|
|
297
|
+
* (演绎链接进来之后这笔代价随声明规模长),而落库结果逐字相同,多编一遍不会让任何东西红。
|
|
298
|
+
*/
|
|
299
|
+
export declare function normalizeDeclaration(declaration: unknown): {
|
|
300
|
+
declaration: PageRegistryDeclaration;
|
|
301
|
+
compiledPage: CompiledPageDeclaration;
|
|
302
|
+
};
|
|
250
303
|
/** 声明总字节数:UTF-8 计,涵盖 declaration 的全部字符串字段 */
|
|
251
304
|
export declare function declarationByteSize(declaration: PageRegistryDeclaration): number;
|
|
252
305
|
/** 存量 JSON 记录归一化:只补元数据;旧页面语法必须离线迁移,不在读取时自动转换。 */
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { type RegistryAssetStore, type SomaAssetKind } from './asset-store';
|
|
2
|
+
import type { SomaPageOouiArtifact } from '../../shared/types/ui-config.types';
|
|
3
|
+
/** 钉子格式版本。读到不认识的版本整份当"未钉住",不猜字段。 */
|
|
4
|
+
export declare const ASSET_PIN_VERSION = 1;
|
|
5
|
+
/**
|
|
6
|
+
* 供货方交出来的样式表分片。字段名与 `ComposedComponentPacks.styles`
|
|
7
|
+
* (`core/client/component/component-pack.ts`)一一对应,宿主接线是把已有的
|
|
8
|
+
* 合成结果原样递进来,不必再造一份形状。
|
|
9
|
+
*/
|
|
10
|
+
export interface PublishedAssetSupply {
|
|
11
|
+
/** 组件名 → 该组件的 CSS 分片(`styles.components`) */
|
|
12
|
+
components: Readonly<Record<string, string>>;
|
|
13
|
+
/** 共享资产名 → 分片(`styles.shared`) */
|
|
14
|
+
shared?: Readonly<Record<string, string>>;
|
|
15
|
+
/** 组件名 → 依赖的共享资产名(`styles.deps`) */
|
|
16
|
+
dependencies?: Readonly<Record<string, readonly string[]>>;
|
|
17
|
+
/** 包级基座分片(`styles.base`)。**次序即身份**——注入键是 `base:<下标>`,这里不重排 */
|
|
18
|
+
base?: readonly string[];
|
|
19
|
+
/** 组件名 → 令牌规则(`renderComponentTokenRule` 的产出;core 不代算,见下) */
|
|
20
|
+
tokens?: Readonly<Record<string, string>>;
|
|
21
|
+
/** 组件补丁(`composed.patches`) */
|
|
22
|
+
patches?: readonly {
|
|
23
|
+
target: string;
|
|
24
|
+
patchedBy: string;
|
|
25
|
+
css: string;
|
|
26
|
+
}[];
|
|
27
|
+
/**
|
|
28
|
+
* 供货包名 → 版本(如 `{ 'soma-ui': '1.4.2' }`)。
|
|
29
|
+
* 这是**词表版本**那一维的载体,也是 `isCompiledUsable` 第三道闸的判据来源
|
|
30
|
+
* (见 `currentAssetSupplyKey`)。参照 SDUI 的能力协商:各方把自己"是哪个版本"
|
|
31
|
+
* 报上来,而不是让对面去猜。不给就那道闸不判。
|
|
32
|
+
*/
|
|
33
|
+
packs?: Readonly<Record<string, string>>;
|
|
34
|
+
}
|
|
35
|
+
/** 供货来源;返回 null / undefined 表示"宿主没告诉我",此时不钉、不判 */
|
|
36
|
+
export type PublishedAssetSource = () => PublishedAssetSupply | null | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* 注入样式供货来源(宿主服务端接线;传 null 复位为"不钉")。
|
|
39
|
+
* 与组件清单同款:**每次都重新问一次,不缓存**——供货可随宿主热更新,
|
|
40
|
+
* 缓存住的表现是"换了组件库版本,钉子还钉着旧摘要"。
|
|
41
|
+
*/
|
|
42
|
+
export declare function setPublishedAssetSource(next: PublishedAssetSource | null): void;
|
|
43
|
+
/** 当前供货(没有则 undefined)。对账与钉住共用同一个入口,不各问一次。 */
|
|
44
|
+
export declare function currentAssetSupply(): PublishedAssetSupply | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* 供货指纹:`packs` 的 `名字@版本` 逐行摘要。缺 `packs` 返回 undefined(不判)。
|
|
47
|
+
*
|
|
48
|
+
* 为什么不去哈希 1.3MB 的全库字节:这个键会挂在**每次取页**都要过的
|
|
49
|
+
* `isCompiledUsable` 上。哈希全库每次约数毫秒,而"每次取页多几毫秒"是这条路径上
|
|
50
|
+
* 最典型的静默退化(功能全对、监控全绿,只有耗时在涨——`published-page-assets.ts`
|
|
51
|
+
* 的文件头就是为同一件事写的)。版本号是**声明出来的**能力协商,微秒级。
|
|
52
|
+
* 代价是宿主必须如实报版本;不报就不判,而不是拿一个猜的键去判。
|
|
53
|
+
*/
|
|
54
|
+
export declare function currentAssetSupplyKey(): string | undefined;
|
|
55
|
+
/** 钉住的一份资产 */
|
|
56
|
+
export interface SomaPinnedAsset {
|
|
57
|
+
kind: SomaAssetKind;
|
|
58
|
+
/** `sha256-<64 hex>` */
|
|
59
|
+
digest: string;
|
|
60
|
+
bytes: number;
|
|
61
|
+
/** 参与这份资产的构件名(升序)。对账要按同一份名单重算,"少了谁"才看得见 */
|
|
62
|
+
members: string[];
|
|
63
|
+
}
|
|
64
|
+
/** 一个页面版本的资产钉子 */
|
|
65
|
+
export interface SomaAssetPin {
|
|
66
|
+
pinVersion: typeof ASSET_PIN_VERSION;
|
|
67
|
+
/** 与 `compiled` 同一道版本闸(`DECLARATION_COMPILER_VERSION`) */
|
|
68
|
+
compilerVersion: string;
|
|
69
|
+
/** 供货包版本(词表版本那一维;供货方没报就缺席) */
|
|
70
|
+
packs?: Record<string, string>;
|
|
71
|
+
/** 资产清单(按 kind 升序) */
|
|
72
|
+
assets: SomaPinnedAsset[];
|
|
73
|
+
/**
|
|
74
|
+
* 本次**没能覆盖到**的东西。空则整个键不写。
|
|
75
|
+
* 它是"钉子宁可缺席不可说谎"的第二层:钉住了一部分,就必须写清哪一部分没钉住。
|
|
76
|
+
*/
|
|
77
|
+
caveats?: string[];
|
|
78
|
+
}
|
|
79
|
+
/** 钉住资产时需要的最小声明形状(只用 html;不引 page-registry-store 免得成环) */
|
|
80
|
+
export interface PinnableDeclaration {
|
|
81
|
+
html: string;
|
|
82
|
+
}
|
|
83
|
+
export interface PinPublishedAssetsOptions {
|
|
84
|
+
/** 演绎产物。演绎选出的组件不在 `html` 里,不带上就会漏钉恰好是演绎选中的那些 */
|
|
85
|
+
artifact?: SomaPageOouiArtifact | undefined;
|
|
86
|
+
/** 资产库(缺省取进程共享库) */
|
|
87
|
+
store?: RegistryAssetStore;
|
|
88
|
+
/** 编译器版本。由调用方传入,与 `compiled.compilerVersion` 同一个值 */
|
|
89
|
+
compilerVersion: string;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* 收集这一版真正会用到的构件名(升序去重)。
|
|
93
|
+
*
|
|
94
|
+
* 两个来源都要:
|
|
95
|
+
* - `html` 里的 `data-soma-component`(手写编排);
|
|
96
|
+
* - 演绎产物每个区域的构件树(REQ-014)。**漏掉后者的表现最阴**:
|
|
97
|
+
* 页面开出来,手写那部分有样式,演绎出来那一块光秃秃,而两者都"渲染成功"。
|
|
98
|
+
*/
|
|
99
|
+
export declare function pinnedAssetMembers(html: string, artifact?: SomaPageOouiArtifact | undefined): string[];
|
|
100
|
+
/** 拼装结果:规范次序的样式表 + 没找到分片的构件名 */
|
|
101
|
+
export interface AssembledComponentCss {
|
|
102
|
+
css: string;
|
|
103
|
+
missing: string[];
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* 按**规范次序**拼一份组件 CSS 闭包。幂等的全部要求都在这个函数里:
|
|
107
|
+
* 同一份构件名单 + 同一份供货 ⇒ 逐字节相同的字符串。
|
|
108
|
+
*
|
|
109
|
+
* 次序 = 基座 → 共享 → 令牌 → 组件 → 补丁,与 `pack-styles.ts` 的注入次序同层同序。
|
|
110
|
+
* 差别只有一处,写在这里免得下一个人以为是随手拉平的:运行时是**逐组件**注入
|
|
111
|
+
* (组件 A 的共享 → A 的令牌 → A 的分片 → 组件 B 的共享 → …),这里拉平成分层。
|
|
112
|
+
* 两者只在"某个组件分片去改共享类"时级联结果不同——而那本身违反分片纪律
|
|
113
|
+
* (分片只该碰自己的 `.soma-<组件>`)。钉子不为它兜底,但也不假装两者永远等价。
|
|
114
|
+
*
|
|
115
|
+
* `tokens` 由供货方交,core 不代算:令牌规则要读组件契约(`contract.tokens`),
|
|
116
|
+
* 契约住在组件库,core 自己算就等于在 core 里养第二份派生实现——两份必然漂,
|
|
117
|
+
* 而漂掉的表现是"钉子的字节与真实注入的字节差一条规则",对账天天报假漂移。
|
|
118
|
+
*/
|
|
119
|
+
export declare function assembleComponentCss(supply: PublishedAssetSupply, members: readonly string[]): AssembledComponentCss;
|
|
120
|
+
/**
|
|
121
|
+
* 钉住这一版的资产。返回 null = 这一版没有可钉的资产(宿主没供货 / 页面没引用构件 /
|
|
122
|
+
* 供货里这些构件一片 CSS 都没有 / 字节没能落库)。**返回 null 不阻断发布**。
|
|
123
|
+
*/
|
|
124
|
+
export declare function pinPublishedAssets(declaration: PinnableDeclaration, options: PinPublishedAssetsOptions): SomaAssetPin | null;
|
|
125
|
+
/** 钉子自身的 JSON 字节数(报体积用;它是**除声明与产物之外**新增在版本记录上的那一份) */
|
|
126
|
+
export declare function assetPinByteSize(pin: SomaAssetPin | undefined): number;
|
|
127
|
+
/**
|
|
128
|
+
* 发布时的漂移告示:上一版与这一版**构件名单一模一样、字节却不同** ⇒ 组件库在两次发布
|
|
129
|
+
* 之间换了。返回一句话,没漂返回 null。
|
|
130
|
+
*
|
|
131
|
+
* 为什么必须在发布这一刻说,而不是等回滚时再说:回滚是**故障现场**,那时候
|
|
132
|
+
* "样式也跟着变了"这条信息来得太晚,而且与故障本身混在一起分不开。
|
|
133
|
+
* 发布时说出来,操作者当场就知道"这次上线不只改了声明,还换了一整套样式基线"。
|
|
134
|
+
*
|
|
135
|
+
* 判据严格卡在"名单相同"上,因为名单不同本来就该产出不同字节(页面自己改了),
|
|
136
|
+
* 那时候报漂移是假警报——而假警报几次之后,真警报也没人看了。
|
|
137
|
+
*/
|
|
138
|
+
export declare function assetSupplyDriftNotice(previous: SomaAssetPin | undefined, current: SomaAssetPin | undefined, who: string): string | null;
|
|
139
|
+
/** 对账判定 */
|
|
140
|
+
export type SomaAssetReconcileStatus = 'match' | 'drift' | 'unpinned' | 'unavailable';
|
|
141
|
+
export interface SomaAssetReconciliation {
|
|
142
|
+
status: SomaAssetReconcileStatus;
|
|
143
|
+
/** 三段式(现状 / 问题 / 建议)问题清单;`match` 时为空 */
|
|
144
|
+
issues: string[];
|
|
145
|
+
/** 钉住的摘要(有钉子时) */
|
|
146
|
+
pinned?: string;
|
|
147
|
+
/** 按同一份名单、用今天的供货重算出的摘要(能算时) */
|
|
148
|
+
current?: string;
|
|
149
|
+
/** 漂移时:钉住的字节还在资产库里吗(在 ⇒ 这次漂移可恢复) */
|
|
150
|
+
recoverable?: boolean;
|
|
151
|
+
}
|
|
152
|
+
/** 对账所需的最小记录形状 */
|
|
153
|
+
export interface ReconcilableRecord {
|
|
154
|
+
name?: string;
|
|
155
|
+
version?: number;
|
|
156
|
+
assets?: unknown;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* 拿这一版的钉子对今天的供货。这是"回滚只回滚了一半"第一次可判定的地方:
|
|
160
|
+
* `reconcilePinnedAssets(v3 记录)` 回答"今天部署的组件 CSS 与 v3 发布那天是否一致"。
|
|
161
|
+
*
|
|
162
|
+
* 判定只有四种,且**都不抛**:对账是读路径上的诊断,它自己绝不能成为新的失败面。
|
|
163
|
+
*/
|
|
164
|
+
export declare function reconcilePinnedAssets(record: ReconcilableRecord, options?: {
|
|
165
|
+
store?: RegistryAssetStore;
|
|
166
|
+
}): SomaAssetReconciliation;
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
import type { IService, SomaServiceRequest } from '../../../api/IService';
|
|
2
2
|
/**
|
|
3
3
|
* GET /api/soma-registry/pages/list — 页面摘要清单(分页协议)。
|
|
4
|
-
* 查询参数(全部可选):app / keyword /
|
|
4
|
+
* 查询参数(全部可选):app / keyword / status(published/archived,闭集外的值按未提供
|
|
5
|
+
* 处理)/ includeArchived=1(需 read-private)/ limit / offset。
|
|
5
6
|
* 响应:{ schemaVersion, pages: [{ name, latestVersion, updatedAt, status, app, tags, title? }], total }。
|
|
6
7
|
*
|
|
7
|
-
* **可见性按主体分层**:无 `read-private` 作用域的调用方只看得到 published
|
|
8
|
-
*
|
|
8
|
+
* **可见性按主体分层**:无 `read-private` 作用域的调用方只看得到 published 页面——这条
|
|
9
|
+
* 铁律不受 `status` 影响:非特权主体传 status=archived 依旧看不到任何已下架页面(可见性
|
|
10
|
+
* 过滤先于 status 精筛生效)。草稿名与已下架页面同样是信息——按主体过滤而不是整端点鉴权:
|
|
9
11
|
* 画廊跑在浏览器里、拿不到管理凭据,端点一鉴权它就瞎了。
|
|
12
|
+
*
|
|
13
|
+
* `status` 与 `includeArchived` 的关系:`status` 更具体,选定后覆盖 `includeArchived`
|
|
14
|
+
* 的缺省收窄行为(例如 status=archived 无需再传 includeArchived=1);不传 `status`
|
|
15
|
+
* 时行为不受影响。
|
|
10
16
|
*/
|
|
11
17
|
export default class ListService implements IService {
|
|
12
18
|
get(req: SomaServiceRequest): Promise<Response>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type CompiledPageDeclaration } from '../../../build/compiler/page-declaration-compiler';
|
|
1
2
|
export interface CompilableDeclaration {
|
|
2
3
|
html: string;
|
|
3
4
|
uiYaml: string;
|
|
@@ -5,8 +6,70 @@ export interface CompilableDeclaration {
|
|
|
5
6
|
styleYaml?: string;
|
|
6
7
|
dataYaml?: string;
|
|
7
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* 声明位置。与架构 §3.1 的 `SomaSource`、空间层的 `SomaSpatialSource` 同构,
|
|
11
|
+
* 另收 `SomaBlockParseError` 的块标识与行号——两种定位方式都要能落地。
|
|
12
|
+
*/
|
|
13
|
+
export interface SomaCompileDiagnosticSource {
|
|
14
|
+
/** 声明所在文件(仓库相对路径),或 `<vocabulary:名字>` 这样的合成来源 */
|
|
15
|
+
file?: string;
|
|
16
|
+
/** 文件内的定位路径,如 `page.state`、utility 的 root */
|
|
17
|
+
path?: string;
|
|
18
|
+
/** SOMA DSL 块标识 */
|
|
19
|
+
blockId?: string;
|
|
20
|
+
/** 块内行号(1 起) */
|
|
21
|
+
line?: number;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* 一条编译诊断。**纯数据**:无函数、无 Map/Set、无循环引用,可直接 JSON/YAML 序列化——
|
|
25
|
+
* 它要跨进程(HTTP 响应)与跨包(soma-ai 自修复提示词)传,带不动活对象。
|
|
26
|
+
*
|
|
27
|
+
* 字段全部可选是刻意的:演绎链抛的 `SomaOouiError`(及其子类)带 `code` / `layer` /
|
|
28
|
+
* `remedy`,`src` 与 `trace` 视抛出点而定;解析器与块编译抛的多是普通 `Error` /
|
|
29
|
+
* `SomaBlockParseError`,只有 `message`(后者另有 `blockId` / `line`)。
|
|
30
|
+
* 同一个结构几种来源都装得下,消费者不必按来源分形状。
|
|
31
|
+
*/
|
|
32
|
+
export interface SomaCompileDiagnostic {
|
|
33
|
+
/** 与 `issues[]` 同序、逐字相同的那句中文(消费者可用它对账) */
|
|
34
|
+
message: string;
|
|
35
|
+
/** 解析器原话,不含 `[编译] …` 前缀 */
|
|
36
|
+
detail: string;
|
|
37
|
+
/** 错误类名,如 `SomaBlockParseError`;拿不到就是 `Error` */
|
|
38
|
+
name: string;
|
|
39
|
+
/** 稳定错误码(架构 §20.2 的公开契约),如 `OOUI-INT-NO-RULE` */
|
|
40
|
+
code?: string;
|
|
41
|
+
/** 出错的层,如 `spatial` / `intent` */
|
|
42
|
+
layer?: string;
|
|
43
|
+
/** 可操作的修法——AI 自修复真正要读的那一段 */
|
|
44
|
+
remedy?: string;
|
|
45
|
+
/** 指回声明位置 */
|
|
46
|
+
src?: SomaCompileDiagnosticSource;
|
|
47
|
+
/** 到失败点为止的推导链;只在原样可序列化时带出 */
|
|
48
|
+
trace?: readonly unknown[];
|
|
49
|
+
}
|
|
50
|
+
/** 干跑编译的完整结果:判定 + 结构化诊断 + 可复用的编译产物 */
|
|
51
|
+
export interface CompileGateResult {
|
|
52
|
+
/** 中文问题清单(空数组 = 通过);格式与 `dryRunCompile()` 逐字一致 */
|
|
53
|
+
issues: string[];
|
|
54
|
+
/** 与 `issues` 同序的结构化诊断;通过时为空数组 */
|
|
55
|
+
diagnostics: SomaCompileDiagnostic[];
|
|
56
|
+
/**
|
|
57
|
+
* 编译产物。**只有 `issues` 为空时才可能非 null**;
|
|
58
|
+
* 调用方复用它之前必须判空(拿不到就拒,不能跳过后续闸门)。
|
|
59
|
+
*/
|
|
60
|
+
compiled: CompiledPageDeclaration | null;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* 干跑编译的完整形态:判定 + 结构化诊断 + 编译产物。
|
|
64
|
+
*
|
|
65
|
+
* `issues` 与 `dryRunCompile()` 逐字一致——两者是同一条判定,不是两套规则。
|
|
66
|
+
*/
|
|
67
|
+
export declare function dryRunCompileWithDiagnostics(declaration: CompilableDeclaration): CompileGateResult;
|
|
8
68
|
/**
|
|
9
69
|
* 干跑编译,返回中文问题清单(空数组 = 通过)。
|
|
10
70
|
* 与安全扫描同款约定:命中即拒,清单点名到具体哪一件、解析器原话是什么。
|
|
71
|
+
*
|
|
72
|
+
* 需要 `code` / `src` / `trace` / `remedy` 或想复用编译产物的调用方,
|
|
73
|
+
* 改用 `dryRunCompileWithDiagnostics()`——本函数是它的字符串投影,判定完全相同。
|
|
11
74
|
*/
|
|
12
75
|
export declare function dryRunCompile(declaration: CompilableDeclaration): string[];
|
|
@@ -12,6 +12,20 @@ export interface DeriveSampleResult {
|
|
|
12
12
|
}
|
|
13
13
|
/** 从契约派生一份样张 props */
|
|
14
14
|
export declare function deriveContractSample(contract: SomaComponentContract): DeriveSampleResult;
|
|
15
|
+
/**
|
|
16
|
+
* 组件目录的交互式预览不能因作者还没补 example 而退化成空态。
|
|
17
|
+
*
|
|
18
|
+
* 这份值仍以契约为唯一输入:example/default/enum 永远优先;只有契约没有给出
|
|
19
|
+
* 内容时,才按字段类型和名称补一个确定的「预览基线」。它只用于开发者橱窗,
|
|
20
|
+
* 不回写目录样张、更不进入业务页面或生成链。
|
|
21
|
+
*/
|
|
22
|
+
export interface DerivePreviewSampleResult {
|
|
23
|
+
props: Record<string, unknown>;
|
|
24
|
+
/** 使用了预览基线的字段路径,供调用方如实标注来源。 */
|
|
25
|
+
synthesized: string[];
|
|
26
|
+
}
|
|
27
|
+
/** 从完整契约派生开发者橱窗的可运行预览基线。 */
|
|
28
|
+
export declare function deriveContractPreviewSample(contract: SomaComponentContract): DerivePreviewSampleResult;
|
|
15
29
|
/** 单个字段的样张值(组件内部或工具按需调用) */
|
|
16
30
|
export declare function deriveFieldSample(field: SomaContractField): unknown;
|
|
17
31
|
/**
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 容器断点:全体系唯一真源。
|
|
3
|
+
*
|
|
4
|
+
* ── 为什么单独一个模块 ─────────────────────────────────────────────
|
|
5
|
+
* 此前同一组值有**三份**副本:构建期求解器的元组表、soma-ui 的对象表、
|
|
6
|
+
* 视觉矩阵脚本里的硬编码数组。三处靠注释"同源同值"与人工同步维系,
|
|
7
|
+
* 而它们坏起来是**零报错**的——改一处漏一处,表现为构建期求解出的
|
|
8
|
+
* CSS 与组件 CSS 在不同宽度上折断,只有把窗口拖到那一档才看得见。
|
|
9
|
+
*
|
|
10
|
+
* ── 为什么不直接从求解器导出 ───────────────────────────────────────
|
|
11
|
+
* `build/layout/constraint-solver.ts` 带着 `SomaLayoutConstraintError`
|
|
12
|
+
* 与整个求解算法。soma-ui 若 import 它,等于把**构建期求解器拖进客户端
|
|
13
|
+
* 依赖图**,并会撞 `verify:client-boundary` / `verify:client-dep-graph`
|
|
14
|
+
* 的 build-only 规则。
|
|
15
|
+
*
|
|
16
|
+
* 因此本模块是**纯字面量**:不 import 任何东西,也不牵连任何运行时资产,
|
|
17
|
+
* 可以安全地被 soma-ui、生成链与构建期求解器同时消费——与
|
|
18
|
+
* `"./adaptive-vocabulary"` 子路径同一形态。
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* 容器断点八档(rem;16px 根字号下为 320/384/448/576/640/768/896/1024px)。
|
|
22
|
+
*
|
|
23
|
+
* 键序即档序,从窄到宽。`CONTAINER_STEPS` 依赖这个顺序。
|
|
24
|
+
*/
|
|
25
|
+
export declare const CONTAINER_BREAKPOINTS: {
|
|
26
|
+
readonly cqXs: 20;
|
|
27
|
+
readonly cqSm: 24;
|
|
28
|
+
readonly cqMd: 28;
|
|
29
|
+
readonly cqLg: 36;
|
|
30
|
+
readonly cqXl: 40;
|
|
31
|
+
readonly cq2xl: 48;
|
|
32
|
+
readonly cq3xl: 56;
|
|
33
|
+
readonly cq4xl: 64;
|
|
34
|
+
};
|
|
35
|
+
export type ContainerBreakpoint = keyof typeof CONTAINER_BREAKPOINTS;
|
|
36
|
+
/**
|
|
37
|
+
* 元组形态:构建期求解器按档序遍历时用(`solveLayout` 逐档各解一次,
|
|
38
|
+
* `css-emitter` 按 index 取 rem 值发 `@container (min-width: Nrem)`)。
|
|
39
|
+
*
|
|
40
|
+
* **由上表派生,不另写一份**——这正是本模块要消灭的那种双写。
|
|
41
|
+
*/
|
|
42
|
+
export declare const CONTAINER_STEPS: ReadonlyArray<readonly [ContainerBreakpoint, number]>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { type SomaDataObjectRelation, type SomaDataObjectRoles } from './types/data-config.types';
|
|
2
|
+
/**
|
|
3
|
+
* 校验 `roles:` 段。返回空数组即合法。
|
|
4
|
+
*
|
|
5
|
+
* `fieldKeys` 是本对象字段字典的键。**字典为空时直接拒收整段**:
|
|
6
|
+
* 角色的值就是字段名,没有字典就没有任何东西能对账,
|
|
7
|
+
* 放行等于把"指错字段"这类错推迟到渲染期,而渲染期它只会表现为一处空白。
|
|
8
|
+
*/
|
|
9
|
+
export declare function validateObjectRoles(raw: unknown, fieldKeys: readonly string[]): string[];
|
|
10
|
+
/** `validateObjectRelations` 的上下文 */
|
|
11
|
+
export interface ObjectRelationsContext {
|
|
12
|
+
/** 本对象字段字典的键(校验 `via`) */
|
|
13
|
+
fieldKeys: readonly string[];
|
|
14
|
+
/**
|
|
15
|
+
* 本次声明里全部已知的对象名(校验 `to`)。
|
|
16
|
+
*
|
|
17
|
+
* 传 `undefined` 表示**调用方拿不到这份名单**(块声明路径就是如此:块内私有对象
|
|
18
|
+
* 的全局身份要等 block-compile 合并之后才成形)。这时跳过 `to` 的存在性检查,
|
|
19
|
+
* 但**仍校验它是不是合法标识符**——放行未知名字与放行乱码是两件事。
|
|
20
|
+
*/
|
|
21
|
+
objectNames?: readonly string[];
|
|
22
|
+
/** 本对象名(`to` 指向自己是合法的:树形自关联) */
|
|
23
|
+
selfName?: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* 校验 `relations:` 段。返回空数组即合法。
|
|
27
|
+
*/
|
|
28
|
+
export declare function validateObjectRelations(raw: unknown, ctx: ObjectRelationsContext): string[];
|
|
29
|
+
/**
|
|
30
|
+
* 校验字段字典里的 `modifies:` 修饰关系。返回空数组即合法。
|
|
31
|
+
*
|
|
32
|
+
* 三条判据,都拦"能跑但看着不对"的错法:
|
|
33
|
+
* ① 目标必须在同一本字典里——指错则修饰字段并不进被修饰者,自己占一格;
|
|
34
|
+
* ② 不能指自己——自指的语义是"我修饰我",没有可执行含义;
|
|
35
|
+
* ③ 目标自己不能再带 `modifies`——**修饰不可级联**。级联时"谁是被呈现的那个"
|
|
36
|
+
* 没有唯一答案,而这种歧义只会表现为"少显示了一格"。
|
|
37
|
+
*/
|
|
38
|
+
export declare function validateFieldModifies(fields: Readonly<Record<string, {
|
|
39
|
+
modifies?: string;
|
|
40
|
+
}>>): string[];
|
|
41
|
+
/** 供解析器复用的类型别名出口,避免消费方再从两处 import */
|
|
42
|
+
export type { SomaDataObjectRelation, SomaDataObjectRoles };
|