soma-core 2.2.5 → 2.2.7
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 +5 -6
- package/bin/soma.cjs +2 -2
- package/core/build/compiler/flat-page.ts +16 -0
- package/core/build/compiler/full-manifest-builder.ts +0 -3
- package/core/build/compiler/page-assets.ts +0 -1
- package/core/build/compiler/page-closure.ts +245 -0
- package/core/build/compiler/page-declaration-compiler.ts +2 -5
- package/core/build/compiler/soma-precompile.js +1972 -3312
- package/core/build/compiler/soma-precompile.ts +4 -7
- package/core/build/component-tree/artifact-codec.ts +4 -8
- package/core/build/lsp/soma-declaration.cjs +1 -1
- package/core/build/lsp/std-completion.generated.json +3 -3
- package/core/client/a11y/a11y-config.ts +2 -1
- package/core/client/a11y/dom-id.ts +1 -1
- package/core/client/base/SomaHttpClient.ts +11 -3
- package/core/client/base/SomaPageRootBase.ts +6 -0
- package/core/client/base/defineSomaView.ts +178 -0
- package/core/client/base/index.ts +13 -0
- package/core/client/base/view-context.ts +328 -0
- package/core/client/behavior/adapter-collection.ts +2 -2
- package/core/client/compiler/manifest-compiler.ts +5 -36
- package/core/client/component/component-definition.types.ts +2 -1
- package/core/client/component/component-manager.ts +110 -20
- package/core/client/component/structure-adapter.ts +3 -7
- package/core/client/container/IContainerAdapter.ts +4 -0
- package/core/client/container/SomaContainerAdapter.ts +52 -3
- package/core/client/data/data-object-resolver.ts +523 -184
- package/core/client/data/data-write-actions.ts +79 -15
- package/core/client/data/format-config.ts +3 -1
- package/core/client/data/region-scope-port.ts +11 -0
- package/core/client/engine/asset-resolver.ts +2 -5
- package/core/client/engine/dom-renderer.ts +7 -40
- package/core/client/engine/event-engine.ts +29 -108
- package/core/client/engine/property-watcher.ts +1 -1
- package/core/client/engine/reactive-proxy.ts +78 -17
- package/core/client/engine/runtime-builder.ts +0 -14
- package/core/client/engine/scope-resolver.ts +18 -0
- package/core/client/engine/soma-bootstrap.ts +387 -99
- package/core/client/engine/style-binder.ts +49 -106
- package/core/client/engine/timer-engine.ts +11 -1
- package/core/client/host-bridge/load-host-domain-class.ts +2 -1
- package/core/client/infra/http/SomaHttpService.ts +15 -4
- package/core/client/infra/i18n/pack-locales.ts +2 -2
- package/core/client/infra/notify/DefaultNotifyService.ts +2 -2
- package/core/client/mount/domain-rule.ts +7 -3
- package/core/client/mount/mount-page.ts +38 -5
- package/core/client/mount/types.ts +2 -0
- package/core/client/parser/confirm-spec.ts +100 -7
- package/core/client/parser/data-config-parser.ts +28 -211
- package/core/client/parser/pipeline-parser.ts +16 -60
- package/core/client/parser/style-config-parser.ts +101 -95
- package/core/client/parser/timer-parser.ts +21 -0
- package/core/client/parser/ui-config-parser.ts +64 -12
- package/core/client/registry/declaration-renderer.ts +1 -1
- package/core/client/render-ports/hide-transition.ts +9 -0
- package/core/client/render-ports/index.ts +4 -0
- package/core/client/render-ports/notify-renderer.ts +2 -1
- package/core/client/runtime/SomaRuntimeServices.ts +2 -1
- package/core/client/runtime/SomaSnapshotStore.ts +5 -0
- package/core/client/security/url-guard.ts +71 -11
- package/core/client/validation/async-check-registry.ts +2 -1
- package/core/client/validation/contract-validator.ts +2 -6
- package/core/client/validation/field-rules.ts +3 -13
- package/core/client/validation/object-rules.ts +2 -10
- package/core/index.ts +17 -39
- package/core/inspect/check-product.ts +5 -5
- package/core/inspect/runtime.ts +2 -1
- package/core/server/api/dispatch-service-api.ts +35 -36
- package/core/server/api/load-host-service.ts +8 -4
- package/core/server/api/paged-list.ts +259 -0
- package/core/server/compile-port.ts +1 -1
- package/core/server/host/app-config-composer.ts +2 -1
- package/core/server/host/empty-host-bootstrap.mjs +3 -0
- package/core/server/host/host-assembly-entry.ts +1 -0
- package/core/server/host/host-assembly.ts +50 -3
- package/core/server/host/host-caller.ts +2 -1
- package/core/server/host/host-dir.ts +9 -0
- package/core/server/host/host-response-headers.ts +2 -1
- package/core/server/host/invoke-host-request-hook.ts +28 -4
- package/core/server/host/published-page-assets.ts +2 -1
- package/core/server/host/resolve-host-request-hook.ts +25 -7
- package/core/server/host/server-page-assets.ts +4 -4
- package/core/server/host/source-aliases.cjs +345 -0
- package/core/server/host/source-aliases.ts +32 -0
- package/core/server/host/source-packages.cjs +1 -0
- package/core/server/host/virtual-pages.ts +3 -2
- package/core/server/infra/cache/ServerFileCache.ts +83 -10
- package/core/server/node.ts +10 -0
- package/core/server/registry/api-registry-store.ts +3 -1
- package/core/server/registry/declaration-precompiler.ts +0 -2
- package/core/server/registry/page-registry-repository.ts +2 -1
- package/core/server/registry/page-registry-store.ts +2 -1
- package/core/server/registry/registry-error.ts +6 -1
- package/core/server/registry/registry-file-lock.ts +296 -23
- package/core/server/registry/request-body-limit.ts +3 -2
- package/core/server/registry/validation/declaration-safety-scan.ts +151 -27
- package/core/server/runtime-space/access-gate.ts +21 -7
- package/core/server/runtime-space/bindings.ts +3 -6
- package/core/server/runtime-space/dynamic-pages.ts +181 -49
- package/core/server/runtime-space/errors.ts +3 -0
- package/core/server/runtime-space/inject.ts +78 -16
- package/core/server/runtime-space/page-grants.ts +7 -1
- package/core/server/runtime-space/resolve.ts +66 -19
- package/core/server/runtime-space/store.ts +32 -3
- package/core/server/runtime-space/submit-steps.ts +2 -1
- package/core/server/runtime-space/types.ts +3 -1
- package/core/shared/component-tree-errors.ts +2 -1
- package/core/shared/contract-a11y.ts +1 -1
- package/core/shared/contract-sections.ts +2 -2
- package/core/shared/core-diagnostic-codes.ts +14 -0
- package/core/shared/data-declaration-checks.ts +29 -3
- package/core/shared/declaration-keys.ts +1 -1
- package/core/shared/engines/engine-error.ts +2 -1
- package/core/shared/generation-error.ts +2 -1
- package/core/shared/page-envelope.ts +1 -1
- package/core/shared/pure-binding.ts +88 -0
- package/core/shared/registry-generated/diagnostic-registry-index.ts +21 -19
- package/core/shared/registry-generated/diagnostic-registry.ts +170 -177
- package/core/shared/registry-generated/limits.ts +65 -13
- package/core/shared/registry-generated/std-grammar-completion.ts +0 -4
- package/core/shared/registry-generated/std-grammar-views.ts +40 -10
- package/core/shared/registry-generated/std-grammar.ts +43 -21
- package/core/shared/soma-error.ts +36 -0
- package/core/shared/types/compile-port.types.ts +1 -1
- package/core/shared/types/data-config.types.ts +20 -18
- package/core/shared/types/engine.types.ts +0 -3
- package/core/shared/types/event.types.ts +10 -11
- package/core/shared/types/generation-error.types.ts +5 -1
- package/core/shared/types/host-assembly.types.ts +7 -1
- package/core/shared/types/manifest.types.ts +0 -3
- package/core/shared/types/region-scope.types.ts +5 -1
- package/core/shared/types/scope-manifest.types.ts +0 -2
- package/core/shared/types/style-config.types.ts +21 -21
- package/core/shared/types/ui-config.types.ts +4 -5
- package/core/shared/types/watcher.types.ts +1 -1
- package/dist/browser/runtime-bundle.manifest.json +11 -13
- package/dist/browser/soma-runtime.js +2733 -2712
- package/dist/core/index.cjs +5665 -5534
- package/dist/host-native/aot-builder.cjs +330 -1
- package/dist/host-native/native-server.cjs +5434 -4726
- package/dist/lsp/component-tree.cjs +5868 -7040
- package/dist/types/build/compiler/full-manifest-builder.d.ts +0 -2
- package/dist/types/build/compiler/page-closure.d.ts +21 -0
- package/dist/types/build/compiler/page-declaration-compiler.d.ts +2 -4
- package/dist/types/build/compiler/soma-precompile.d.ts +1 -3
- package/dist/types/build/component-tree/artifact-codec.d.ts +0 -2
- package/dist/types/client/a11y/a11y-config.d.ts +2 -1
- package/dist/types/client/base/SomaHttpClient.d.ts +1 -1
- package/dist/types/client/base/SomaPageRootBase.d.ts +5 -0
- package/dist/types/client/base/defineSomaView.d.ts +46 -0
- package/dist/types/client/base/index.d.ts +2 -0
- package/dist/types/client/base/view-context.d.ts +136 -0
- package/dist/types/client/behavior/adapter-collection.d.ts +1 -1
- package/dist/types/client/compiler/manifest-compiler.d.ts +0 -3
- package/dist/types/client/component/component-definition.types.d.ts +2 -1
- package/dist/types/client/component/component-manager.d.ts +29 -0
- package/dist/types/client/container/IContainerAdapter.d.ts +3 -0
- package/dist/types/client/container/SomaContainerAdapter.d.ts +5 -0
- package/dist/types/client/data/data-object-resolver.d.ts +93 -31
- package/dist/types/client/data/format-config.d.ts +2 -1
- package/dist/types/client/engine/dom-renderer.d.ts +1 -2
- package/dist/types/client/engine/event-engine.d.ts +0 -7
- package/dist/types/client/engine/reactive-proxy.d.ts +11 -4
- package/dist/types/client/engine/runtime-builder.d.ts +0 -4
- package/dist/types/client/engine/soma-bootstrap.d.ts +44 -6
- package/dist/types/client/engine/style-binder.d.ts +8 -4
- package/dist/types/client/host-bridge/load-host-domain-class.d.ts +2 -1
- package/dist/types/client/mount/domain-rule.d.ts +2 -0
- package/dist/types/client/mount/mount-page.d.ts +2 -1
- package/dist/types/client/mount/types.d.ts +2 -0
- package/dist/types/client/parser/confirm-spec.d.ts +27 -3
- package/dist/types/client/parser/data-config-parser.d.ts +6 -5
- package/dist/types/client/parser/style-config-parser.d.ts +7 -3
- package/dist/types/client/parser/timer-parser.d.ts +5 -0
- package/dist/types/client/parser/ui-config-parser.d.ts +6 -2
- package/dist/types/client/render-ports/hide-transition.d.ts +9 -0
- package/dist/types/client/render-ports/index.d.ts +4 -0
- package/dist/types/client/render-ports/notify-renderer.d.ts +2 -1
- package/dist/types/client/runtime/SomaSnapshotStore.d.ts +2 -0
- package/dist/types/client/security/url-guard.d.ts +14 -0
- package/dist/types/client/validation/async-check-registry.d.ts +2 -1
- package/dist/types/client/validation/object-rules.d.ts +0 -5
- package/dist/types/index.d.ts +6 -11
- package/dist/types/inspect/runtime.d.ts +2 -1
- package/dist/types/server/api/dispatch-service-api.d.ts +5 -0
- package/dist/types/server/api/load-host-service.d.ts +1 -1
- package/dist/types/server/api/paged-list.d.ts +101 -0
- package/dist/types/server/compile-port.d.ts +1 -1
- package/dist/types/server/host/host-assembly-entry.d.ts +1 -1
- package/dist/types/server/host/host-assembly.d.ts +2 -0
- package/dist/types/server/host/host-dir.d.ts +2 -0
- package/dist/types/server/host/invoke-host-request-hook.d.ts +10 -3
- package/dist/types/server/host/published-page-assets.d.ts +2 -1
- package/dist/types/server/host/resolve-host-request-hook.d.ts +18 -5
- package/dist/types/server/host/server-page-assets.d.ts +2 -1
- package/dist/types/server/host/source-aliases.d.cts +53 -0
- package/dist/types/server/host/source-aliases.d.ts +30 -0
- package/dist/types/server/host/source-packages.d.cts +2 -0
- package/dist/types/server/infra/cache/ServerFileCache.d.ts +8 -0
- package/dist/types/server/node.d.ts +1 -0
- package/dist/types/server/registry/declaration-precompiler.d.ts +0 -1
- package/dist/types/server/registry/registry-error.d.ts +5 -1
- package/dist/types/server/registry/registry-file-lock.d.ts +30 -0
- package/dist/types/server/registry/request-body-limit.d.ts +3 -2
- package/dist/types/server/registry/validation/declaration-safety-scan.d.ts +3 -0
- package/dist/types/server/runtime-space/access-gate.d.ts +7 -0
- package/dist/types/server/runtime-space/bindings.d.ts +3 -2
- package/dist/types/server/runtime-space/dynamic-pages.d.ts +6 -1
- package/dist/types/server/runtime-space/errors.d.ts +1 -1
- package/dist/types/server/runtime-space/resolve.d.ts +2 -0
- package/dist/types/server/runtime-space/store.d.ts +8 -1
- package/dist/types/server/runtime-space/submit-steps.d.ts +2 -1
- package/dist/types/server/runtime-space/types.d.ts +3 -1
- package/dist/types/shared/component-tree-errors.d.ts +2 -1
- package/dist/types/shared/core-diagnostic-codes.d.ts +1 -1
- package/dist/types/shared/declaration-keys.d.ts +1 -1
- package/dist/types/shared/engines/engine-error.d.ts +2 -1
- package/dist/types/shared/generation-error.d.ts +2 -1
- package/dist/types/shared/pure-binding.d.ts +48 -0
- package/dist/types/shared/registry-generated/diagnostic-registry.d.ts +149 -158
- package/dist/types/shared/registry-generated/limits.d.ts +54 -10
- package/dist/types/shared/registry-generated/std-grammar-completion.d.ts +0 -30
- package/dist/types/shared/registry-generated/std-grammar-views.d.ts +97 -23
- package/dist/types/shared/registry-generated/std-grammar.d.ts +110 -242
- package/dist/types/shared/soma-error.d.ts +15 -0
- package/dist/types/shared/types/data-config.types.d.ts +17 -17
- package/dist/types/shared/types/engine.types.d.ts +0 -3
- package/dist/types/shared/types/event.types.d.ts +9 -7
- package/dist/types/shared/types/generation-error.types.d.ts +1 -1
- package/dist/types/shared/types/host-assembly.types.d.ts +2 -0
- package/dist/types/shared/types/manifest.types.d.ts +0 -3
- package/dist/types/shared/types/region-scope.types.d.ts +4 -1
- package/dist/types/shared/types/scope-manifest.types.d.ts +0 -2
- package/dist/types/shared/types/style-config.types.d.ts +17 -19
- package/dist/types/shared/types/ui-config.types.d.ts +4 -5
- package/host-native/bin/host-native.cjs +22 -1
- package/host-native/client/browser-entry.ts +21 -172
- package/host-native/src/aot-builder.ts +75 -0
- package/host-native/src/host-prepare.ts +39 -5
- package/host-native/src/manifest-http.ts +2 -3
- package/host-native/src/native-server.ts +812 -174
- package/host-native/src/page-http.ts +3 -3
- package/host-native/src/public-packages.cjs +0 -1
- package/host-native/src/registry-handler.ts +12 -5
- package/host-native/src/static-file.ts +203 -53
- package/host-native/styles/globals.css +30 -28
- package/package.json +14 -2
- package/core/client/engine/step-runner.ts +0 -212
- package/core/client/engine/trigger-engine.ts +0 -55
- package/core/client/format/zoned.ts +0 -10
- package/core/client/parser/step-parser.ts +0 -359
- package/core/client/parser/trigger-parser.ts +0 -90
- package/core/client/parser/value-lang.ts +0 -340
- package/core/client/time/instant.ts +0 -2
- package/core/shared/calc/coerce.ts +0 -2
- package/core/shared/calc/errors.ts +0 -40
- package/core/shared/calc/evaluator.ts +0 -113
- package/core/shared/calc/index.ts +0 -11
- package/core/shared/calc/lexer.ts +0 -189
- package/core/shared/calc/parser.ts +0 -193
- package/core/shared/calc/typer.ts +0 -171
- package/core/shared/date-parts.ts +0 -2
- package/core/shared/show-when.ts +0 -77
- package/core/shared/types/step.types.ts +0 -91
- package/core/shared/types/trigger.types.ts +0 -14
- package/dist/types/client/engine/step-runner.d.ts +0 -42
- package/dist/types/client/engine/trigger-engine.d.ts +0 -16
- package/dist/types/client/format/zoned.d.ts +0 -1
- package/dist/types/client/parser/step-parser.d.ts +0 -23
- package/dist/types/client/parser/trigger-parser.d.ts +0 -13
- package/dist/types/client/parser/value-lang.d.ts +0 -63
- package/dist/types/client/time/instant.d.ts +0 -1
- package/dist/types/shared/calc/coerce.d.ts +0 -1
- package/dist/types/shared/calc/errors.d.ts +0 -14
- package/dist/types/shared/calc/evaluator.d.ts +0 -2
- package/dist/types/shared/calc/index.d.ts +0 -6
- package/dist/types/shared/calc/lexer.d.ts +0 -19
- package/dist/types/shared/calc/parser.d.ts +0 -43
- package/dist/types/shared/calc/typer.d.ts +0 -11
- package/dist/types/shared/date-parts.d.ts +0 -1
- package/dist/types/shared/show-when.d.ts +0 -21
- package/dist/types/shared/types/step.types.d.ts +0 -76
- package/dist/types/shared/types/trigger.types.d.ts +0 -12
|
@@ -1,24 +1,38 @@
|
|
|
1
1
|
// core/client/parser/style-config-parser.ts — SOMA 样式配置解析器
|
|
2
2
|
// 负责将 _style.yaml 解析后的原始对象转换为类型安全的 StyleConfig 结构
|
|
3
3
|
|
|
4
|
+
import { SomaError } from '../../shared/soma-error';
|
|
4
5
|
import type {
|
|
5
6
|
SomaStyleViolationKind,
|
|
6
7
|
StyleConfig,
|
|
7
|
-
|
|
8
|
+
StyleTierBinding,
|
|
8
9
|
StyleTransition,
|
|
9
10
|
TransitionTrigger,
|
|
10
11
|
} from '../../shared/types/style-config.types';
|
|
12
|
+
import {
|
|
13
|
+
SOMA_STYLE_COMPARE_KEYS,
|
|
14
|
+
SOMA_STYLE_COMPARE_REMEDY,
|
|
15
|
+
SOMA_STYLE_TIER_KEYS,
|
|
16
|
+
SOMA_STYLE_TIER_MAX,
|
|
17
|
+
SOMA_STYLE_TIER_NAME_PATTERN,
|
|
18
|
+
isPureBindPath,
|
|
19
|
+
isTierName,
|
|
20
|
+
type SomaPureBindingCode,
|
|
21
|
+
} from '../../shared/pure-binding';
|
|
11
22
|
|
|
12
23
|
// ─── 错误类 ───────────────────────────────────────────────────────────────────
|
|
13
24
|
|
|
14
|
-
export class SomaStyleConfigError extends
|
|
25
|
+
export class SomaStyleConfigError extends SomaError {
|
|
15
26
|
public readonly path: string;
|
|
16
27
|
/** 违规类别;仅结构化校验失败时缺省(那类失败没有"类别"可言) */
|
|
17
28
|
public readonly kind?: SomaStyleViolationKind;
|
|
29
|
+
/** 纯绑定违规码(样式比较形);其余解析错误无码 */
|
|
30
|
+
public readonly code?: SomaPureBindingCode;
|
|
18
31
|
|
|
19
|
-
constructor(message: string, path: string = '', kind?: SomaStyleViolationKind) {
|
|
32
|
+
constructor(message: string, path: string = '', kind?: SomaStyleViolationKind, code?: SomaPureBindingCode) {
|
|
20
33
|
const prefix = path ? ` (路径: ${path})` : '';
|
|
21
|
-
super(`[SOMA StyleConfigParser] ${message}${prefix}`);
|
|
34
|
+
super(`[SOMA StyleConfigParser] ${code ? `[${code}] ` : ''}${message}${prefix}`);
|
|
35
|
+
this.code = code;
|
|
22
36
|
this.name = 'SomaStyleConfigError';
|
|
23
37
|
this.path = path;
|
|
24
38
|
this.kind = kind;
|
|
@@ -86,20 +100,24 @@ function assertNoLayoutClasses(
|
|
|
86
100
|
}
|
|
87
101
|
}
|
|
88
102
|
|
|
89
|
-
// ───
|
|
103
|
+
// ─── 键闭集(宽进改严:闭集外的键一律报错,不静默忽略) ─────────────────────────
|
|
90
104
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
// 纯属性路径:仅允许 字母/数字/下划线 + 点分隔
|
|
94
|
-
return /^[a-zA-Z_]\w*(\.[a-zA-Z_]\w*)*$/.test(path);
|
|
95
|
-
}
|
|
105
|
+
const STYLE_TOP_KEYS = new Set(['host', 'base', 'states', 'transitions', 'themes']);
|
|
106
|
+
const TRANSITION_KEYS = new Set(['trigger', 'apply']);
|
|
96
107
|
|
|
97
|
-
function
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
108
|
+
function assertClosedKeys(obj: Record<string, unknown>, allowed: ReadonlySet<string>, what: string, path: string): void {
|
|
109
|
+
for (const key of Object.keys(obj)) {
|
|
110
|
+
if (!allowed.has(key)) {
|
|
111
|
+
throw new SomaStyleConfigError(
|
|
112
|
+
`${what}有未知键 "${key}"(支持: ${[...allowed].join(' / ')});样式只做视觉翻译,条件求值与逻辑归展示对象 / 业务对象`,
|
|
113
|
+
path ? `${path}.${key}` : key,
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
101
117
|
}
|
|
102
118
|
|
|
119
|
+
// ─── 内部校验函数 ─────────────────────────────────────────────────────────────
|
|
120
|
+
|
|
103
121
|
function validateSomaId(somaId: string, path: string): void {
|
|
104
122
|
if (!somaId || typeof somaId !== 'string') {
|
|
105
123
|
throw new SomaStyleConfigError(`data-soma-id 不能为空`, path);
|
|
@@ -129,74 +147,79 @@ function parseBase(raw: unknown, path: string): Record<string, string> {
|
|
|
129
147
|
return result;
|
|
130
148
|
}
|
|
131
149
|
|
|
132
|
-
// ─── states
|
|
150
|
+
// ─── 类名档位绑定(states / active_state 共用) ────────────────────────────────
|
|
133
151
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
152
|
+
/**
|
|
153
|
+
* 解析 `{ bind, tiers }`:bind 是展示对象成员的纯路径,tiers 是 档位名 → 类名串 的闭集映射。
|
|
154
|
+
* 旧的 `condition` + `value` 比较形一律拒收(CORE-STYLE-COMPARE-FORBIDDEN),不留兼容。
|
|
155
|
+
*/
|
|
156
|
+
function parseTierBinding(obj: Record<string, unknown>, path: string, extraKeys: readonly string[]): StyleTierBinding {
|
|
157
|
+
for (const key of Object.keys(obj)) {
|
|
158
|
+
if (SOMA_STYLE_COMPARE_KEYS.has(key)) {
|
|
159
|
+
throw new SomaStyleConfigError(
|
|
160
|
+
`样式不做比较:不再支持 "${key}"(原「condition 路径 == value 时加类」形态已删除);${SOMA_STYLE_COMPARE_REMEDY}`,
|
|
161
|
+
`${path}.${key}`,
|
|
162
|
+
undefined,
|
|
163
|
+
'CORE-STYLE-COMPARE-FORBIDDEN',
|
|
164
|
+
);
|
|
165
|
+
}
|
|
137
166
|
}
|
|
167
|
+
assertClosedKeys(obj, new Set([...SOMA_STYLE_TIER_KEYS, ...extraKeys]), '类名档位绑定', path);
|
|
138
168
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
// condition
|
|
142
|
-
if (!obj.condition || typeof obj.condition !== 'string') {
|
|
169
|
+
if (!isPureBindPath(obj.bind)) {
|
|
143
170
|
throw new SomaStyleConfigError(
|
|
144
|
-
`
|
|
145
|
-
path
|
|
171
|
+
`bind 必须是展示对象成员的纯路径(如 "page.statusTier"),禁止取反 / 管道 / 运算符,当前值: ${JSON.stringify(obj.bind)}`,
|
|
172
|
+
`${path}.bind`,
|
|
146
173
|
);
|
|
147
174
|
}
|
|
148
|
-
if (!
|
|
149
|
-
throw new SomaStyleConfigError(
|
|
150
|
-
`condition 必须是纯属性路径(如 "a.b.c"),禁止包含运算符,当前值: "${obj.condition}"`,
|
|
151
|
-
path,
|
|
152
|
-
);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
// value
|
|
156
|
-
if (!('value' in obj)) {
|
|
157
|
-
throw new SomaStyleConfigError(`缺少必填字段 value`, path);
|
|
175
|
+
if (!obj.tiers || typeof obj.tiers !== 'object' || Array.isArray(obj.tiers)) {
|
|
176
|
+
throw new SomaStyleConfigError(`tiers 必须是对象(档位名 → 类名串)`, `${path}.tiers`);
|
|
158
177
|
}
|
|
159
|
-
|
|
178
|
+
const entries = Object.entries(obj.tiers as Record<string, unknown>);
|
|
179
|
+
if (entries.length === 0 || entries.length > SOMA_STYLE_TIER_MAX) {
|
|
160
180
|
throw new SomaStyleConfigError(
|
|
161
|
-
`
|
|
162
|
-
path
|
|
181
|
+
`tiers 的档位数必须在 1 ~ ${SOMA_STYLE_TIER_MAX} 之间,当前 ${entries.length}`,
|
|
182
|
+
`${path}.tiers`,
|
|
163
183
|
);
|
|
164
184
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
185
|
+
const tiers: Record<string, string> = {};
|
|
186
|
+
for (const [tier, classes] of entries) {
|
|
187
|
+
if (!isTierName(tier)) {
|
|
188
|
+
throw new SomaStyleConfigError(
|
|
189
|
+
`档位名 "${tier}" 不合闭集形态(${SOMA_STYLE_TIER_NAME_PATTERN})`,
|
|
190
|
+
`${path}.tiers.${tier}`,
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
if (typeof classes !== 'string' || !classes.trim()) {
|
|
194
|
+
throw new SomaStyleConfigError(
|
|
195
|
+
`档位 "${tier}" 的值必须是非空 CSS 类名字符串,当前值: ${JSON.stringify(classes)}`,
|
|
196
|
+
`${path}.tiers.${tier}`,
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
assertNoLayoutClasses(classes, `${path}.tiers.${tier}`, true);
|
|
200
|
+
tiers[tier] = classes;
|
|
172
201
|
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
return {
|
|
176
|
-
condition: obj.condition,
|
|
177
|
-
value: obj.value as string | number | boolean | null,
|
|
178
|
-
apply: obj.apply,
|
|
179
|
-
};
|
|
202
|
+
return { bind: obj.bind, tiers };
|
|
180
203
|
}
|
|
181
204
|
|
|
182
|
-
|
|
205
|
+
// ─── states 解析 ──────────────────────────────────────────────────────────────
|
|
206
|
+
|
|
207
|
+
function parseStates(raw: unknown, path: string): Record<string, StyleTierBinding> {
|
|
183
208
|
if (!raw) return {};
|
|
184
209
|
if (typeof raw !== 'object' || Array.isArray(raw)) {
|
|
185
|
-
throw new SomaStyleConfigError(`states 必须是对象(somaId →
|
|
210
|
+
throw new SomaStyleConfigError(`states 必须是对象(somaId → { bind, tiers })`, path);
|
|
186
211
|
}
|
|
187
212
|
|
|
188
|
-
const result: Record<string,
|
|
189
|
-
for (const [somaId,
|
|
213
|
+
const result: Record<string, StyleTierBinding> = {};
|
|
214
|
+
for (const [somaId, binding] of Object.entries(raw as Record<string, unknown>)) {
|
|
190
215
|
validateSomaId(somaId, `${path}.${somaId}`);
|
|
191
|
-
if (!Array.isArray(
|
|
216
|
+
if (!binding || typeof binding !== 'object' || Array.isArray(binding)) {
|
|
192
217
|
throw new SomaStyleConfigError(
|
|
193
|
-
`states.${somaId}
|
|
218
|
+
`states.${somaId} 的值必须是 { bind, tiers } 对象(原规则数组形态已删除)`,
|
|
194
219
|
`${path}.${somaId}`,
|
|
195
220
|
);
|
|
196
221
|
}
|
|
197
|
-
result[somaId] =
|
|
198
|
-
parseStateRule(rule, `${path}.${somaId}[${idx}]`),
|
|
199
|
-
);
|
|
222
|
+
result[somaId] = parseTierBinding(binding as Record<string, unknown>, `${path}.${somaId}`, []);
|
|
200
223
|
}
|
|
201
224
|
return result;
|
|
202
225
|
}
|
|
@@ -224,6 +247,20 @@ function parseTransition(raw: unknown, somaId: string, path: string): StyleTrans
|
|
|
224
247
|
);
|
|
225
248
|
}
|
|
226
249
|
|
|
250
|
+
// active_state:纯绑定(bind + tiers),不再有 apply / condition / value
|
|
251
|
+
if (obj.trigger === 'active_state') {
|
|
252
|
+
const { trigger: _trigger, ...rest } = obj;
|
|
253
|
+
if ('apply' in rest && !Object.keys(rest).some((key) => SOMA_STYLE_COMPARE_KEYS.has(key))) {
|
|
254
|
+
throw new SomaStyleConfigError(
|
|
255
|
+
`active_state 用 tiers 给出各档位类名,不再有 apply;${SOMA_STYLE_COMPARE_REMEDY}`,
|
|
256
|
+
`${path}.apply`,
|
|
257
|
+
);
|
|
258
|
+
}
|
|
259
|
+
return { trigger: 'active_state', ...parseTierBinding(rest, path, []) };
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
assertClosedKeys(obj, TRANSITION_KEYS, '过渡配置', path);
|
|
263
|
+
|
|
227
264
|
// apply
|
|
228
265
|
if (!obj.apply || typeof obj.apply !== 'string') {
|
|
229
266
|
throw new SomaStyleConfigError(
|
|
@@ -233,42 +270,10 @@ function parseTransition(raw: unknown, somaId: string, path: string): StyleTrans
|
|
|
233
270
|
}
|
|
234
271
|
assertNoLayoutClasses(obj.apply, `${path}.apply`, true);
|
|
235
272
|
|
|
236
|
-
|
|
237
|
-
trigger: obj.trigger as TransitionTrigger,
|
|
273
|
+
return {
|
|
274
|
+
trigger: obj.trigger as Exclude<TransitionTrigger, 'active_state'>,
|
|
238
275
|
apply: obj.apply,
|
|
239
276
|
};
|
|
240
|
-
|
|
241
|
-
// active_state 专有字段
|
|
242
|
-
if (obj.trigger === 'active_state') {
|
|
243
|
-
if (!obj.condition || typeof obj.condition !== 'string') {
|
|
244
|
-
throw new SomaStyleConfigError(
|
|
245
|
-
`active_state 类型的 trigger 必须提供 condition 字段`,
|
|
246
|
-
path,
|
|
247
|
-
);
|
|
248
|
-
}
|
|
249
|
-
if (!isValidConditionPath(obj.condition)) {
|
|
250
|
-
throw new SomaStyleConfigError(
|
|
251
|
-
`condition 必须是纯属性路径,当前值: "${obj.condition}"`,
|
|
252
|
-
path,
|
|
253
|
-
);
|
|
254
|
-
}
|
|
255
|
-
if (!('value' in obj)) {
|
|
256
|
-
throw new SomaStyleConfigError(
|
|
257
|
-
`active_state 类型的 trigger 必须提供 value 字段`,
|
|
258
|
-
path,
|
|
259
|
-
);
|
|
260
|
-
}
|
|
261
|
-
if (!isPrimitiveValue(obj.value)) {
|
|
262
|
-
throw new SomaStyleConfigError(
|
|
263
|
-
`value 必须是基础类型,当前值: ${JSON.stringify(obj.value)}`,
|
|
264
|
-
path,
|
|
265
|
-
);
|
|
266
|
-
}
|
|
267
|
-
result.condition = obj.condition;
|
|
268
|
-
result.value = obj.value as string | number | boolean | null;
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
return result;
|
|
272
277
|
}
|
|
273
278
|
|
|
274
279
|
function parseTransitions(raw: unknown, path: string): Record<string, StyleTransition> {
|
|
@@ -293,7 +298,7 @@ function parseTransitions(raw: unknown, path: string): Record<string, StyleTrans
|
|
|
293
298
|
* 校验规则:
|
|
294
299
|
* - host 必须是非空字符串
|
|
295
300
|
* - base 的值必须是纯 CSS 类名字符串;core 不解析也不编译具体类名
|
|
296
|
-
* - states
|
|
301
|
+
* - states / transitions.active_state 是纯绑定:`bind` 纯路径 + `tiers` 档位闭集(成员的值就是档位名),不再有 condition / value 比较
|
|
297
302
|
* - transitions 的 trigger 必须是有效枚举值
|
|
298
303
|
* - base 命中布局类模式即失败;states / transitions 放行显隐对(F-06)
|
|
299
304
|
* - themes 段已退役(主题是编译期事,T19):写了内容就明确拒收,不静默丢弃(空表等于没写)
|
|
@@ -308,6 +313,7 @@ export function parseStyleConfig(raw: unknown): StyleConfig {
|
|
|
308
313
|
}
|
|
309
314
|
|
|
310
315
|
const obj = raw as Record<string, unknown>;
|
|
316
|
+
assertClosedKeys(obj, STYLE_TOP_KEYS, '样式配置', '');
|
|
311
317
|
|
|
312
318
|
// host
|
|
313
319
|
if (!obj.host || typeof obj.host !== 'string') {
|
|
@@ -16,6 +16,11 @@ function parseTimerItem(raw: unknown, index: number): ParsedTimer {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
const item = raw as Record<string, unknown>;
|
|
19
|
+
for (const key of Object.keys(item)) {
|
|
20
|
+
if (!['id', 'tick', 'interval', 'delay', 'once'].includes(key)) {
|
|
21
|
+
throw new SomaTimerParseError(`timers[${index}] 有未知键 "${key}"(支持: id / tick / interval / delay / once);定时器只触发管道,条件判断归 Domain`);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
19
24
|
|
|
20
25
|
if (typeof item.id !== 'string' || !item.id.trim()) {
|
|
21
26
|
throw new SomaTimerParseError(`timers[${index}].id 必须是非空字符串`);
|
|
@@ -68,3 +73,19 @@ export function compileTimer(timer: ParsedTimer): import('../../shared/types/tim
|
|
|
68
73
|
eventKey: `tick:${somaId}`,
|
|
69
74
|
};
|
|
70
75
|
}
|
|
76
|
+
|
|
77
|
+
/** 从 event 配置根对象分离 timers 与事件声明(`triggers` 已删除:它不再是保留键,写了按事件声明形态报错) */
|
|
78
|
+
export function splitEventConfigRaw(raw: unknown): {
|
|
79
|
+
eventsRaw: Record<string, unknown>;
|
|
80
|
+
timers: ParsedTimer[];
|
|
81
|
+
} {
|
|
82
|
+
if (!raw || typeof raw !== 'object' || Array.isArray(raw)) {
|
|
83
|
+
return { eventsRaw: {}, timers: [] };
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const { timers: timersRaw, ...eventsRaw } = raw as Record<string, unknown>;
|
|
87
|
+
return {
|
|
88
|
+
eventsRaw,
|
|
89
|
+
timers: parseTimers(timersRaw),
|
|
90
|
+
};
|
|
91
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// core/client/parser/ui-config-parser.ts — SOMA UI 配置解析器
|
|
2
2
|
// 负责将 YAML 解析后的原始对象转换为类型安全的 UiConfig 结构
|
|
3
3
|
|
|
4
|
+
import { SomaError } from '../../shared/soma-error';
|
|
4
5
|
import type {
|
|
5
6
|
UiConfig,
|
|
6
7
|
ShowMapping,
|
|
@@ -12,7 +13,6 @@ import type {
|
|
|
12
13
|
} from '../../shared/types/ui-config.types';
|
|
13
14
|
import { SOMA_FRAGMENTS_FORMAT } from '../../shared/types/ui-config.types';
|
|
14
15
|
import { SOMA_FRAGMENTS_KEY } from '../../shared/fragments-section';
|
|
15
|
-
import { inspectShowWhen, isShowWhenObject, type SomaShowWhen } from '../../shared/show-when';
|
|
16
16
|
import type { OnChangeRule } from '../../shared/types/watcher.types';
|
|
17
17
|
import type { SomaScopeDecl, SomaScopeGateDecl, SomaScopeMirrorDecl, SomaScopeSliceDecl } from '../../shared/types/region-scope.types';
|
|
18
18
|
import { formatScopeIssues, validateScopeDecls } from '../../shared/region-scope-decl';
|
|
@@ -22,6 +22,14 @@ import {
|
|
|
22
22
|
scopesConflictMessage,
|
|
23
23
|
} from '../../shared/page-scopes';
|
|
24
24
|
import { parsePageState } from './page-state-parser';
|
|
25
|
+
import {
|
|
26
|
+
findNegatedPathIn,
|
|
27
|
+
hasNegationPrefix,
|
|
28
|
+
isPureRolePath,
|
|
29
|
+
negationMessage,
|
|
30
|
+
roleByMessage,
|
|
31
|
+
type SomaPureBindingCode,
|
|
32
|
+
} from '../../shared/pure-binding';
|
|
25
33
|
|
|
26
34
|
// ─── 错误类 ───────────────────────────────────────────────────────────────────
|
|
27
35
|
|
|
@@ -29,14 +37,17 @@ import { parsePageState } from './page-state-parser';
|
|
|
29
37
|
* UI 配置解析错误
|
|
30
38
|
* 携带错误路径信息以便定位问题
|
|
31
39
|
*/
|
|
32
|
-
export class SomaUiConfigError extends
|
|
40
|
+
export class SomaUiConfigError extends SomaError {
|
|
33
41
|
public readonly path: string;
|
|
42
|
+
/** 纯绑定违规码(取反 / role_by 非纯路径);其余解析错误无码 */
|
|
43
|
+
public readonly code?: SomaPureBindingCode;
|
|
34
44
|
|
|
35
|
-
constructor(message: string, path: string = '') {
|
|
45
|
+
constructor(message: string, path: string = '', code?: SomaPureBindingCode) {
|
|
36
46
|
const prefix = path ? ` (路径: ${path})` : '';
|
|
37
|
-
super(`[SOMA UiConfigParser] ${message}${prefix}`);
|
|
47
|
+
super(`[SOMA UiConfigParser] ${code ? `[${code}] ` : ''}${message}${prefix}`);
|
|
38
48
|
this.name = 'SomaUiConfigError';
|
|
39
49
|
this.path = path;
|
|
50
|
+
this.code = code;
|
|
40
51
|
}
|
|
41
52
|
}
|
|
42
53
|
|
|
@@ -61,10 +72,28 @@ export interface SomaUiConfigParseOptions {
|
|
|
61
72
|
* @param path - 当前路径(用于错误信息)
|
|
62
73
|
* @throws SomaUiConfigError 校验失败时抛出
|
|
63
74
|
*/
|
|
75
|
+
/** 键闭集:闭集外的键一律报错(页面只做视觉与纯绑定,逻辑写法不会被静默忽略) */
|
|
76
|
+
function assertClosedUiKeys(obj: object, allowed: readonly string[], what: string, path: string): void {
|
|
77
|
+
for (const key of Object.keys(obj)) {
|
|
78
|
+
if (!allowed.includes(key)) {
|
|
79
|
+
throw new SomaUiConfigError(
|
|
80
|
+
`${what}有未知键 "${key}"(支持: ${allowed.join(' / ')});页面不求值、不判断、不派生,逻辑归展示对象 / 业务对象`,
|
|
81
|
+
`${path}.${key}`,
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const BIND_KEYS = ['obj', 'var', 'onChange', 'role_by', 'key', 'repeatPlanId', 'collectionSlot'] as const;
|
|
88
|
+
const ONCHANGE_KEYS = ['condition', 'callback', 'refresh', 'debounce'] as const;
|
|
89
|
+
const NESTED_SHOW_KEYS = ['bind', 'show', 'props', 'when'] as const;
|
|
90
|
+
const EXTENDED_SHOW_KEYS = ['text', 'model', 'when', 'class', 'show', 'props'] as const;
|
|
91
|
+
|
|
64
92
|
function validateBind(bind: any, path: string): asserts bind is BindDeclaration {
|
|
65
93
|
if (!bind || typeof bind !== 'object') {
|
|
66
94
|
throw new SomaUiConfigError(`bind 必须是对象`, path);
|
|
67
95
|
}
|
|
96
|
+
assertClosedUiKeys(bind, BIND_KEYS, 'bind ', path);
|
|
68
97
|
|
|
69
98
|
if (!bind.obj || typeof bind.obj !== 'string') {
|
|
70
99
|
throw new SomaUiConfigError(
|
|
@@ -80,6 +109,10 @@ function validateBind(bind: any, path: string): asserts bind is BindDeclaration
|
|
|
80
109
|
);
|
|
81
110
|
}
|
|
82
111
|
|
|
112
|
+
if (bind.role_by !== undefined && !isPureRolePath(bind.role_by)) {
|
|
113
|
+
throw new SomaUiConfigError(roleByMessage(bind.role_by), `${path}.role_by`, 'CORE-PAGE-ROLE-BY-INVALID');
|
|
114
|
+
}
|
|
115
|
+
|
|
83
116
|
if ('onChange' in bind && bind.onChange !== undefined) {
|
|
84
117
|
parseOnChangeRules(bind.onChange, `${path}.onChange`);
|
|
85
118
|
}
|
|
@@ -111,6 +144,7 @@ function parseOnChangeRules(raw: unknown, path: string): OnChangeRule[] {
|
|
|
111
144
|
}
|
|
112
145
|
|
|
113
146
|
const rule = item as Record<string, unknown>;
|
|
147
|
+
assertClosedUiKeys(rule, ONCHANGE_KEYS, 'onChange 条目', itemPath);
|
|
114
148
|
if (typeof rule.condition !== 'string' || !rule.condition.trim()) {
|
|
115
149
|
throw new SomaUiConfigError('condition 必须是非空字符串', itemPath);
|
|
116
150
|
}
|
|
@@ -151,6 +185,9 @@ function parseInitProps(raw: unknown, path: string): Record<string, unknown> {
|
|
|
151
185
|
if (!key.trim()) {
|
|
152
186
|
throw new SomaUiConfigError('initProps 的键不能为空', path);
|
|
153
187
|
}
|
|
188
|
+
if (key.split('.').some((part) => ['__proto__', 'prototype', 'constructor'].includes(part))) {
|
|
189
|
+
throw new SomaUiConfigError(`initProps 的键 "${key}" 含不安全路径段`, path);
|
|
190
|
+
}
|
|
154
191
|
result[key] = value;
|
|
155
192
|
}
|
|
156
193
|
return result;
|
|
@@ -179,20 +216,28 @@ function isExtendedShowValue(value: any): boolean {
|
|
|
179
216
|
|
|
180
217
|
// ─── show 映射解析 ────────────────────────────────────────────────────────────
|
|
181
218
|
|
|
182
|
-
/** `when`
|
|
183
|
-
function parseWhenValue(raw: unknown, path: string):
|
|
184
|
-
if (typeof raw === 'string')
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
return
|
|
219
|
+
/** `when` 的值:只许纯路径字符串(绑定展示对象给出的布尔值);对象谓词等其它形态一律拒收 */
|
|
220
|
+
function parseWhenValue(raw: unknown, path: string): string {
|
|
221
|
+
if (typeof raw === 'string') {
|
|
222
|
+
if (hasNegationPrefix(raw)) {
|
|
223
|
+
throw new SomaUiConfigError(negationMessage('when', raw), path, 'CORE-PAGE-NEGATE-FORBIDDEN');
|
|
224
|
+
}
|
|
225
|
+
return raw;
|
|
189
226
|
}
|
|
190
227
|
throw new SomaUiConfigError(
|
|
191
|
-
`when
|
|
228
|
+
`when 必须是路径字符串(页面不求值,布尔值由展示对象给出),当前值: ${JSON.stringify(raw)}`,
|
|
192
229
|
path,
|
|
193
230
|
);
|
|
194
231
|
}
|
|
195
232
|
|
|
233
|
+
/** props 值里不许有 `!path` 取反(普通文字如 `!关闭` 不是路径,放行) */
|
|
234
|
+
function assertNoNegatedProps(props: unknown, path: string): void {
|
|
235
|
+
const hit = findNegatedPathIn(props);
|
|
236
|
+
if (hit) {
|
|
237
|
+
throw new SomaUiConfigError(negationMessage(`props.${hit.at}`, hit.value), `${path}.props`, 'CORE-PAGE-NEGATE-FORBIDDEN');
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
196
241
|
/**
|
|
197
242
|
* 递归解析 show 映射
|
|
198
243
|
*
|
|
@@ -230,6 +275,7 @@ function parseShowMapping(rawShow: any, path: string, options?: SomaUiConfigPars
|
|
|
230
275
|
} else if (isNestedShowMapping(value)) {
|
|
231
276
|
// 嵌套绑定:含 bind + show
|
|
232
277
|
const nestedPath = `${currentPath}.bind`;
|
|
278
|
+
assertClosedUiKeys(value, NESTED_SHOW_KEYS, '嵌套绑定', currentPath);
|
|
233
279
|
validateBind(value.bind, nestedPath);
|
|
234
280
|
if (value.bind.collectionSlot !== undefined && options?.collectionBindingStage !== 'definition-source') {
|
|
235
281
|
throw new SomaUiConfigError('collectionSlot 仅允许受信组件定义源;运行时必须使用准备计划', nestedPath);
|
|
@@ -253,12 +299,14 @@ function parseShowMapping(rawShow: any, path: string, options?: SomaUiConfigPars
|
|
|
253
299
|
if (!value.props || typeof value.props !== 'object' || Array.isArray(value.props)) {
|
|
254
300
|
throw new SomaUiConfigError('props 必须是对象', currentPath);
|
|
255
301
|
}
|
|
302
|
+
assertNoNegatedProps(value.props, currentPath);
|
|
256
303
|
nested.props = { ...value.props };
|
|
257
304
|
}
|
|
258
305
|
|
|
259
306
|
result[key] = nested;
|
|
260
307
|
} else if (typeof value === 'object' && value !== null && isExtendedShowValue(value)) {
|
|
261
308
|
// 扩展绑定:含 text / model / when / class / show
|
|
309
|
+
assertClosedUiKeys(value, EXTENDED_SHOW_KEYS, '展示绑定', currentPath);
|
|
262
310
|
const extended: ExtendedShowValue = {};
|
|
263
311
|
|
|
264
312
|
if ('text' in value && value.text !== undefined) {
|
|
@@ -301,6 +349,9 @@ function parseShowMapping(rawShow: any, path: string, options?: SomaUiConfigPars
|
|
|
301
349
|
`${currentPath}.class`,
|
|
302
350
|
);
|
|
303
351
|
}
|
|
352
|
+
if (hasNegationPrefix(condition)) {
|
|
353
|
+
throw new SomaUiConfigError(negationMessage(`class "${className}"`, condition), `${currentPath}.class`, 'CORE-PAGE-NEGATE-FORBIDDEN');
|
|
354
|
+
}
|
|
304
355
|
classMap[className] = condition;
|
|
305
356
|
}
|
|
306
357
|
extended.class = classMap;
|
|
@@ -317,6 +368,7 @@ function parseShowMapping(rawShow: any, path: string, options?: SomaUiConfigPars
|
|
|
317
368
|
currentPath,
|
|
318
369
|
);
|
|
319
370
|
}
|
|
371
|
+
assertNoNegatedProps(value.props as Record<string, unknown>, currentPath);
|
|
320
372
|
extended.props = { ...(value.props as Record<string, unknown>) };
|
|
321
373
|
}
|
|
322
374
|
|
|
@@ -136,7 +136,7 @@ export function createGeneratedPagePreview(
|
|
|
136
136
|
artifact: compiled.artifact,
|
|
137
137
|
uiYaml: '', eventYaml: '', styleYaml: '', DomainClass: getPreviewPageRoot(),
|
|
138
138
|
uiConfig: compiled.uiConfig as never, eventConfig: compiled.eventConfig as never,
|
|
139
|
-
|
|
139
|
+
timerConfig: compiled.timerConfig as never,
|
|
140
140
|
...(compiled.styleConfig !== undefined ? { styleConfig: compiled.styleConfig as never } : {}),
|
|
141
141
|
...(compiled.dataConfig !== undefined ? { dataConfig: compiled.dataConfig as never } : {}),
|
|
142
142
|
...(compiled.compiledStyles !== undefined ? { compiledStyles: compiled.compiledStyles as never } : {}),
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 隐藏前过渡端口(UI 体系注入,经 `renderPorts.hideTransition`;方言中性)。
|
|
3
|
+
* core 的显隐唯一出口 `setVisibility(el, false)` 在真正写 `hidden` 之前调用它:
|
|
4
|
+
* - 返回 `void`(或抛错):立即隐藏,与未注册时完全一致;
|
|
5
|
+
* - 返回 Promise:等它 resolve 后才隐藏;等待期间 core 视该元素为「已隐藏」(`isVisible` 为 false,重复隐藏不再调用钩子);
|
|
6
|
+
* - 等待期间该元素被再次显示:core 先触发 `signal` 的 abort(实现据此撤销过渡状态),再直接显示,旧 Promise 的结果作废。
|
|
7
|
+
* 钩子只在元素当前可见时被调用;是否做过渡、做什么、多久,全由实现自己决定,core 不认识动画。
|
|
8
|
+
*/
|
|
9
|
+
export type HideTransition = (element: HTMLElement, signal: AbortSignal) => Promise<void> | void;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type { NotifyRenderer } from './notify-renderer';
|
|
2
2
|
import type { RegionFallbackRenderer } from './region-fallback';
|
|
3
|
+
import type { HideTransition } from './hide-transition';
|
|
3
4
|
|
|
4
5
|
export type { NotifyEntry, NotifyRenderer } from './notify-renderer';
|
|
5
6
|
export type { RegionFallbackRenderer } from './region-fallback';
|
|
7
|
+
export type { HideTransition } from './hide-transition';
|
|
6
8
|
export { TOAST_CONFIG_ERROR, createToastScheduler } from './scheduling/toast-scheduler';
|
|
7
9
|
export type { ToastClock, ToastItemState, ToastPhase, ToastScheduler, ToastTimingConfig } from './scheduling/toast-scheduler';
|
|
8
10
|
export { createPromptQueue } from './scheduling/prompt-queue';
|
|
@@ -12,6 +14,8 @@ export type { PromptOptions, PromptQueue } from './scheduling/prompt-queue';
|
|
|
12
14
|
export interface SomaRenderPorts {
|
|
13
15
|
notify?: NotifyRenderer;
|
|
14
16
|
regionFallback?: RegionFallbackRenderer;
|
|
17
|
+
/** 隐藏前过渡:core 写 `hidden` 之前先等它(缺省立即隐藏) */
|
|
18
|
+
hideTransition?: HideTransition;
|
|
15
19
|
}
|
|
16
20
|
|
|
17
21
|
export { confirmSatisfied, confirmKeyAccepts } from '../parser/confirm-spec';
|
|
@@ -23,7 +23,8 @@ export interface NotifyEntry {
|
|
|
23
23
|
export interface NotifyRenderer {
|
|
24
24
|
show(entry: NotifyEntry): { dismiss(): void };
|
|
25
25
|
/**
|
|
26
|
-
* 确认。`spec` 只在 typed / consent
|
|
26
|
+
* 确认。`spec` 只在 typed / consent 级或 `tone: 'danger'` 时出现(plain 且无语气不带),`message` 恒等于 `spec.text`,不认识分级的渲染器照旧显示一句话。
|
|
27
|
+
* `spec.tone === 'danger'`(破坏性确认):渲染器应给确认钮警示呈现,并把初始焦点放在「取消」;typed / consent 的放行规则不变。
|
|
27
28
|
* 认识分级的渲染器必须用 `confirmSatisfied(spec, { typed, consented })` 决定确认钮此刻能不能点:
|
|
28
29
|
* typed 要键入 `phrase`、consent 要先勾选同意(`impact` 是勾选旁的影响说明);
|
|
29
30
|
* 键入框里输入法组字(`isImeProcessing`)期间的 Enter 是选词,不算确认;取消 / Esc / 点遮罩一律 resolve(false)。
|
|
@@ -46,6 +46,7 @@ import { createIdentityPort, type SomaIdentityPort, type SomaIdentityProvider }
|
|
|
46
46
|
import { createAppConfigPort, type SomaAppConfigPort } from '../infra/config/feature-flags';
|
|
47
47
|
import { createShortcutRegistry, shortcutsDesign } from './shortcuts';
|
|
48
48
|
import type { SomaShortcutRegistry } from '../../shared/types/write-runtime.types';
|
|
49
|
+
import { SOMA_PIPELINE_HOST_HTTP_REQUEST_TIMEOUT_MS } from 'soma-foundation/values';
|
|
49
50
|
|
|
50
51
|
/** Runtime infrastructure injected into domain instances by bootstrap */
|
|
51
52
|
export interface SomaRuntimeServices extends SomaRuntimeServicesBase {
|
|
@@ -200,7 +201,7 @@ export function createDefaultRuntimeServices(options?: {
|
|
|
200
201
|
const router = new SomaRouter(options?.initialPath ?? '/');
|
|
201
202
|
const http = new SomaHttpService({
|
|
202
203
|
baseURL: String(config.get('apiBaseUrl') ?? '/api'),
|
|
203
|
-
timeout: Number(config.get('requestTimeout') ??
|
|
204
|
+
timeout: Number(config.get('requestTimeout') ?? SOMA_PIPELINE_HOST_HTTP_REQUEST_TIMEOUT_MS),
|
|
204
205
|
defaultHeaders: () => ({
|
|
205
206
|
'x-soma-page-href': router.getCurrentPath().split('#')[0].split('?')[0] || '/',
|
|
206
207
|
}),
|
|
@@ -27,6 +27,11 @@ export class SomaSnapshotStore {
|
|
|
27
27
|
return snapshot.id;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
/** 释放一条快照(不存在则什么也不做):热替换等内部流程用完自己 capture 的快照即释放,不占环形容量 */
|
|
31
|
+
release(id: number): void {
|
|
32
|
+
this.snapshots = this.snapshots.filter((item) => item.id !== id);
|
|
33
|
+
}
|
|
34
|
+
|
|
30
35
|
restore(id: number, root: Record<string, any>): void {
|
|
31
36
|
const snapshot = this.snapshots.find((item) => item.id === id);
|
|
32
37
|
if (!snapshot) {
|