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
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ICache } from '../infra/cache/ICache';
|
|
2
|
+
import type { SomaAdaptiveVocabulary } from '../../shared/types/adaptive.types';
|
|
2
3
|
import type { SomaPageAssets, ParsedRuntimeAssets } from './soma-bootstrap';
|
|
3
4
|
/**
|
|
4
5
|
* 资产解析器:将 SomaPageAssets 解析为引擎可消费的 ParsedRuntimeAssets。
|
|
@@ -7,9 +8,14 @@ import type { SomaPageAssets, ParsedRuntimeAssets } from './soma-bootstrap';
|
|
|
7
8
|
* - 预编译模式:assets 中已有 uiConfig/eventConfig,直接使用,零开销
|
|
8
9
|
* - 字符串模式:assets 中是 yaml 字符串,运行时解析,带 LRU 缓存
|
|
9
10
|
*/
|
|
11
|
+
export interface SomaAssetResolverOptions {
|
|
12
|
+
/** 阶梯词汇表(F-09):随 bootstrap 注入,用于 `_ui.yaml` 的 adaptive 校验 */
|
|
13
|
+
adaptiveVocabulary?: SomaAdaptiveVocabulary;
|
|
14
|
+
}
|
|
10
15
|
export declare class SomaAssetResolver {
|
|
11
16
|
private cache;
|
|
12
|
-
|
|
17
|
+
private readonly adaptiveVocabulary?;
|
|
18
|
+
constructor(cache?: ICache<ParsedRuntimeAssets>, options?: SomaAssetResolverOptions);
|
|
13
19
|
resolve(assets: SomaPageAssets): ParsedRuntimeAssets;
|
|
14
20
|
private parseLocale;
|
|
15
21
|
private parseAppConfig;
|
|
@@ -2,7 +2,25 @@ import type { IContainerAdapter } from '../container/IContainerAdapter';
|
|
|
2
2
|
import type { SomaCompiledBinding } from '../../shared/types/manifest.types';
|
|
3
3
|
import type { BindingEntry } from '../../shared/types/engine.types';
|
|
4
4
|
import type { SomaScopeResolver } from './scope-resolver';
|
|
5
|
+
import { type SomaPipeRegistry } from '../pipes/pipe-registry';
|
|
5
6
|
export type ModelWriteBack = (path: string, value: string) => void;
|
|
7
|
+
/**
|
|
8
|
+
* 行内组件钩子:列表/对象作用域渲染遇到带 props 的锚点时回调。
|
|
9
|
+
* 组件管理器据此在行克隆上按需展开/更新组件实例(scopeData 为行数据)。
|
|
10
|
+
*/
|
|
11
|
+
export type SomaRowComponentHook = (element: HTMLElement, propsDecl: Record<string, unknown>, scopeData: any) => void;
|
|
12
|
+
/**
|
|
13
|
+
* 行内组件释放钩子:一段**已渲染产物**即将离开 DOM 时回调(入参是被摘除的子树根)。
|
|
14
|
+
*
|
|
15
|
+
* 为什么必须有它:渲染器删行只做 DOM 层的 `remove()` / `clearRenderedChildren()`,
|
|
16
|
+
* 而行里可能住着组件实例(组件管理器的强引用 Set + 各自的事件引擎/控制器)。
|
|
17
|
+
* 没有这条通道,删掉的行会留下:onUnmount 不触发(焦点陷阱/滚动锁/定时器不回收)、
|
|
18
|
+
* 实例表随重渲线性膨胀、事件监听留在游离 DOM 上仍能派发 emit(幽灵行)。
|
|
19
|
+
* 三者都不报错——正是"静默失败"那一类。
|
|
20
|
+
*
|
|
21
|
+
* 约定:钩子在节点**还挂在树上**时调用(实现方可以再查子树),调用后渲染器才真的摘除。
|
|
22
|
+
*/
|
|
23
|
+
export type SomaRowComponentReleaseHook = (removedRoot: HTMLElement) => void;
|
|
6
24
|
export declare class SomaDomRenderer {
|
|
7
25
|
private adapter;
|
|
8
26
|
private resolver;
|
|
@@ -10,8 +28,36 @@ export declare class SomaDomRenderer {
|
|
|
10
28
|
private modelWriteBack;
|
|
11
29
|
private modelListeners;
|
|
12
30
|
private modelAbort;
|
|
13
|
-
|
|
31
|
+
private componentHook;
|
|
32
|
+
private componentReleaseHook;
|
|
33
|
+
private pipeRegistry;
|
|
34
|
+
setComponentHook(hook: SomaRowComponentHook | null): void;
|
|
35
|
+
setComponentReleaseHook(hook: SomaRowComponentReleaseHook | null): void;
|
|
36
|
+
/** 摘除单个已渲染节点:先放行释放钩子,再离开 DOM(顺序不可颠倒——查子树需要它还在树上) */
|
|
37
|
+
private removeRendered;
|
|
38
|
+
/**
|
|
39
|
+
* 清空容器内的渲染产物(保留 <template>)。
|
|
40
|
+
* 与 `adapter.clearRenderedChildren` 的唯一区别:逐个放行释放钩子。
|
|
41
|
+
* 无钩子时(非组件页面)零额外开销,直接走适配器原路径。
|
|
42
|
+
*/
|
|
43
|
+
private clearRendered;
|
|
44
|
+
init(adapter: IContainerAdapter, resolver: SomaScopeResolver, scopeTracker: WeakMap<HTMLElement, any>, pipeRegistry?: SomaPipeRegistry): void;
|
|
45
|
+
/**
|
|
46
|
+
* 行/对象作用域内查找锚点(经适配器,页面 data-soma-id 与实例 data-soma-scoped-id 同构):
|
|
47
|
+
* 行模板根元素自身就是锚点时也要命中(querySelector 只搜后代,
|
|
48
|
+
* 此前根自身锚点会静默失配,如 cart_row@title)。
|
|
49
|
+
*/
|
|
50
|
+
private findScopedAnchor;
|
|
51
|
+
/** 收集列表容器的变体模板:'item' 默认 + 'item:变体'(异构列表 role_by 用) */
|
|
52
|
+
private collectRoleTemplates;
|
|
53
|
+
/** 异构列表:按行数据取模板与变体名;同构列表回落默认模板 */
|
|
54
|
+
private pickRowTemplate;
|
|
55
|
+
/** 页面作用域的管道上下文(编译路径 text/attr 用) */
|
|
56
|
+
private rootPipeContext;
|
|
57
|
+
private applyPipes;
|
|
14
58
|
setModelWriteBack(fn: ModelWriteBack): void;
|
|
59
|
+
/** 模型回写必须在绑定表创建时附着,不能依赖首帧渲染是否走到该项。 */
|
|
60
|
+
private ensureModelListener;
|
|
15
61
|
bindEntry(binding: SomaCompiledBinding, container: HTMLElement): BindingEntry | null;
|
|
16
62
|
/**
|
|
17
63
|
* 为 binding 编译专用的渲染闭包。
|
|
@@ -32,8 +78,12 @@ export declare class SomaDomRenderer {
|
|
|
32
78
|
private renderObj;
|
|
33
79
|
private applyShowConfig;
|
|
34
80
|
private applyNestedShowConfig;
|
|
81
|
+
/** 嵌套列表的按行选模板:role_by 命中 item:<值> 变体,否则回落默认模板 */
|
|
82
|
+
private pickNestedTemplate;
|
|
35
83
|
private appendNestedTemplateItem;
|
|
36
84
|
private applyExtendedShowConfig;
|
|
85
|
+
/** 行作用域展示值:透明处理管道(`item.price | money`),无管道走原路径 */
|
|
86
|
+
private resolveRowValue;
|
|
37
87
|
private resolveShowValue;
|
|
38
88
|
private parseConditionalPath;
|
|
39
89
|
private isNestedShowMapping;
|
|
@@ -53,6 +53,12 @@ export declare class SomaEventEngine<TContext extends Record<string, unknown> =
|
|
|
53
53
|
* 避免点击 product_name 等子节点时,closest 停在无事件的子 id 上。
|
|
54
54
|
*/
|
|
55
55
|
private resolveEventBinding;
|
|
56
|
+
/**
|
|
57
|
+
* 从候选里挑与本次按键匹配的那条。
|
|
58
|
+
* 没有候选列表(绝大多数绑定)时原样返回,不产生任何额外判断成本。
|
|
59
|
+
* 一条都不匹配时返回 undefined —— 按了无关按键就该什么都不发生。
|
|
60
|
+
*/
|
|
61
|
+
private pickKeyVariant;
|
|
56
62
|
execute(config: SomaCompiledEvent, element: HTMLElement, originalEvent: Event): Promise<void>;
|
|
57
63
|
destroy(): void;
|
|
58
64
|
private executeNow;
|
|
@@ -17,9 +17,12 @@ export interface SomaRenderEngineOptions {
|
|
|
17
17
|
diagnostics?: SomaDiagnostics;
|
|
18
18
|
middleware?: SomaMiddlewareChain<SomaRenderMiddlewareContext>;
|
|
19
19
|
propertyWatcher?: SomaPropertyWatcher;
|
|
20
|
+
/** 格式化管道注册表(缺省内置管道集) */
|
|
21
|
+
pipeRegistry?: import('../pipes/pipe-registry').SomaPipeRegistry;
|
|
20
22
|
}
|
|
21
23
|
export interface SomaRenderMiddlewareContext {
|
|
22
|
-
|
|
24
|
+
/** publish = 事务中途的自愿提交(长任务播进展),其余含义见 render-engine 各方法 */
|
|
25
|
+
phase: 'full-render' | 'patch' | 'commit' | 'publish';
|
|
23
26
|
path?: string;
|
|
24
27
|
changedPaths: string[];
|
|
25
28
|
bindings: BindingEntry[];
|
|
@@ -45,6 +48,13 @@ export declare class SomaRenderEngine {
|
|
|
45
48
|
constructor(options: SomaRenderEngineOptions);
|
|
46
49
|
getScopeTracker(): WeakMap<HTMLElement, any>;
|
|
47
50
|
getRegisteredSomaIds(): string[];
|
|
51
|
+
/** 装配行内组件钩子(组件管理器调用,见 dom-renderer.SomaRowComponentHook) */
|
|
52
|
+
setComponentHook(hook: import('./dom-renderer').SomaRowComponentHook | null): void;
|
|
53
|
+
/**
|
|
54
|
+
* 装配行内组件**释放**钩子:删行/清空产物前放行,组件管理器据此销毁行内实例。
|
|
55
|
+
* 与 setComponentHook 成对存在——只有挂载没有卸载,就是泄漏。
|
|
56
|
+
*/
|
|
57
|
+
setComponentReleaseHook(hook: import('./dom-renderer').SomaRowComponentReleaseHook | null): void;
|
|
48
58
|
/** 注册属性监听器(文档 §10.2 watch API) */
|
|
49
59
|
watch(path: string, callback: WatchCallback, options?: WatcherOptions): () => void;
|
|
50
60
|
getPropertyWatcher(): SomaPropertyWatcher;
|
|
@@ -58,6 +68,20 @@ export declare class SomaRenderEngine {
|
|
|
58
68
|
endTransaction(): void;
|
|
59
69
|
/** 一次性提交事务内积累的 dirty path(Phase 2 commit 点) */
|
|
60
70
|
commit(): Promise<void>;
|
|
71
|
+
/**
|
|
72
|
+
* 事务**中途**的自愿提交点:把此刻积累的 patch 立刻上屏,事务不结束。
|
|
73
|
+
*
|
|
74
|
+
* 为什么需要它:一次事件 = 一次原子提交,是这套事务语义刻意的设计(避免中间态闪烁、
|
|
75
|
+
* 出错时 discardPendingPatches 能整体回滚)。但它有个代价——**长任务里的中途进展
|
|
76
|
+
* 播不出去**:实测 AI 生成一次 P50 约 40 秒,期间 Domain 改了多少次 statusText,
|
|
77
|
+
* 界面一次都不会动,连"生成中"都看不到;用户分不清"在想"还是"卡死"。
|
|
78
|
+
*
|
|
79
|
+
* 这里给的是**自愿**的中途提交,而不是把事务拆掉:
|
|
80
|
+
* - 不调用它 → 行为与过去逐字节一致(原子提交 + 失败回滚),存量页面零影响;
|
|
81
|
+
* - 调用它 → 调用方明确知道:**已经上屏的这部分不再享有失败回滚**。
|
|
82
|
+
* 这个取舍必须由业务自己做——它才知道"这一帧值不值得让用户看见"。
|
|
83
|
+
*/
|
|
84
|
+
publishInTransaction(): Promise<void>;
|
|
61
85
|
/** force 全量 render 前丢弃 pending patch(避免 commit + render 双写) */
|
|
62
86
|
discardPendingPatches(): void;
|
|
63
87
|
isInTransaction(): boolean;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { SomaAdaptiveVocabulary } from '../../shared/types/adaptive.types';
|
|
1
2
|
import type { IContainerAdapter } from '../container/IContainerAdapter';
|
|
2
3
|
import type { SomaDiagnostics } from '../diagnostics/SomaDiagnostics';
|
|
3
4
|
import type { SomaMiddlewareChain } from '../middleware/SomaMiddlewareChain';
|
|
@@ -31,6 +32,10 @@ export interface RuntimeBuildInput {
|
|
|
31
32
|
diagnostics: SomaDiagnostics;
|
|
32
33
|
renderMiddleware?: SomaMiddlewareChain<SomaRenderMiddlewareContext>;
|
|
33
34
|
eventMiddleware?: SomaMiddlewareChain<SomaEventMiddlewareContext>;
|
|
35
|
+
/** 格式化管道注册表(缺省内置管道集) */
|
|
36
|
+
pipeRegistry?: import('../pipes/pipe-registry').SomaPipeRegistry;
|
|
37
|
+
/** 阶梯词汇表(F-09),经宿主 bootstrap 注入;无 adaptive 声明的页面用不到 */
|
|
38
|
+
adaptiveVocabulary?: SomaAdaptiveVocabulary;
|
|
34
39
|
}
|
|
35
40
|
export interface SomaRuntime {
|
|
36
41
|
renderEngine: SomaRenderEngine;
|
|
@@ -41,6 +46,8 @@ export interface SomaRuntime {
|
|
|
41
46
|
triggerEngine: SomaTriggerEngine;
|
|
42
47
|
timerEngine: SomaTimerEngine;
|
|
43
48
|
resolver: SomaScopeResolver;
|
|
49
|
+
/** 页面运行时清单(组件管理器标记 emit 路由用) */
|
|
50
|
+
manifest: import('../../shared/types/manifest.types').SomaRuntimeManifest;
|
|
44
51
|
}
|
|
45
52
|
/**
|
|
46
53
|
* 运行时构建器:将配置 + 实例 + DOM 组装为可运行的引擎组。
|
|
@@ -8,21 +8,35 @@ import type { PropertyTrigger } from '../../shared/types/trigger.types';
|
|
|
8
8
|
import type { ParsedTimer } from '../../shared/types/timer.types';
|
|
9
9
|
import type { StyleConfig } from '../../shared/types/style-config.types';
|
|
10
10
|
import type { UiConfig } from '../../shared/types/ui-config.types';
|
|
11
|
+
import type { SomaAdaptiveVocabulary } from '../../shared/types/adaptive.types';
|
|
11
12
|
import type { SomaPageRoot } from '../../shared/types/domain.types';
|
|
12
13
|
import { SomaAssetResolver } from './asset-resolver';
|
|
13
14
|
import type { SomaEventMiddlewareContext } from './event-engine';
|
|
14
15
|
import type { SomaRenderEngine, SomaRenderMiddlewareContext } from './render-engine';
|
|
15
16
|
import type { SomaStyleBinder } from './style-binder';
|
|
17
|
+
import type { SomaDataConfig, SomaDataDicts } from '../../shared/types/data-config.types';
|
|
16
18
|
import type { WatchCallback, WatcherOptions } from '../../shared/types/watcher.types';
|
|
19
|
+
import type { SomaComponentDefinition } from '../component/component-definition.types';
|
|
20
|
+
import { type SomaPipeFn } from '../pipes/pipe-registry';
|
|
21
|
+
import { type SomaErrorEvent, type SomaPageIdentity } from '../observability/error-reporter';
|
|
17
22
|
export interface SomaPageAssets {
|
|
18
23
|
html: string;
|
|
19
24
|
includes?: Record<string, string>;
|
|
20
25
|
DomainClass: new () => SomaPageRoot;
|
|
21
26
|
uiYaml?: string;
|
|
27
|
+
/** 仅供构建/测试入口携带的外置声明块;mount 本身不读取。 */
|
|
28
|
+
declarationBlocks?: ReadonlyMap<string, string>;
|
|
22
29
|
eventYaml?: string;
|
|
23
30
|
styleYaml?: string;
|
|
24
31
|
localeYaml?: string;
|
|
25
32
|
appConfigYaml?: string;
|
|
33
|
+
/**
|
|
34
|
+
* 从统一声明编译出的数据对象运行时资产。
|
|
35
|
+
* 提供后 bootstrap 在首渲前解析声明、异步取数并注入 page.data,
|
|
36
|
+
* 完成后触发一次全量渲染;解析/取数失败不阻塞页面(data 保持空对象 + console.error)。
|
|
37
|
+
* 不提供时加载路径零变化。
|
|
38
|
+
*/
|
|
39
|
+
dataYaml?: string;
|
|
26
40
|
uiConfig?: UiConfig;
|
|
27
41
|
eventConfig?: ParsedEvent[];
|
|
28
42
|
triggerConfig?: PropertyTrigger[];
|
|
@@ -30,8 +44,36 @@ export interface SomaPageAssets {
|
|
|
30
44
|
styleConfig?: StyleConfig;
|
|
31
45
|
locale?: Record<string, unknown>;
|
|
32
46
|
appConfig?: unknown;
|
|
47
|
+
/** 数据对象层声明的预编译形态(构建阶段已解析校验,优先于 dataYaml) */
|
|
48
|
+
dataConfig?: SomaDataConfig;
|
|
33
49
|
/** Full router path including query string (e.g. /items/detail?id=1) */
|
|
34
50
|
routerPath?: string;
|
|
51
|
+
/**
|
|
52
|
+
* 组件运行时定义(组件体系模块 7,可选)。
|
|
53
|
+
* 键为契约名;页面 HTML 中 data-soma-component 引用的组件必须在此提供。
|
|
54
|
+
* 不提供时组件能力整体旁路,页面走既有路径。
|
|
55
|
+
*/
|
|
56
|
+
components?: Record<string, SomaComponentDefinition>;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* 错误采集接线声明(可观测性,默认关闭)。
|
|
60
|
+
*
|
|
61
|
+
* 为什么放在 bootstrap 而不是让 Host 自己 install:采集器本身只会记"出了什么错",
|
|
62
|
+
* 记不住"这是哪个页面的哪个版本"——而页面身份只有挂载时点知道。挂在生命周期
|
|
63
|
+
* 编排器上,身份随挂载自动盖戳、随卸载自动摘监听,Host 不需要维护任何状态。
|
|
64
|
+
*/
|
|
65
|
+
export interface SomaBootstrapErrorReporting {
|
|
66
|
+
/** 页面身份:错误归因到「页面名@版本」的唯一依据(声明态页面必须带 version) */
|
|
67
|
+
page: SomaPageIdentity;
|
|
68
|
+
/**
|
|
69
|
+
* 上报通道。缺省走 console.error 单行 JSON——宿主一行开启就先有数据,
|
|
70
|
+
* 等接了真通道(sendBeacon / 第三方 SDK)再替换,不必为"先看看"写胶水。
|
|
71
|
+
*/
|
|
72
|
+
report?: (event: SomaErrorEvent) => void;
|
|
73
|
+
/** 同签名错误去重窗口(毫秒),透传采集器 */
|
|
74
|
+
dedupeWindowMs?: number;
|
|
75
|
+
/** 单页上报条数上限,透传采集器 */
|
|
76
|
+
maxEvents?: number;
|
|
35
77
|
}
|
|
36
78
|
export interface SomaBootstrapOptions {
|
|
37
79
|
adapter?: IContainerAdapter;
|
|
@@ -39,6 +81,25 @@ export interface SomaBootstrapOptions {
|
|
|
39
81
|
diagnostics?: SomaDiagnostics;
|
|
40
82
|
telemetry?: SomaTelemetry;
|
|
41
83
|
assetResolver?: SomaAssetResolver;
|
|
84
|
+
/**
|
|
85
|
+
* Host 级组件注册(组件体系模块 7)。
|
|
86
|
+
* 经 `@soma-host/bootstrap/soma-bootstrap.ts` 的 configureSomaBootstrap 注入,
|
|
87
|
+
* 对该 Host 的所有页面生效;页面资产 components 同名时覆盖 Host 级定义。
|
|
88
|
+
*/
|
|
89
|
+
components?: Record<string, SomaComponentDefinition>;
|
|
90
|
+
/**
|
|
91
|
+
* Host 自定义格式化管道(模块 7 U4):{ 管道名: 纯函数 },与内置管道合并。
|
|
92
|
+
* 内置:money / tpl / date / percent / plural。
|
|
93
|
+
*/
|
|
94
|
+
pipes?: Record<string, SomaPipeFn>;
|
|
95
|
+
/**
|
|
96
|
+
* 阶梯词汇注册位(F-09 / 契约 C5),与组件注册同点:
|
|
97
|
+
* `adaptiveVocabulary: createSomaUiAdaptiveVocabulary()`。
|
|
98
|
+
*
|
|
99
|
+
* core **不内置任何级语义**——语法归语言、词汇归组件。不注册而页面声明了
|
|
100
|
+
* `adaptive.ladder` 时按"词汇未知"快速失败,而不是静默忽略那些级。
|
|
101
|
+
*/
|
|
102
|
+
adaptiveVocabulary?: SomaAdaptiveVocabulary;
|
|
42
103
|
/** Render-engine middleware chain (opt-in) */
|
|
43
104
|
renderMiddleware?: SomaMiddlewareChain<SomaRenderMiddlewareContext>;
|
|
44
105
|
/**
|
|
@@ -46,6 +107,11 @@ export interface SomaBootstrapOptions {
|
|
|
46
107
|
* Use `createPermissionMiddleware` when events declare `permission:code` in pipeline.
|
|
47
108
|
*/
|
|
48
109
|
eventMiddleware?: SomaMiddlewareChain<SomaEventMiddlewareContext>;
|
|
110
|
+
/**
|
|
111
|
+
* 错误采集接线(默认关闭:不给就一个全局监听都不装)。
|
|
112
|
+
* 库不该擅自劫持 window 的错误钩子,是否采集由 Host 显式决定。
|
|
113
|
+
*/
|
|
114
|
+
errorReporting?: SomaBootstrapErrorReporting;
|
|
49
115
|
}
|
|
50
116
|
export interface ParsedRuntimeAssets {
|
|
51
117
|
uiConfig: UiConfig;
|
|
@@ -76,11 +142,26 @@ export declare class SomaBootstrap {
|
|
|
76
142
|
private runtimeResolver;
|
|
77
143
|
private proxy;
|
|
78
144
|
private domainInstance;
|
|
145
|
+
private componentManager;
|
|
146
|
+
private hostComponents;
|
|
147
|
+
private pipeRegistry;
|
|
148
|
+
/** 阶梯词汇表:Host 级注册,对该 Host 全部页面生效;未注册时恒为 undefined */
|
|
149
|
+
private readonly adaptiveVocabulary?;
|
|
150
|
+
/** 数据对象层:当前页面的声明(无 *_data.yaml 时为 null,整条路径旁路) */
|
|
151
|
+
private dataConfig;
|
|
152
|
+
/** 数据对象层:最近一次取数任务(whenDataReady 暴露给测试/调试) */
|
|
153
|
+
private dataReady;
|
|
154
|
+
/** 数据对象层:字段字典产物(soma-ui 双态映射消费) */
|
|
155
|
+
private dataDicts;
|
|
79
156
|
private mounted;
|
|
80
157
|
private diagnostics;
|
|
81
158
|
private readonly telemetry;
|
|
82
159
|
private container;
|
|
83
160
|
private assets;
|
|
161
|
+
/** 错误采集配置(null = 未开启,整条路径旁路) */
|
|
162
|
+
private readonly errorReporting;
|
|
163
|
+
/** 错误采集句柄:mount 时装、cleanup 时摘,生命周期与页面严格同寿 */
|
|
164
|
+
private errorReporter;
|
|
84
165
|
constructor(options?: SomaBootstrapOptions);
|
|
85
166
|
mount(container: HTMLElement, assets: SomaPageAssets): Promise<void>;
|
|
86
167
|
hotSwap(overrides: Partial<SomaPageAssets>, options?: {
|
|
@@ -105,11 +186,48 @@ export declare class SomaBootstrap {
|
|
|
105
186
|
whenSettled(): Promise<void>;
|
|
106
187
|
getDomainValue(path: string): unknown;
|
|
107
188
|
getRegisteredSomaIds(): string[];
|
|
189
|
+
/** 数据对象层字段字典产物(对象名 → 字段名 → 字典条目;无声明时为空对象) */
|
|
190
|
+
getDataDicts(): SomaDataDicts;
|
|
191
|
+
/** 等待当前数据对象取数任务完成(测试 / 调试;无声明时立即 resolve) */
|
|
192
|
+
whenDataReady(): Promise<void>;
|
|
108
193
|
/** 获取渲染引擎(测试 / 调试) */
|
|
109
194
|
getRenderEngine(): SomaRenderEngine | null;
|
|
110
195
|
/** 监听属性变更(委托 RenderEngine.watch) */
|
|
111
196
|
watch(path: string, callback: WatchCallback, options?: WatcherOptions): () => void;
|
|
197
|
+
/**
|
|
198
|
+
* 更新错误采集的页面身份。
|
|
199
|
+
* 声明态页面"发布新版本 → 原地重渲"时调用,后续错误立刻落在新版本上——
|
|
200
|
+
* 这一个调用就是"哪个版本引入的错误"这个问题的全部答案。
|
|
201
|
+
* 未开启采集时是安全的空操作。
|
|
202
|
+
*/
|
|
203
|
+
setErrorReportingPage(page: SomaPageIdentity): void;
|
|
204
|
+
/** 装(或复用)错误采集器;未配置时整条路径旁路,一个全局监听都不装 */
|
|
205
|
+
private setupErrorReporting;
|
|
206
|
+
/**
|
|
207
|
+
* 引擎自身捕获的异常进同一采集通道。
|
|
208
|
+
* 全局 error 监听抓不到这些——它们已经被引擎 catch 住了(页面不崩,但确实错了),
|
|
209
|
+
* 不显式补一条,可观测数据就会漏掉最该看的那类问题。
|
|
210
|
+
*/
|
|
211
|
+
private captureEngineError;
|
|
112
212
|
private createDomainInstance;
|
|
213
|
+
/**
|
|
214
|
+
* 首渲前解析数据对象声明并向 Domain 实例注入 reloadData 钩子。
|
|
215
|
+
* 无声明(dataConfig/dataYaml 均缺省)时整条路径旁路,加载零变化;
|
|
216
|
+
* 声明非法只 console.error,页面继续以空 data 挂载(不阻塞)。
|
|
217
|
+
*/
|
|
218
|
+
private prepareDataLayer;
|
|
219
|
+
/**
|
|
220
|
+
* 执行数据对象取数:解析完成后注入 page.data、缓存字段字典并触发一次全量渲染。
|
|
221
|
+
* 任何失败均不阻塞页面:data 置空对象 + console.error。
|
|
222
|
+
*/
|
|
223
|
+
private loadDataObjects;
|
|
224
|
+
/**
|
|
225
|
+
* 主题派生注入:app.config 声明 theme.brand 时全库换装;配置非法只告警不阻断挂载。
|
|
226
|
+
* 主题是引擎内建路径,不是 bootstrap 可注册能力。
|
|
227
|
+
*/
|
|
228
|
+
private applyHostTheme;
|
|
229
|
+
/** 组件管理器装配:无 components 资产时保持 null,组件能力整体旁路 */
|
|
230
|
+
private setupComponentManager;
|
|
113
231
|
private buildRuntime;
|
|
114
232
|
private startDeclarativeTimers;
|
|
115
233
|
private stopDeclarativeTimers;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/** 页面身份:错误归因的最小事实 */
|
|
2
|
+
export interface SomaPageIdentity {
|
|
3
|
+
/** 页面名(声明仓库里的 name;文件态页面用路由路径) */
|
|
4
|
+
name: string;
|
|
5
|
+
/** 声明版本号(声明态页面才有) */
|
|
6
|
+
version?: number;
|
|
7
|
+
/** 声明来源:file=文件态四件套 / registry=声明仓库 / preview=即时预览 */
|
|
8
|
+
source?: 'file' | 'registry' | 'preview';
|
|
9
|
+
}
|
|
10
|
+
/** 规范化后的错误事件 */
|
|
11
|
+
export interface SomaErrorEvent {
|
|
12
|
+
kind: 'runtime' | 'promise' | 'resource';
|
|
13
|
+
message: string;
|
|
14
|
+
stack?: string;
|
|
15
|
+
/** 资源类错误的地址 */
|
|
16
|
+
source?: string;
|
|
17
|
+
line?: number;
|
|
18
|
+
column?: number;
|
|
19
|
+
page: SomaPageIdentity;
|
|
20
|
+
/** 事件时间(毫秒时间戳,由采集器打点) */
|
|
21
|
+
at: number;
|
|
22
|
+
/** 页面地址(去掉 hash 与 query 的路径部分,避免带出敏感参数) */
|
|
23
|
+
path?: string;
|
|
24
|
+
}
|
|
25
|
+
export interface SomaErrorReporterOptions {
|
|
26
|
+
page: SomaPageIdentity;
|
|
27
|
+
/** 上报通道:Host 注入(接口/console/第三方 SDK 皆可) */
|
|
28
|
+
report: (event: SomaErrorEvent) => void;
|
|
29
|
+
/** 同签名错误的去重窗口(毫秒,默认 60s) */
|
|
30
|
+
dedupeWindowMs?: number;
|
|
31
|
+
/** 单页最多上报条数(默认 50,防错误风暴) */
|
|
32
|
+
maxEvents?: number;
|
|
33
|
+
}
|
|
34
|
+
export interface SomaErrorReporterHandle {
|
|
35
|
+
/** 更新页面身份(发布新版本后重渲时调用) */
|
|
36
|
+
setPage(page: SomaPageIdentity): void;
|
|
37
|
+
/** 手动上报一条(业务侧捕获的异常也能进同一通道) */
|
|
38
|
+
capture(error: unknown, kind?: SomaErrorEvent['kind']): void;
|
|
39
|
+
/** 卸载全局监听 */
|
|
40
|
+
dispose(): void;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* 安装前端错误采集器。返回句柄用于更新页面身份与卸载。
|
|
44
|
+
*
|
|
45
|
+
* 用法(Host 侧):
|
|
46
|
+
* const reporter = installSomaErrorReporter({
|
|
47
|
+
* page: { name: 'order-console', version: 3, source: 'registry' },
|
|
48
|
+
* report: (e) => navigator.sendBeacon('/api/observability/error', JSON.stringify(e)),
|
|
49
|
+
* });
|
|
50
|
+
*/
|
|
51
|
+
export declare function installSomaErrorReporter(options: SomaErrorReporterOptions): SomaErrorReporterHandle;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type SomaAdaptiveConfig, type SomaAdaptiveVocabulary } from '../../shared/types/adaptive.types';
|
|
2
|
+
/** 阶梯声明错误(ERR-02):携带违规位置,文案必须给出合法取值或接线点 */
|
|
3
|
+
export declare class SomaAdaptiveConfigError extends Error {
|
|
4
|
+
readonly path: string;
|
|
5
|
+
constructor(message: string, path?: string);
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* 合并多份词汇来源为一张词汇表。
|
|
9
|
+
*
|
|
10
|
+
* 同名级语义被注册两次即显式冲突报错,不做"后者覆盖前者"——
|
|
11
|
+
* 静默覆盖会让"实际生效的级语义"取决于注册顺序,那是第二份事实。
|
|
12
|
+
*/
|
|
13
|
+
export declare function createAdaptiveVocabulary(...sources: SomaAdaptiveVocabulary[]): SomaAdaptiveVocabulary;
|
|
14
|
+
/**
|
|
15
|
+
* 解析并校验 `_ui.yaml` 顶层 `adaptive` 键。
|
|
16
|
+
*
|
|
17
|
+
* 解析期四项快速失败校验(F-08):
|
|
18
|
+
* 1. 级数 ≤ 5;
|
|
19
|
+
* 2. 每一级的槽与级值 ∈ 已注册词汇表(词汇未注册 = 词汇未知);
|
|
20
|
+
* 3. pin 条目合法且不重复;
|
|
21
|
+
* 4. pin 与 ladder 冲突(同槽既被钉住又被列入降级序)即非法。
|
|
22
|
+
*
|
|
23
|
+
* `pin` 与 ladder 槽的**锚点存在性**不在此校验——解析期看不到 DOM,
|
|
24
|
+
* 那一项在编译期做(见 adaptive-compile.ts),归属仍是 F-08。
|
|
25
|
+
*/
|
|
26
|
+
export declare function parseAdaptiveConfig(raw: unknown, vocabulary?: SomaAdaptiveVocabulary, path?: string, options?: {
|
|
27
|
+
vocabularyRequired?: boolean;
|
|
28
|
+
}): SomaAdaptiveConfig;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { SomaDataConfig } from '../../shared/types/data-config.types';
|
|
2
|
+
export declare class SomaDataConfigError extends Error {
|
|
3
|
+
readonly path: string;
|
|
4
|
+
constructor(message: string, path?: string);
|
|
5
|
+
}
|
|
6
|
+
/** 解析后的 `$` 引用:三源之一 + 字段路径段 */
|
|
7
|
+
export interface SomaDataRef {
|
|
8
|
+
/** query:URL 参数;page:Domain 字段;object:已解析数据对象 */
|
|
9
|
+
source: 'query' | 'page' | 'object';
|
|
10
|
+
/** source 为 object 时的对象名 */
|
|
11
|
+
object?: string;
|
|
12
|
+
/** 引用的字段路径段(`$order.trace.no` → ['trace', 'no']) */
|
|
13
|
+
path: string[];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* 解析 `$` 引用语法:`$query.<键>` / `$page.<路径>` / `$<数据对象>.<字段路径>`。
|
|
17
|
+
* 语法非法时返回 null(由调用方按上下文报带定位的声明错误)。
|
|
18
|
+
*/
|
|
19
|
+
export declare function parseDataRef(text: string): SomaDataRef | null;
|
|
20
|
+
/**
|
|
21
|
+
* 归一化 transform 值中的管道段:规格允许 `date: 'YYYY-MM-DD'` 的冒号简写,
|
|
22
|
+
* 统一改写成 pipe-registry 的标准语法 `date('YYYY-MM-DD')` 后复用其解析器。
|
|
23
|
+
* 首段(字段路径)原样保留。
|
|
24
|
+
*/
|
|
25
|
+
export declare function normalizeDataPipeValue(rawValue: string): string;
|
|
26
|
+
/**
|
|
27
|
+
* 解析 *_data.yaml 的原始对象(yaml.load 产物)→ SomaDataConfig。
|
|
28
|
+
* 空输入(null/undefined)返回空声明;结构非法抛 SomaDataConfigError。
|
|
29
|
+
*/
|
|
30
|
+
export declare function parseDataConfig(raw: unknown): SomaDataConfig;
|
|
31
|
+
/**
|
|
32
|
+
* 解析 *_data.yaml 字符串 → SomaDataConfig(运行时字符串模式入口)。
|
|
33
|
+
*/
|
|
34
|
+
export declare function parseDataYaml(yamlStr: string): SomaDataConfig;
|
|
@@ -7,6 +7,8 @@ export declare class SomaEventParseError extends Error {
|
|
|
7
7
|
readonly rawExpression: string;
|
|
8
8
|
constructor(message: string, rawExpression: string);
|
|
9
9
|
}
|
|
10
|
+
/** 是否为已知 DOM 事件(组件管理器区分 DOM 订阅与疑似 emit 订阅用) */
|
|
11
|
+
export declare function isKnownDomEvent(name: string): boolean;
|
|
10
12
|
/**
|
|
11
13
|
* 解析事件选择器字符串
|
|
12
14
|
*
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import type { StyleConfig } from '../../shared/types/style-config.types';
|
|
1
|
+
import type { SomaStyleViolationKind, StyleConfig } from '../../shared/types/style-config.types';
|
|
2
2
|
export declare class SomaStyleConfigError extends Error {
|
|
3
3
|
readonly path: string;
|
|
4
|
-
|
|
4
|
+
/** 违规类别;仅结构化校验失败时缺省(那类失败没有"类别"可言) */
|
|
5
|
+
readonly kind?: SomaStyleViolationKind;
|
|
6
|
+
constructor(message: string, path?: string, kind?: SomaStyleViolationKind);
|
|
5
7
|
}
|
|
6
8
|
/**
|
|
7
9
|
* 将 YAML 解析后的原始对象转换为类型安全的 StyleConfig
|
|
@@ -11,7 +13,7 @@ export declare class SomaStyleConfigError extends Error {
|
|
|
11
13
|
* - base 的值必须是纯 Tailwind 类名字符串
|
|
12
14
|
* - states 的 condition 必须是纯属性路径,value 必须是基础类型
|
|
13
15
|
* - transitions 的 trigger 必须是有效枚举值
|
|
14
|
-
* - themes
|
|
16
|
+
* - base / themes 命中布局类模式即失败;states / transitions 放行显隐对(F-06)
|
|
15
17
|
*
|
|
16
18
|
* @param raw - YAML 解析后的原始对象
|
|
17
19
|
* @returns 类型安全的 StyleConfig
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { UiConfig, ShowMapping, ParsedShowEntry } from '../../shared/types/ui-config.types';
|
|
2
|
+
import type { SomaAdaptiveVocabulary } from '../../shared/types/adaptive.types';
|
|
2
3
|
/**
|
|
3
4
|
* UI 配置解析错误
|
|
4
5
|
* 携带错误路径信息以便定位问题
|
|
@@ -7,6 +8,23 @@ export declare class SomaUiConfigError extends Error {
|
|
|
7
8
|
readonly path: string;
|
|
8
9
|
constructor(message: string, path?: string);
|
|
9
10
|
}
|
|
11
|
+
export interface SomaUiConfigParseOptions {
|
|
12
|
+
/**
|
|
13
|
+
* 阶梯词汇表(F-09)。core 不内置任何级语义,词汇由宿主 bootstrap 注入;
|
|
14
|
+
* 不传而页面声明了 `adaptive.ladder` 时,按"词汇未知"快速失败。
|
|
15
|
+
*/
|
|
16
|
+
adaptiveVocabulary?: SomaAdaptiveVocabulary;
|
|
17
|
+
/**
|
|
18
|
+
* 词汇是否必须在本次解析时到位。默认 true(页面装载路径)。
|
|
19
|
+
*
|
|
20
|
+
* 构建期预编译是唯一的 false 场景:那一刻宿主 bootstrap 尚未加载,
|
|
21
|
+
* 词汇无处可取。此时结构校验(级数 / 单键 / pin 冲突 / profile)照做,
|
|
22
|
+
* 只把**词汇归属**这一项推迟到编译期 `compileAdaptive` ——
|
|
23
|
+
* 那里词汇必然在手,未注册同样报错、同样指路,
|
|
24
|
+
* 所以推迟的是报错时机,不是报错本身。
|
|
25
|
+
*/
|
|
26
|
+
adaptiveVocabularyRequired?: boolean;
|
|
27
|
+
}
|
|
10
28
|
/**
|
|
11
29
|
* 将 YAML 解析后的原始对象转换为类型安全的 UiConfig
|
|
12
30
|
*
|
|
@@ -16,12 +34,15 @@ export declare class SomaUiConfigError extends Error {
|
|
|
16
34
|
* - show 键不能为空
|
|
17
35
|
* - 嵌套绑定的 bind 和 show 必须成对出现
|
|
18
36
|
* - 处理 somaId@attr 扩展语法
|
|
37
|
+
* - 可选的 adaptive 保留键按阶梯 schema 校验(缺席则完全旁路,产物不变)
|
|
19
38
|
*
|
|
20
39
|
* @param raw - YAML 解析后的原始对象(通常来自 yaml-loader)
|
|
40
|
+
* @param options - 解析上下文;adaptiveVocabulary 由宿主 bootstrap 注入
|
|
21
41
|
* @returns 类型安全的 UiConfig 对象
|
|
22
42
|
* @throws SomaUiConfigError 格式不合法时抛出
|
|
43
|
+
* @throws SomaAdaptiveConfigError adaptive 声明不合法时抛出
|
|
23
44
|
*/
|
|
24
|
-
export declare function parseUiConfig(raw: any): UiConfig;
|
|
45
|
+
export declare function parseUiConfig(raw: any, options?: SomaUiConfigParseOptions): UiConfig;
|
|
25
46
|
/**
|
|
26
47
|
* 解析 show 键中的 somaId@attr 语法
|
|
27
48
|
*
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export declare class SomaScopeError extends Error {
|
|
2
|
+
readonly blockId: string;
|
|
3
|
+
constructor(message: string, blockId: string);
|
|
4
|
+
}
|
|
5
|
+
export type AliasKind = 'api' | 'path';
|
|
6
|
+
export interface AliasEntry {
|
|
7
|
+
kind: AliasKind;
|
|
8
|
+
target: string;
|
|
9
|
+
}
|
|
10
|
+
export interface BlockScope {
|
|
11
|
+
blockId: string;
|
|
12
|
+
/** 本块 data 段声明或引入的对象名 */
|
|
13
|
+
dataNames: ReadonlySet<string>;
|
|
14
|
+
/** 块作用域别名 */
|
|
15
|
+
aliases: ReadonlyMap<string, AliasEntry>;
|
|
16
|
+
/** 按 HTML 位置可见的行变量(行内组件才有) */
|
|
17
|
+
rowVars: ReadonlySet<string>;
|
|
18
|
+
/** 页面变量固定名 */
|
|
19
|
+
pageVar: string;
|
|
20
|
+
}
|
|
21
|
+
export interface BuildScopeInput {
|
|
22
|
+
blockId: string;
|
|
23
|
+
dataNames?: Iterable<string>;
|
|
24
|
+
aliasRaw?: Record<string, unknown>;
|
|
25
|
+
rowVars?: Iterable<string>;
|
|
26
|
+
}
|
|
27
|
+
export declare function buildBlockScope(input: BuildScopeInput): BlockScope;
|
|
28
|
+
export type ResolvedPath = {
|
|
29
|
+
kind: 'data';
|
|
30
|
+
full: string;
|
|
31
|
+
} | {
|
|
32
|
+
kind: 'row';
|
|
33
|
+
full: string;
|
|
34
|
+
} | {
|
|
35
|
+
kind: 'page';
|
|
36
|
+
full: string;
|
|
37
|
+
} | {
|
|
38
|
+
kind: 'literal';
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* 路径归属裁决 + 全名还原。
|
|
42
|
+
*
|
|
43
|
+
* 返回 `literal` 表示"首段不在任何作用域内"——由调用方按位置决定它是字面量
|
|
44
|
+
* 还是错误(props 值位允许字面量,绑定位不允许)。
|
|
45
|
+
*/
|
|
46
|
+
export declare function resolvePath(raw: string, scope: BlockScope): ResolvedPath;
|
|
47
|
+
/** API 位的别名展开;非别名原样返回(仍须过注册表白名单,那是另一道闸门) */
|
|
48
|
+
export declare function resolveApiRef(raw: string, scope: BlockScope): string;
|
|
49
|
+
/** 供 value-lang 使用的 hasVar:判定首段是否在作用域内 */
|
|
50
|
+
export declare function scopeHasVar(scope: BlockScope): (segment: string) => boolean;
|
|
51
|
+
/** 把值里的路径整体还原为全名(供绑定位写入清单) */
|
|
52
|
+
export declare function expandPath(raw: string, scope: BlockScope): string;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { UiConfig } from '../../../shared/types/ui-config.types';
|
|
2
|
+
import { type BlockScope } from './namespace';
|
|
3
|
+
export interface PageBlockAst {
|
|
4
|
+
/** v1 等价 UiConfig:直接交既有编译管线 */
|
|
5
|
+
ui: UiConfig;
|
|
6
|
+
/** 事件段原文(交 pipeline-parser,形状与 v1 _event.yaml 一致) */
|
|
7
|
+
eventRaw: Record<string, unknown>;
|
|
8
|
+
/** 数据段原文(页面级共享对象,交数据对象层) */
|
|
9
|
+
dataRaw?: Record<string, unknown>;
|
|
10
|
+
scope: BlockScope;
|
|
11
|
+
}
|
|
12
|
+
export interface ParsePageInput {
|
|
13
|
+
body: Record<string, unknown>;
|
|
14
|
+
/** 页面内全部锚点(校验引用完整性用) */
|
|
15
|
+
anchors: ReadonlySet<string>;
|
|
16
|
+
/** 组件实例锚点(出现在 ui 段 = 编译错误,指路组件块) */
|
|
17
|
+
instances: ReadonlySet<string>;
|
|
18
|
+
/** 词典键(locale 批量段校验用;缺省不校验) */
|
|
19
|
+
localeKeys?: ReadonlySet<string>;
|
|
20
|
+
}
|
|
21
|
+
export declare function parsePageBlock(input: ParsePageInput): PageBlockAst;
|