soma-core 2.2.5 → 2.2.6
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 +1848 -3244
- 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/SomaContainerAdapter.ts +9 -1
- package/core/client/data/data-object-resolver.ts +516 -181
- 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 +1 -105
- 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 +385 -98
- 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/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 +1 -1
- package/core/client/parser/data-config-parser.ts +27 -210
- package/core/client/parser/pipeline-parser.ts +14 -59
- 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/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 +1 -35
- 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 +5 -4
- package/core/server/compile-port.ts +1 -1
- package/core/server/host/app-config-composer.ts +2 -1
- package/core/server/host/host-assembly-entry.ts +1 -0
- package/core/server/host/host-assembly.ts +47 -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/virtual-pages.ts +3 -2
- package/core/server/infra/cache/ServerFileCache.ts +79 -9
- 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 +74 -15
- 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 +8 -0
- 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 +16 -19
- package/core/shared/registry-generated/diagnostic-registry.ts +135 -177
- package/core/shared/registry-generated/limits.ts +49 -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 +42 -20
- 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 +17 -17
- package/core/shared/types/engine.types.ts +0 -3
- package/core/shared/types/event.types.ts +1 -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 +2567 -2696
- package/dist/core/index.cjs +5446 -5486
- package/dist/host-native/aot-builder.cjs +46 -1
- package/dist/host-native/native-server.cjs +4879 -4505
- package/dist/lsp/component-tree.cjs +5814 -7042
- 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/data/data-object-resolver.d.ts +91 -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/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/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 +2 -7
- 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/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/infra/cache/ServerFileCache.d.ts +8 -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 +119 -158
- package/dist/types/shared/registry-generated/limits.d.ts +40 -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 +109 -241
- package/dist/types/shared/soma-error.d.ts +15 -0
- package/dist/types/shared/types/data-config.types.d.ts +14 -16
- package/dist/types/shared/types/engine.types.d.ts +0 -3
- package/dist/types/shared/types/event.types.d.ts +1 -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 +52 -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/package.json +3 -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,3 +1,4 @@
|
|
|
1
|
+
import { SomaError } from '../soma-error';
|
|
1
2
|
/** 切片名闭集(至多 8 个;真源 soma-design `pipeline/region-scope#/spec/slices/names`) */
|
|
2
3
|
export declare const SOMA_REGION_SLICE_NAMES: readonly ["filter", "view", "selection", "focus", "results", "navigation", "monitor", "pending"];
|
|
3
4
|
export type SomaRegionSliceName = (typeof SOMA_REGION_SLICE_NAMES)[number];
|
|
@@ -119,6 +120,8 @@ export interface SomaRegionPort {
|
|
|
119
120
|
slice(name: SomaRegionSliceName): SomaRegionSliceHandle | null;
|
|
120
121
|
/** 订阅路由上抛的语义事件(事件类型 `SCOPE | semantic`);返回退订函数 */
|
|
121
122
|
onSemantic(listener: (name: string, payload: Readonly<Record<string, unknown>>) => void): () => void;
|
|
123
|
+
/** 发语义事件(与 `SCOPE | semantic` 管道同一条通道,订阅方是同一批);组件 / 展示对象在代码里按顺序编排时用 */
|
|
124
|
+
emit(name: string, payload?: Readonly<Record<string, unknown>>): void;
|
|
122
125
|
}
|
|
123
126
|
/** 组件端 `ctx.services.region`:按作用域 id 取端口;作用域未声明、端口已失效返回 null */
|
|
124
127
|
export type SomaRegionServices = (scopeId: string) => SomaRegionPort | null;
|
|
@@ -137,7 +140,7 @@ export interface SomaScopeEventSpec {
|
|
|
137
140
|
}
|
|
138
141
|
export declare const SOMA_REGION_SCOPE_ERROR: "ERR-RUN-001";
|
|
139
142
|
/** 区域协调的运行期缺陷(非 owner / 非路径写者写切片等);与 ERR-RUN-001 同级,只影响该区域 */
|
|
140
|
-
export declare class SomaRegionScopeError extends
|
|
143
|
+
export declare class SomaRegionScopeError extends SomaError {
|
|
141
144
|
readonly code: "ERR-RUN-001";
|
|
142
145
|
readonly scopeId: string;
|
|
143
146
|
readonly slice: string;
|
|
@@ -7,16 +7,15 @@
|
|
|
7
7
|
*/
|
|
8
8
|
export type SomaStyleViolationKind = 'layout-class';
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
10
|
+
* 类名档位绑定(纯绑定):`bind` 路径指向展示对象的成员,成员的值就是档位名;
|
|
11
|
+
* 档位名命中 `tiers` 的键时,应用该档位的类名,其余档位的类名一律移除;不在闭集内时不加任何类。
|
|
12
|
+
* 页面不写「等于某值」的比较;档位名闭集形态与个数上限见 std-grammar.json#pageForbiddenLogicKeys.pureBinding.styleTier。
|
|
12
13
|
*/
|
|
13
|
-
export interface
|
|
14
|
-
/**
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
|
|
18
|
-
/** 匹配时应用的 CSS 类名;具体样式由宿主样式系统提供 */
|
|
19
|
-
apply: string;
|
|
14
|
+
export interface StyleTierBinding {
|
|
15
|
+
/** 展示对象成员的纯路径(点分标识符,无取反 / 管道 / 运算符) */
|
|
16
|
+
bind: string;
|
|
17
|
+
/** 档位名 → 类名串;具体样式由宿主样式系统提供 */
|
|
18
|
+
tiers: Record<string, string>;
|
|
20
19
|
}
|
|
21
20
|
/**
|
|
22
21
|
* 过渡/动画触发器类型
|
|
@@ -25,16 +24,15 @@ export type TransitionTrigger = 'hover' | 'focus' | 'active' | 'enter' | 'leave'
|
|
|
25
24
|
/**
|
|
26
25
|
* 过渡/动画配置
|
|
27
26
|
*/
|
|
28
|
-
export
|
|
29
|
-
/**
|
|
30
|
-
trigger: TransitionTrigger
|
|
27
|
+
export type StyleTransition = {
|
|
28
|
+
/** DOM 事件 / 入离场触发 */
|
|
29
|
+
trigger: Exclude<TransitionTrigger, 'active_state'>;
|
|
31
30
|
/** 应用的 CSS 动画/过渡类名;具体样式由宿主样式系统提供 */
|
|
32
31
|
apply: string;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
32
|
+
} | ({
|
|
33
|
+
/** 状态驱动:纯绑定,成员的值就是档位名 */
|
|
34
|
+
trigger: 'active_state';
|
|
35
|
+
} & StyleTierBinding);
|
|
38
36
|
/**
|
|
39
37
|
* 样式配置顶层结构
|
|
40
38
|
* 对应 _style.yaml 文件的完整结构
|
|
@@ -44,8 +42,8 @@ export interface StyleConfig {
|
|
|
44
42
|
host: string;
|
|
45
43
|
/** 基础静态样式映射:somaId → CSS 类名 */
|
|
46
44
|
base: Record<string, string>;
|
|
47
|
-
/** 状态驱动样式:somaId →
|
|
48
|
-
states: Record<string,
|
|
45
|
+
/** 状态驱动样式:somaId → 类名档位绑定 */
|
|
46
|
+
states: Record<string, StyleTierBinding>;
|
|
49
47
|
/** 动态交互与动画:somaId → 过渡配置 */
|
|
50
48
|
transitions: Record<string, StyleTransition>;
|
|
51
49
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { OnChangeRule } from './watcher.types';
|
|
2
2
|
import type { SomaPageStateConfig } from './page-state.types';
|
|
3
3
|
import type { SomaScopeDecl } from './region-scope.types';
|
|
4
|
-
import type { SomaShowWhen } from '../show-when';
|
|
5
4
|
/**
|
|
6
5
|
* 作用域声明
|
|
7
6
|
* 定义数据源路径和当前作用域别名
|
|
@@ -45,8 +44,8 @@ export interface NestedShowMapping {
|
|
|
45
44
|
bind: BindDeclaration;
|
|
46
45
|
/** 子级展示映射 */
|
|
47
46
|
show: ShowMapping;
|
|
48
|
-
/** 整块显隐:与 bind 同处一个配置对象(另起同名键会覆盖列表绑定)
|
|
49
|
-
when?:
|
|
47
|
+
/** 整块显隐:与 bind 同处一个配置对象(另起同名键会覆盖列表绑定);纯路径字符串("!path" 取反),值由展示对象给出 */
|
|
48
|
+
when?: string;
|
|
50
49
|
}
|
|
51
50
|
/**
|
|
52
51
|
* 扩展绑定值
|
|
@@ -57,8 +56,8 @@ export interface ExtendedShowValue {
|
|
|
57
56
|
text?: string;
|
|
58
57
|
/** 双向绑定路径(表单控件) */
|
|
59
58
|
model?: string;
|
|
60
|
-
/**
|
|
61
|
-
when?:
|
|
59
|
+
/** 条件渲染:纯路径字符串(truthy 显示,"!path" 取反),布尔值由展示对象 / 业务对象给出 */
|
|
60
|
+
when?: string;
|
|
62
61
|
/** CSS 类名动态绑定 { "class-names": "condition-path" } */
|
|
63
62
|
class?: Record<string, string>;
|
|
64
63
|
/** 子级展示映射 */
|
|
@@ -3,8 +3,13 @@
|
|
|
3
3
|
|
|
4
4
|
const path = require('node:path');
|
|
5
5
|
const fs = require('node:fs');
|
|
6
|
+
const os = require('node:os');
|
|
6
7
|
const { spawn } = require('node:child_process');
|
|
7
8
|
|
|
9
|
+
process.on('unhandledRejection', (reason) => {
|
|
10
|
+
console.error('[soma-native][unhandledRejection]', reason);
|
|
11
|
+
});
|
|
12
|
+
|
|
8
13
|
const args = process.argv.slice(2);
|
|
9
14
|
const command = args[0];
|
|
10
15
|
|
|
@@ -43,7 +48,12 @@ if (!process.env.SOMA_NATIVE_HEAP_APPLIED && !process.env.SOMA_DISABLE_HEAP_CAP)
|
|
|
43
48
|
process.on('SIGINT', () => forward('SIGINT'));
|
|
44
49
|
process.on('SIGTERM', () => forward('SIGTERM'));
|
|
45
50
|
child.on('exit', (code, signal) => {
|
|
46
|
-
|
|
51
|
+
if (typeof code === 'number') {
|
|
52
|
+
process.exit(code);
|
|
53
|
+
} else {
|
|
54
|
+
const sigNum = signal && os.constants && os.constants.signals ? os.constants.signals[signal] : undefined;
|
|
55
|
+
process.exit(typeof sigNum === 'number' ? 128 + sigNum : 1);
|
|
56
|
+
}
|
|
47
57
|
});
|
|
48
58
|
return;
|
|
49
59
|
}
|
|
@@ -159,8 +169,15 @@ async function run() {
|
|
|
159
169
|
const nativeServer = (!isDev && fs.existsSync(precompiledServerPath))
|
|
160
170
|
? require(precompiledServerPath)
|
|
161
171
|
: loadJiti()(path.resolve(__dirname, '../src/native-server.ts'));
|
|
172
|
+
const targetPort = port ?? (process.env.PORT ? parseInt(process.env.PORT, 10) : 3000);
|
|
173
|
+
const targetHost = hostname ?? process.env.SOMA_HOST ?? process.env.HOST ?? '0.0.0.0';
|
|
174
|
+
if (await nativeServer.isPortInUse(targetPort, targetHost)) {
|
|
175
|
+
console.error(`[soma-native][server] 端口 ${targetPort} 已被其他进程占用,请使用 --port 指定其他端口`);
|
|
176
|
+
process.exit(1);
|
|
177
|
+
}
|
|
162
178
|
|
|
163
179
|
if (isDev) {
|
|
180
|
+
process.env.SOMA_DEV_SERVER = '1';
|
|
164
181
|
const hostPrepare = loadJiti()(path.resolve(__dirname, '../src/host-prepare.ts'));
|
|
165
182
|
try {
|
|
166
183
|
await hostPrepare.prewarmHostPages(hostDir, process.env);
|
|
@@ -180,6 +197,10 @@ async function run() {
|
|
|
180
197
|
});
|
|
181
198
|
|
|
182
199
|
const { url, port: actualPort } = await instance.start();
|
|
200
|
+
// 只警告不退出:纯四件套原生工程没有 soma.app.ts 是合法的。装配代码只认文件名 soma.app.ts(应用根或源码根下,见 host-assembly.ts)。
|
|
201
|
+
if (![hostDir, webRoot].some((dir) => fs.existsSync(path.join(dir, 'soma.app.ts')))) {
|
|
202
|
+
console.warn(`[soma-native] 未找到 soma.app.ts,当前目录:${hostDir};若这是 soma-kit / 应用工程,请确认在工程根目录运行`);
|
|
203
|
+
}
|
|
183
204
|
const modeText = isDev ? '开发态 (增量热更新)' : '生产态 (极速 AOT)';
|
|
184
205
|
|
|
185
206
|
console.log(`\n SOMA 极速原生内核已就绪 [${modeText}]`);
|
|
@@ -14,7 +14,6 @@ import type {
|
|
|
14
14
|
SomaRuntimeServices,
|
|
15
15
|
} from 'soma-core/runtime';
|
|
16
16
|
import { assertRuntimeArtifact, maybeStartBootTimings, readBootTimings, SomaBootstrap } from 'soma-core/runtime';
|
|
17
|
-
import { SomaLocaleOnlyPageRoot } from 'soma-core/base';
|
|
18
17
|
import { loadHostDomainClass, resolveHostBootstrapOptions } from 'soma-core/host-bridge';
|
|
19
18
|
import { designChunkLoadBackoffMs } from 'soma-foundation/layout';
|
|
20
19
|
import {
|
|
@@ -32,6 +31,14 @@ declare global {
|
|
|
32
31
|
|
|
33
32
|
const isDev = process.env.NODE_ENV !== 'production';
|
|
34
33
|
|
|
34
|
+
export function isBindingMatch(
|
|
35
|
+
cachedBinding?: { digest?: string; generation?: number },
|
|
36
|
+
incomingBinding?: { digest?: string; generation?: number },
|
|
37
|
+
): boolean {
|
|
38
|
+
return (cachedBinding?.digest ?? '') === (incomingBinding?.digest ?? '') &&
|
|
39
|
+
(cachedBinding?.generation ?? 0) === (incomingBinding?.generation ?? 0);
|
|
40
|
+
}
|
|
41
|
+
|
|
35
42
|
export function forbiddenText(language?: string): string {
|
|
36
43
|
return language && language.toLowerCase().startsWith('en')
|
|
37
44
|
? SOMA_PAGE_FORBIDDEN_TEXT_EN
|
|
@@ -69,6 +76,13 @@ type PagePayload = ComponentTreeRuntimeEnvelope & {
|
|
|
69
76
|
query?: SomaPageAssets['pageQuery'];
|
|
70
77
|
queryContract?: SomaPageAssets['queryContract'];
|
|
71
78
|
nav?: SomaPageAssets['nav'];
|
|
79
|
+
binding?: {
|
|
80
|
+
digest?: string;
|
|
81
|
+
generation?: number;
|
|
82
|
+
kind?: string;
|
|
83
|
+
owner?: string;
|
|
84
|
+
version?: string;
|
|
85
|
+
};
|
|
72
86
|
};
|
|
73
87
|
|
|
74
88
|
type PrecompiledAssets = Pick<
|
|
@@ -78,7 +92,6 @@ type PrecompiledAssets = Pick<
|
|
|
78
92
|
| 'artifact'
|
|
79
93
|
| 'uiConfig'
|
|
80
94
|
| 'eventConfig'
|
|
81
|
-
| 'triggerConfig'
|
|
82
95
|
| 'timerConfig'
|
|
83
96
|
| 'styleConfig'
|
|
84
97
|
| 'locale'
|
|
@@ -97,7 +110,6 @@ async function loadPrecompiledFromManifest(
|
|
|
97
110
|
const res = await fetch(`/soma/manifest?path=${encodeURIComponent(path)}`);
|
|
98
111
|
if (!res.ok) return null;
|
|
99
112
|
const data: PrecompiledAssets & {
|
|
100
|
-
triggers?: SomaPageAssets['triggerConfig'];
|
|
101
113
|
timers?: SomaPageAssets['timerConfig'];
|
|
102
114
|
} = await res.json();
|
|
103
115
|
assertRuntimeArtifact(data);
|
|
@@ -115,7 +127,6 @@ async function loadPrecompiledFromManifest(
|
|
|
115
127
|
artifact: data.artifact,
|
|
116
128
|
uiConfig: data.uiConfig,
|
|
117
129
|
eventConfig: data.eventConfig,
|
|
118
|
-
triggerConfig: data.triggers ?? [],
|
|
119
130
|
timerConfig: data.timers ?? [],
|
|
120
131
|
styleConfig: data.styleConfig,
|
|
121
132
|
locale: data.locale ?? {},
|
|
@@ -128,168 +139,10 @@ async function loadPrecompiledFromManifest(
|
|
|
128
139
|
}
|
|
129
140
|
}
|
|
130
141
|
|
|
131
|
-
// 9 维主题与视觉方案跨页实时同步(支持工作台用户操作记忆与多窗口协同)
|
|
132
|
-
function applyVisualSchemeToHost(hostEl: HTMLElement, state: Record<string, unknown>): void {
|
|
133
|
-
const palette = (state.palette || state.colorEnum || "CLASSIC_TECH_BLUE") as string;
|
|
134
|
-
const colorDepth = (state.colorDepth || state.depth || "NORMAL") as string;
|
|
135
|
-
const colorSaturation = (state.colorSaturation || state.sat || "STANDARD_SATURATION") as string;
|
|
136
|
-
const fontFamily = (state.fontFamily || state.family || "SYSTEM_SANS") as string;
|
|
137
|
-
const fontScale = (state.fontScale || state.scale || state.typoEnum || "MEDIUM_STANDARD") as string;
|
|
138
|
-
const boundary = (state.boundary || state.boundaryScheme || "HAIRLINE_BORDER") as string;
|
|
139
|
-
const shape = (state.shape || state.componentShape || state.styleEnum || "STANDARD_ROUNDED") as string;
|
|
140
|
-
const surfaceTexture = (state.surfaceTexture || state.texture || "SOLID_MATTE") as string;
|
|
141
|
-
const density = (state.density || state.spatialDensity || "STANDARD_BALANCED") as string;
|
|
142
|
-
|
|
143
|
-
const normDepth = (colorDepth === "LIGHTENED" || colorDepth === "SLIGHTLY_LIGHT" || colorDepth === "VERY_LIGHT" || colorDepth === "soft")
|
|
144
|
-
? "LIGHTENED"
|
|
145
|
-
: (colorDepth === "DARKENED" || colorDepth === "SLIGHTLY_DEEP" || colorDepth === "VERY_DEEP" || colorDepth === "dimmed" || colorDepth === "dark")
|
|
146
|
-
? "DARKENED"
|
|
147
|
-
: "NORMAL";
|
|
148
|
-
hostEl.setAttribute("data-kit-palette", palette);
|
|
149
|
-
hostEl.setAttribute("data-kit-depth", normDepth);
|
|
150
|
-
hostEl.setAttribute("data-kit-boundary", boundary);
|
|
151
|
-
hostEl.setAttribute("data-kit-shape", shape);
|
|
152
|
-
hostEl.setAttribute("data-kit-texture", surfaceTexture);
|
|
153
|
-
hostEl.setAttribute("data-kit-density", density);
|
|
154
|
-
document.documentElement.setAttribute("data-kit-palette", palette);
|
|
155
|
-
document.documentElement.setAttribute("data-kit-depth", normDepth);
|
|
156
|
-
document.documentElement.setAttribute("data-kit-boundary", boundary);
|
|
157
|
-
document.documentElement.setAttribute("data-kit-shape", shape);
|
|
158
|
-
document.documentElement.setAttribute("data-kit-texture", surfaceTexture);
|
|
159
|
-
document.documentElement.setAttribute("data-kit-density", density);
|
|
160
|
-
|
|
161
|
-
const s = document.documentElement.style;
|
|
162
|
-
s.setProperty("--soma-theme-palette", palette);
|
|
163
|
-
s.setProperty("--soma-theme-color-depth", colorDepth);
|
|
164
|
-
s.setProperty("--soma-theme-color-saturation", colorSaturation);
|
|
165
|
-
s.setProperty("--soma-theme-font-family", fontFamily);
|
|
166
|
-
s.setProperty("--soma-theme-font-scale", fontScale);
|
|
167
|
-
s.setProperty("--soma-theme-boundary", boundary);
|
|
168
|
-
s.setProperty("--soma-theme-shape", shape);
|
|
169
|
-
s.setProperty("--soma-theme-surface-texture", surfaceTexture);
|
|
170
|
-
s.setProperty("--soma-theme-density", density);
|
|
171
|
-
|
|
172
|
-
const isBorderless = boundary === "BORDERLESS_SHADOW";
|
|
173
|
-
s.setProperty("--soma-border-width", isBorderless ? "0px" : "0.5px");
|
|
174
|
-
|
|
175
|
-
let radiusCard = "8px";
|
|
176
|
-
let radiusControl = "6px";
|
|
177
|
-
let radiusSm = "6px";
|
|
178
|
-
let radiusMd = "8px";
|
|
179
|
-
let radiusLg = "10px";
|
|
180
|
-
let radiusXl = "14px";
|
|
181
|
-
let radiusFull = "9999px";
|
|
182
|
-
|
|
183
|
-
if (shape === "SMALL_SHARP") {
|
|
184
|
-
radiusCard = "4px";
|
|
185
|
-
radiusControl = "2px";
|
|
186
|
-
radiusSm = "2px";
|
|
187
|
-
radiusMd = "4px";
|
|
188
|
-
radiusLg = "4px";
|
|
189
|
-
radiusXl = "6px";
|
|
190
|
-
} else if (shape === "PILL_CAPSULE") {
|
|
191
|
-
radiusCard = "16px";
|
|
192
|
-
radiusControl = "9999px";
|
|
193
|
-
radiusSm = "9999px";
|
|
194
|
-
radiusMd = "12px";
|
|
195
|
-
radiusLg = "16px";
|
|
196
|
-
radiusXl = "20px";
|
|
197
|
-
} else if (shape === "PURE_SQUARE") {
|
|
198
|
-
radiusCard = "0px";
|
|
199
|
-
radiusControl = "0px";
|
|
200
|
-
radiusSm = "0px";
|
|
201
|
-
radiusMd = "0px";
|
|
202
|
-
radiusLg = "0px";
|
|
203
|
-
radiusXl = "0px";
|
|
204
|
-
radiusFull = "0px";
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
s.setProperty("--soma-radius-card", radiusCard);
|
|
208
|
-
s.setProperty("--soma-radius-control", radiusControl);
|
|
209
|
-
s.setProperty("--soma-radius-sm", radiusSm);
|
|
210
|
-
s.setProperty("--soma-radius-md", radiusMd);
|
|
211
|
-
s.setProperty("--soma-radius-lg", radiusLg);
|
|
212
|
-
s.setProperty("--soma-radius-xl", radiusXl);
|
|
213
|
-
s.setProperty("--soma-radius-full", radiusFull);
|
|
214
|
-
|
|
215
|
-
let controlHeight = "32px";
|
|
216
|
-
let space1 = "0.25rem";
|
|
217
|
-
if (density === "COMPACT_DENSE" || density === "compact") {
|
|
218
|
-
controlHeight = "28px";
|
|
219
|
-
space1 = "0.22rem";
|
|
220
|
-
} else if (density === "SPACIOUS_AIRY" || density === "spacious") {
|
|
221
|
-
controlHeight = "40px";
|
|
222
|
-
space1 = "0.3rem";
|
|
223
|
-
}
|
|
224
|
-
s.setProperty("--soma-control-height", controlHeight);
|
|
225
|
-
s.setProperty("--soma-space-1", space1);
|
|
226
|
-
|
|
227
|
-
s.setProperty("--soma-shadow-step-0", isBorderless ? "0 1px 3px 0 rgba(0, 0, 0, 0.06), 0 4px 12px 0 rgba(0, 0, 0, 0.05)" : "none");
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
function setupVisualSchemeSync(containerEl: HTMLElement): () => void {
|
|
231
|
-
const syncFromStorage = () => {
|
|
232
|
-
try {
|
|
233
|
-
const kitHost = containerEl.querySelector('[data-soma-host="SomaLocaleOnlyPageRoot"]') as HTMLElement | null;
|
|
234
|
-
if (!kitHost) return;
|
|
235
|
-
if (typeof localStorage === "undefined") return;
|
|
236
|
-
const raw = localStorage.getItem("soma-visual-scheme-state-v1") || localStorage.getItem("soma-visual-scheme-state");
|
|
237
|
-
if (!raw) return;
|
|
238
|
-
const parsed = JSON.parse(raw);
|
|
239
|
-
if (parsed && typeof parsed === "object") {
|
|
240
|
-
applyVisualSchemeToHost(kitHost, parsed);
|
|
241
|
-
}
|
|
242
|
-
} catch {}
|
|
243
|
-
};
|
|
244
|
-
|
|
245
|
-
syncFromStorage();
|
|
246
|
-
|
|
247
|
-
const onMessage = (ev: MessageEvent) => {
|
|
248
|
-
try {
|
|
249
|
-
const kitHost = containerEl.querySelector('[data-soma-host="SomaLocaleOnlyPageRoot"]') as HTMLElement | null;
|
|
250
|
-
if (!kitHost) return;
|
|
251
|
-
if (ev.data && typeof ev.data === "object") {
|
|
252
|
-
applyVisualSchemeToHost(kitHost, ev.data);
|
|
253
|
-
}
|
|
254
|
-
} catch {}
|
|
255
|
-
};
|
|
256
|
-
|
|
257
|
-
const onStorage = (ev: StorageEvent) => {
|
|
258
|
-
if ((ev.key === "soma-visual-scheme-state-v1" || ev.key === "soma-visual-scheme-state") && ev.newValue) {
|
|
259
|
-
try {
|
|
260
|
-
const kitHost = containerEl.querySelector('[data-soma-host="SomaLocaleOnlyPageRoot"]') as HTMLElement | null;
|
|
261
|
-
if (!kitHost) return;
|
|
262
|
-
const parsed = JSON.parse(ev.newValue);
|
|
263
|
-
if (parsed && typeof parsed === "object") {
|
|
264
|
-
applyVisualSchemeToHost(kitHost, parsed);
|
|
265
|
-
}
|
|
266
|
-
} catch {}
|
|
267
|
-
}
|
|
268
|
-
};
|
|
269
|
-
|
|
270
|
-
let channel: BroadcastChannel | null = null;
|
|
271
|
-
try {
|
|
272
|
-
if (typeof BroadcastChannel !== "undefined") {
|
|
273
|
-
channel = new BroadcastChannel("soma-visual-scheme-sync");
|
|
274
|
-
channel.addEventListener("message", onMessage);
|
|
275
|
-
}
|
|
276
|
-
} catch {}
|
|
277
|
-
|
|
278
|
-
window.addEventListener("storage", onStorage);
|
|
279
|
-
|
|
280
|
-
return () => {
|
|
281
|
-
try {
|
|
282
|
-
channel?.close();
|
|
283
|
-
} catch {}
|
|
284
|
-
window.removeEventListener("storage", onStorage);
|
|
285
|
-
};
|
|
286
|
-
}
|
|
287
|
-
|
|
288
142
|
class NativePageClient {
|
|
289
143
|
|
|
290
144
|
private bootstrap: SomaBootstrapType | null = null;
|
|
291
145
|
private routerBridgeUnsub: (() => void) | null = null;
|
|
292
|
-
private visualSchemeUnsub: (() => void) | null = null;
|
|
293
146
|
private currentRunId = 0;
|
|
294
147
|
private appRoot: HTMLElement;
|
|
295
148
|
private hydrationShell: HTMLElement;
|
|
@@ -448,9 +301,10 @@ class NativePageClient {
|
|
|
448
301
|
|
|
449
302
|
const base = (data.base as string) || urlPathToPageBase(pagePath);
|
|
450
303
|
const sourcePackage = typeof data.sourcePackage === 'string' ? data.sourcePackage : null;
|
|
304
|
+
// 动态页 / 组件树页不走静态 Domain 加载;页面根由引擎按 `domain:` 名查 Host 的 pageRoots 类表(没登记 = 缺省根)
|
|
451
305
|
const DomainClass =
|
|
452
306
|
data.sourceMarkup === 'component-tree' || base.startsWith('dynamic-')
|
|
453
|
-
?
|
|
307
|
+
? undefined
|
|
454
308
|
: await loadHostDomainClass({ base, sourcePackage });
|
|
455
309
|
const routeAssets = {
|
|
456
310
|
routerPath,
|
|
@@ -475,15 +329,17 @@ class NativePageClient {
|
|
|
475
329
|
}
|
|
476
330
|
|
|
477
331
|
const cached = pageAssetCache.get(routerPath);
|
|
332
|
+
const bindingMatch = isBindingMatch(cached?.binding, data.binding);
|
|
478
333
|
if (
|
|
479
334
|
cached &&
|
|
335
|
+
bindingMatch &&
|
|
480
336
|
(cached.sourceMarkup ?? 'legacy-html') === (data.sourceMarkup ?? 'legacy-html') &&
|
|
481
337
|
(data.sourceMarkup !== 'component-tree' ||
|
|
482
338
|
cached.artifact?.artifactDigest === data.artifact?.artifactDigest)
|
|
483
339
|
) {
|
|
484
340
|
const CachedClass =
|
|
485
341
|
cached.sourceMarkup === 'component-tree' || cached.base.startsWith('dynamic-')
|
|
486
|
-
?
|
|
342
|
+
? undefined
|
|
487
343
|
: await loadHostDomainClass({
|
|
488
344
|
base: cached.base,
|
|
489
345
|
sourcePackage: cached.sourcePackage,
|
|
@@ -528,6 +384,7 @@ class NativePageClient {
|
|
|
528
384
|
appConfigYaml: data.appConfigYaml ?? '',
|
|
529
385
|
compiledStyles: data.compiledStyles,
|
|
530
386
|
colorScheme: data.colorScheme,
|
|
387
|
+
binding: data.binding,
|
|
531
388
|
};
|
|
532
389
|
|
|
533
390
|
if (!isDev) {
|
|
@@ -585,11 +442,6 @@ class NativePageClient {
|
|
|
585
442
|
await this.bootstrap.unmount();
|
|
586
443
|
this.bootstrap = null;
|
|
587
444
|
}
|
|
588
|
-
const prevVisualSchemeUnsub = this.visualSchemeUnsub;
|
|
589
|
-
if (prevVisualSchemeUnsub) {
|
|
590
|
-
prevVisualSchemeUnsub();
|
|
591
|
-
this.visualSchemeUnsub = null;
|
|
592
|
-
}
|
|
593
445
|
if (runId !== this.currentRunId) return;
|
|
594
446
|
|
|
595
447
|
const getServices = () =>
|
|
@@ -614,9 +466,6 @@ class NativePageClient {
|
|
|
614
466
|
|
|
615
467
|
this.showContainer();
|
|
616
468
|
|
|
617
|
-
if (this.visualSchemeUnsub) { (this.visualSchemeUnsub as () => void)(); }
|
|
618
|
-
this.visualSchemeUnsub = setupVisualSchemeSync(this.containerEl);
|
|
619
|
-
|
|
620
469
|
if (typeof window !== 'undefined') {
|
|
621
470
|
window.__SOMA_DIAGNOSTICS__ = {
|
|
622
471
|
isSettled: () => bs.isSettled(),
|
|
@@ -172,6 +172,58 @@ function createBrowserClientPlugin(options: {
|
|
|
172
172
|
}
|
|
173
173
|
return undefined;
|
|
174
174
|
});
|
|
175
|
+
|
|
176
|
+
// 8. 可选 peer 依赖 echarts:仅当包 `echarts` 本身无法解析(未安装)时才回落轻量无头桩模块,
|
|
177
|
+
// 防未装 echarts 的应用在 soma dev / build 时崩溃;已安装 echarts 但某个子路径解析失败(版本不符、路径写错)
|
|
178
|
+
// 属于真实错误,原样上抛,不静默吞成桩。
|
|
179
|
+
build.onResolve({ filter: /^echarts(?:\/.*)?$/ }, async (args) => {
|
|
180
|
+
if (args.pluginData?.skipEchartsStub) return undefined;
|
|
181
|
+
const resolveOpts = {
|
|
182
|
+
resolveDir: args.resolveDir,
|
|
183
|
+
kind: args.kind,
|
|
184
|
+
importer: args.importer,
|
|
185
|
+
pluginData: { skipEchartsStub: true },
|
|
186
|
+
};
|
|
187
|
+
const resolved = await build.resolve(args.path, resolveOpts);
|
|
188
|
+
if (resolved.errors.length === 0 && resolved.path) {
|
|
189
|
+
return { path: resolved.path };
|
|
190
|
+
}
|
|
191
|
+
// 子路径失败时再探包根:包根可解析 = 已安装,子路径错误原样抛出
|
|
192
|
+
const bare = args.path === 'echarts' ? resolved : await build.resolve('echarts', resolveOpts);
|
|
193
|
+
if (bare.errors.length === 0 && bare.path) {
|
|
194
|
+
return { errors: resolved.errors };
|
|
195
|
+
}
|
|
196
|
+
return {
|
|
197
|
+
path: args.path,
|
|
198
|
+
namespace: 'soma-optional-echarts-stub',
|
|
199
|
+
};
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
build.onLoad({ filter: /.*/, namespace: 'soma-optional-echarts-stub' }, () => ({
|
|
203
|
+
contents: `
|
|
204
|
+
// 未安装可选依赖 echarts 时的无头桩:首次 init() 提示一次,图表不渲染
|
|
205
|
+
let warned = false;
|
|
206
|
+
export const SVGRenderer = {};
|
|
207
|
+
export function use() {}
|
|
208
|
+
export function init() {
|
|
209
|
+
if (!warned) {
|
|
210
|
+
warned = true;
|
|
211
|
+
console.warn('未安装可选依赖 echarts,图表不会渲染:npm i echarts');
|
|
212
|
+
}
|
|
213
|
+
return {
|
|
214
|
+
setOption() {},
|
|
215
|
+
dispatchAction() {},
|
|
216
|
+
on() {},
|
|
217
|
+
off() {},
|
|
218
|
+
resize() {},
|
|
219
|
+
dispose() {},
|
|
220
|
+
getModel() { return { getSeriesByIndex() { return undefined; } }; },
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
export default { SVGRenderer, use, init };
|
|
224
|
+
`,
|
|
225
|
+
loader: 'js',
|
|
226
|
+
}));
|
|
175
227
|
},
|
|
176
228
|
};
|
|
177
229
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
-
import { assertReservedRoutesShape, loadHostAssembly, registerShellRoutes as registerCoreShellRoutes } from 'soma-core/server/host-assembly';
|
|
3
|
+
import { assertReservedRoutesShape, loadHostAssembly, invalidateHostAssembly, registerShellRoutes as registerCoreShellRoutes } from 'soma-core/server/host-assembly';
|
|
4
|
+
import { clearPagePayloadBufferCache } from './page-http';
|
|
4
5
|
import { precompileAll, precompilePage } from '../../core/build/compiler/full-manifest-builder';
|
|
5
6
|
import { addressOfPageBase } from '../../core/build/compiler/page-base-resolver';
|
|
6
7
|
import { loadPageMarkupConfig } from '../../core/server/host/page-markup-config';
|
|
@@ -8,6 +9,7 @@ import { resolveHostTreeCompileContext } from '../../core/server/host/resolve-ho
|
|
|
8
9
|
import { runPrewarm, computePrewarmInputsDigest } from '../../core/server/runtime-space/prewarm';
|
|
9
10
|
import { resolveAppConfigPath, resolveHostAppConfigPath } from '../../core/server/host/host-config-paths.cjs';
|
|
10
11
|
import { getSomaAssetSources, collectPageEntries, collectIncludes } from '../../core/server/host/source-packages';
|
|
12
|
+
import { invalidateStaticAddresses } from '../../core/server/runtime-space/static-source';
|
|
11
13
|
|
|
12
14
|
export const SOMA_SHELL_ROUTES_ENV = 'SOMA_SHELL_ROUTES';
|
|
13
15
|
|
|
@@ -36,11 +38,38 @@ export function registerShellRoutes(shellRoutes: readonly string[] = readShellRo
|
|
|
36
38
|
return shellRoutes.length === 0 ? [] : registerCoreShellRoutes(shellRoutes);
|
|
37
39
|
}
|
|
38
40
|
|
|
41
|
+
/**
|
|
42
|
+
* 清除指定宿主目录的已准备状态与页面缓存(热更新用)
|
|
43
|
+
*/
|
|
44
|
+
export async function invalidateHostPreparation(hostDir: string): Promise<void> {
|
|
45
|
+
const resolvedHostDir = path.resolve(hostDir);
|
|
46
|
+
let assembly: any = null;
|
|
47
|
+
try {
|
|
48
|
+
assembly = await loadHostAssembly(resolvedHostDir);
|
|
49
|
+
} catch {}
|
|
50
|
+
if (assembly && typeof assembly.invalidate === 'function') {
|
|
51
|
+
try {
|
|
52
|
+
await assembly.invalidate();
|
|
53
|
+
} catch (e) {
|
|
54
|
+
console.warn('[soma-native] assembly.invalidate() error:', e);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
invalidateHostAssembly(resolvedHostDir);
|
|
58
|
+
clearPagePayloadBufferCache();
|
|
59
|
+
invalidateStaticAddresses(resolvedHostDir);
|
|
60
|
+
}
|
|
61
|
+
|
|
39
62
|
export async function prepareHostAssembly(hostDir: string | undefined) {
|
|
40
63
|
if (!hostDir) return null;
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
64
|
+
const resolvedHostDir = path.resolve(hostDir);
|
|
65
|
+
try {
|
|
66
|
+
const assembly = await loadHostAssembly(resolvedHostDir);
|
|
67
|
+
registerShellRoutes();
|
|
68
|
+
return assembly;
|
|
69
|
+
} catch (err) {
|
|
70
|
+
await invalidateHostPreparation(resolvedHostDir);
|
|
71
|
+
throw err;
|
|
72
|
+
}
|
|
44
73
|
}
|
|
45
74
|
|
|
46
75
|
function readFileOrEmpty(filePath: string): string {
|
|
@@ -52,7 +81,8 @@ function readFileOrEmpty(filePath: string): string {
|
|
|
52
81
|
*/
|
|
53
82
|
export async function prewarmHostPages(hostDir: string, env: NodeJS.ProcessEnv = process.env) {
|
|
54
83
|
const resolvedHostDir = path.resolve(hostDir);
|
|
55
|
-
|
|
84
|
+
try {
|
|
85
|
+
const host = await prepareHostAssembly(resolvedHostDir);
|
|
56
86
|
const sources = getSomaAssetSources(resolvedHostDir, env);
|
|
57
87
|
const pageEntries = collectPageEntries(sources);
|
|
58
88
|
const includes = collectIncludes(sources);
|
|
@@ -120,4 +150,8 @@ export async function prewarmHostPages(hostDir: string, env: NodeJS.ProcessEnv =
|
|
|
120
150
|
meta: { routes: shell.routes, locale: shell.locale, appConfig: shell.appConfig },
|
|
121
151
|
...(host && typeof host.prewarm === 'function' ? { hook: () => host.prewarm!() } : {}),
|
|
122
152
|
});
|
|
153
|
+
} catch (err) {
|
|
154
|
+
await invalidateHostPreparation(resolvedHostDir);
|
|
155
|
+
throw err;
|
|
156
|
+
}
|
|
123
157
|
}
|
|
@@ -37,8 +37,8 @@ function findExactBinding(bindings: readonly SomaRuntimeBinding[], address: stri
|
|
|
37
37
|
* 客户端走 /soma/page)。命中后产物来自预热(`<root>/prewarm/`)。
|
|
38
38
|
* GET /soma/manifest?index=1 - 绑定清单 + 预热索引(地址 → 摘要)。
|
|
39
39
|
*/
|
|
40
|
-
export async function handleManifestGet(request: Request): Promise<Response> {
|
|
41
|
-
const hostDir = process.env.SOMA_HOST_DIR;
|
|
40
|
+
export async function handleManifestGet(request: Request, options?: { readonly hostDir?: string }): Promise<Response> {
|
|
41
|
+
const hostDir = options?.hostDir ?? process.env.SOMA_HOST_DIR;
|
|
42
42
|
if (!hostDir) {
|
|
43
43
|
return Response.json({ error: 'SOMA_HOST_DIR not set' }, { status: 500 });
|
|
44
44
|
}
|
|
@@ -83,7 +83,6 @@ export async function handleManifestGet(request: Request): Promise<Response> {
|
|
|
83
83
|
artifact: page.artifact,
|
|
84
84
|
uiConfig: page.uiConfig,
|
|
85
85
|
eventConfig: page.eventConfig,
|
|
86
|
-
triggers: page.triggers,
|
|
87
86
|
timers: page.timers ?? [],
|
|
88
87
|
styleConfig: page.styleConfig,
|
|
89
88
|
dataConfig: page.dataConfig,
|