soma-core 1.0.1 → 1.0.2
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/app/SomaPageClient.tsx +336 -0
- package/app/api/[...path]/route.ts +9 -85
- package/app/api/page/route.ts +18 -16
- package/app/api/soma-manifest/route.ts +39 -0
- package/app/components/SomaHydrationShell.tsx +23 -0
- package/app/layout.tsx +2 -2
- package/app/loading.tsx +5 -0
- package/app/page.tsx +19 -128
- package/bin/soma-lsp.cjs +195 -0
- package/bin/soma-sync.cjs +3 -0
- package/bin/soma.cjs +14 -2
- package/core/api/IService.ts +6 -10
- package/core/api/load-host-service.ts +72 -0
- package/core/api/service-path.ts +39 -0
- package/core/base/SomaEntity.ts +3 -10
- package/core/base/SomaLocaleOnlyPageRoot.ts +3 -4
- package/core/base/SomaPageRootBase.ts +20 -3
- package/core/base/decorators/Event.ts +23 -0
- package/core/base/decorators/Locale.ts +35 -0
- package/core/base/decorators/Page.ts +16 -0
- package/core/base/decorators/Show.ts +20 -0
- package/core/base/decorators/ShowList.ts +34 -0
- package/core/base/decorators/index.ts +5 -0
- package/core/base/index.ts +2 -0
- package/core/base/runAsync.ts +32 -0
- package/core/compiler/full-manifest-builder.ts +33 -7
- package/core/compiler/host-config-sync.cjs +38 -0
- package/core/compiler/manifest-compiler.ts +3 -2
- package/core/compiler/page-base-resolver.ts +23 -0
- package/core/compiler/precompiled-manifest-loader.ts +34 -0
- package/core/compiler/rollup-plugin-soma.ts +45 -0
- package/core/compiler/rspack-plugin-soma.js +33 -0
- package/core/compiler/soma-manifest-webpack-plugin.js +72 -0
- package/core/compiler/soma-precompile.js +3513 -0
- package/core/compiler/soma-precompile.ts +52 -6
- package/core/compiler/soma-rspack-yaml-loader.js +22 -0
- package/core/compiler/soma-webpack-loader.js +7 -1
- package/core/compiler/vite-plugin-soma.ts +11 -1
- package/core/container/IContainerAdapter.ts +36 -0
- package/core/container/MiniProgramContainerAdapter.ts +190 -0
- package/core/container/ReactNativeContainerAdapter.ts +189 -0
- package/core/container/SomaContainerAdapter.ts +17 -6
- package/core/diagnostics/SomaDiagnostics.ts +1 -1
- package/core/diagnostics/SomaTelemetry.ts +100 -0
- package/core/diagnostics/telemetry-context.ts +15 -0
- package/core/engine/asset-resolver.ts +39 -4
- package/core/engine/dom-renderer.ts +9 -11
- package/core/engine/event-engine.ts +110 -41
- package/core/engine/on-change-engine.ts +71 -0
- package/core/engine/property-watcher.ts +117 -0
- package/core/engine/reactive-proxy.ts +11 -5
- package/core/engine/render-engine.ts +97 -11
- package/core/engine/runtime-builder.ts +88 -11
- package/core/engine/scope-resolver.ts +65 -9
- package/core/engine/soma-bootstrap.ts +448 -244
- package/core/engine/style-binder.ts +423 -0
- package/core/engine/theme-variables.ts +37 -0
- package/core/engine/timer-engine.ts +92 -0
- package/core/engine/trigger-engine.ts +55 -0
- package/core/host/resolve-host-bootstrap.ts +28 -0
- package/core/host/soma-bootstrap-host.stub.ts +4 -0
- package/core/index.ts +33 -2
- package/core/infra/auth/TokenAuthService.ts +17 -3
- package/core/infra/http/IHttpClient.ts +11 -1
- package/core/infra/http/SomaHttpService.ts +89 -31
- package/core/infra/i18n/DefaultI18n.ts +6 -18
- package/core/infra/i18n/II18n.ts +2 -3
- package/core/infra/notify/DomNotifyService.ts +98 -0
- package/core/infra/notify/INotifyTheme.ts +22 -0
- package/core/infra/realtime/IRealtimeService.ts +23 -0
- package/core/infra/realtime/IRealtimeTransport.ts +9 -0
- package/core/infra/realtime/SomaRealtimeService.ts +95 -0
- package/core/infra/realtime/SseRealtimeTransport.ts +36 -0
- package/core/infra/realtime/WebSocketRealtimeTransport.ts +102 -0
- package/core/infra/router/router-path.ts +28 -0
- package/core/infra/storage/SessionStorageService.ts +59 -0
- package/core/lsp/cross-file-diagnostics.cjs +160 -0
- package/core/lsp/event-yaml-completion.cjs +106 -0
- package/core/lsp/extra-completion.cjs +64 -0
- package/core/lsp/lsp-navigation.cjs +191 -0
- package/core/lsp/ui-yaml-completion.cjs +170 -0
- package/core/manifest/manifest-contract.ts +12 -0
- package/core/middleware/createPermissionMiddleware.ts +37 -0
- package/core/parser/annotation-extractor.ts +113 -0
- package/core/parser/pipeline-parser.ts +344 -276
- package/core/parser/style-config-parser.ts +340 -0
- package/core/parser/timer-parser.ts +70 -0
- package/core/parser/trigger-parser.ts +90 -0
- package/core/parser/ui-config-parser.ts +73 -1
- package/core/quality/SomaQualityRegistry.ts +68 -0
- package/core/runtime/SomaRuntimeServices.ts +100 -0
- package/core/runtime/SomaSnapshotStore.ts +5 -3
- package/core/types/domain.types.ts +5 -2
- package/core/types/event.types.ts +82 -57
- package/core/types/manifest.types.ts +2 -0
- package/core/types/style-config.types.ts +76 -0
- package/core/types/timer.types.ts +23 -0
- package/core/types/trigger.types.ts +14 -0
- package/core/types/ui-config.types.ts +9 -0
- package/core/types/watcher.types.ts +29 -0
- package/dist/cli/soma.js +23 -23
- package/dist/core/index.cjs +8968 -0
- package/dist/diagnostics/telemetry.cjs +105 -0
- package/dist/preview-export.cjs +3401 -0
- package/dist/tsconfig.types.tsbuildinfo +1 -0
- package/dist/types/api/IService.d.ts +28 -0
- package/dist/types/api/load-host-service.d.ts +5 -0
- package/dist/types/api/service-path.d.ts +13 -0
- package/dist/types/base/SomaApi.d.ts +5 -0
- package/dist/types/base/SomaDict.d.ts +89 -0
- package/dist/types/base/SomaEntity.d.ts +15 -0
- package/dist/types/base/SomaHttpClient.d.ts +66 -0
- package/dist/types/base/SomaLocaleOnlyPageRoot.d.ts +3 -0
- package/dist/types/base/SomaPageRootBase.d.ts +49 -0
- package/dist/types/base/SomaValidator.d.ts +55 -0
- package/dist/types/base/decorators/Event.d.ts +10 -0
- package/dist/types/base/decorators/Locale.d.ts +9 -0
- package/dist/types/base/decorators/Page.d.ts +4 -0
- package/dist/types/base/decorators/Show.d.ts +7 -0
- package/dist/types/base/decorators/ShowList.d.ts +12 -0
- package/dist/types/base/decorators/index.d.ts +5 -0
- package/dist/types/base/index.d.ts +9 -0
- package/dist/types/base/runAsync.d.ts +12 -0
- package/dist/types/compiler/full-manifest-builder.d.ts +35 -0
- package/dist/types/compiler/manifest-compiler.d.ts +29 -0
- package/dist/types/compiler/page-base-resolver.d.ts +6 -0
- package/dist/types/compiler/precompiled-manifest-loader.d.ts +5 -0
- package/dist/types/compiler/rollup-plugin-soma.d.ts +14 -0
- package/dist/types/compiler/route-builder.d.ts +12 -0
- package/dist/types/compiler/soma-precompile.d.ts +40 -0
- package/dist/types/compiler/vite-plugin-soma.d.ts +34 -0
- package/dist/types/container/IContainerAdapter.d.ts +30 -0
- package/dist/types/container/MiniProgramContainerAdapter.d.ts +52 -0
- package/dist/types/container/ReactNativeContainerAdapter.d.ts +47 -0
- package/dist/types/container/SomaContainerAdapter.d.ts +30 -0
- package/dist/types/diagnostics/SomaDiagnostics.d.ts +64 -0
- package/dist/types/diagnostics/SomaTelemetry.d.ts +32 -0
- package/dist/types/diagnostics/telemetry-context.d.ts +4 -0
- package/dist/types/engine/asset-resolver.d.ts +17 -0
- package/dist/types/engine/dom-renderer.d.ts +35 -0
- package/dist/types/engine/event-engine.d.ts +64 -0
- package/dist/types/engine/lis.d.ts +10 -0
- package/dist/types/engine/on-change-engine.d.ts +16 -0
- package/dist/types/engine/property-watcher.d.ts +18 -0
- package/dist/types/engine/reactive-proxy.d.ts +58 -0
- package/dist/types/engine/render-engine.d.ts +73 -0
- package/dist/types/engine/runtime-builder.d.ts +58 -0
- package/dist/types/engine/scope-resolver.d.ts +90 -0
- package/dist/types/engine/soma-bootstrap.d.ts +112 -0
- package/dist/types/engine/style-binder.d.ts +81 -0
- package/dist/types/engine/theme-variables.d.ts +3 -0
- package/dist/types/engine/timer-engine.d.ts +19 -0
- package/dist/types/engine/trigger-engine.d.ts +16 -0
- package/dist/types/host/resolve-host-bootstrap.d.ts +11 -0
- package/dist/types/host/soma-bootstrap-host.stub.d.ts +3 -0
- package/dist/types/index.d.ts +35 -0
- package/dist/types/infra/auth/IAuthService.d.ts +12 -0
- package/dist/types/infra/auth/TokenAuthService.d.ts +26 -0
- package/dist/types/infra/cache/ICache.d.ts +12 -0
- package/dist/types/infra/cache/MemoryCache.d.ts +14 -0
- package/dist/types/infra/cache/ServerFileCache.d.ts +37 -0
- package/dist/types/infra/config/IConfig.d.ts +9 -0
- package/dist/types/infra/config/SomaConfig.d.ts +21 -0
- package/dist/types/infra/event-bus/IEventBus.d.ts +8 -0
- package/dist/types/infra/event-bus/SomaEventBus.d.ts +9 -0
- package/dist/types/infra/http/IHttpClient.d.ts +28 -0
- package/dist/types/infra/http/SomaHttpService.d.ts +27 -0
- package/dist/types/infra/i18n/DefaultI18n.d.ts +7 -0
- package/dist/types/infra/i18n/II18n.d.ts +6 -0
- package/dist/types/infra/logger/ConsoleLogger.d.ts +14 -0
- package/dist/types/infra/logger/ILogger.d.ts +17 -0
- package/dist/types/infra/notify/DefaultNotifyService.d.ts +16 -0
- package/dist/types/infra/notify/DomNotifyService.d.ts +16 -0
- package/dist/types/infra/notify/INotifyService.d.ts +12 -0
- package/dist/types/infra/notify/INotifyTheme.d.ts +12 -0
- package/dist/types/infra/permission/IPermission.d.ts +10 -0
- package/dist/types/infra/permission/SomaPermission.d.ts +19 -0
- package/dist/types/infra/realtime/IRealtimeService.d.ts +13 -0
- package/dist/types/infra/realtime/IRealtimeTransport.d.ts +8 -0
- package/dist/types/infra/realtime/SomaRealtimeService.d.ts +20 -0
- package/dist/types/infra/realtime/SseRealtimeTransport.d.ts +11 -0
- package/dist/types/infra/realtime/WebSocketRealtimeTransport.d.ts +30 -0
- package/dist/types/infra/router/IRouter.d.ts +16 -0
- package/dist/types/infra/router/SomaRouter.d.ts +18 -0
- package/dist/types/infra/router/router-path.d.ts +6 -0
- package/dist/types/infra/storage/IStorageService.d.ts +7 -0
- package/dist/types/infra/storage/MemoryStorageService.d.ts +15 -0
- package/dist/types/infra/storage/SessionStorageService.d.ts +14 -0
- package/dist/types/infra/timer/ITimer.d.ts +13 -0
- package/dist/types/infra/timer/SomaTimer.d.ts +21 -0
- package/dist/types/manifest/manifest-contract.d.ts +4 -0
- package/dist/types/middleware/SomaMiddlewareChain.d.ts +6 -0
- package/dist/types/middleware/createPermissionMiddleware.d.ts +14 -0
- package/dist/types/parser/annotation-extractor.d.ts +12 -0
- package/dist/types/parser/pipeline-parser.d.ts +62 -0
- package/dist/types/parser/style-config-parser.d.ts +20 -0
- package/dist/types/parser/timer-parser.d.ts +6 -0
- package/dist/types/parser/trigger-parser.d.ts +13 -0
- package/dist/types/parser/ui-config-parser.d.ts +34 -0
- package/dist/types/parser/yaml-loader.d.ts +21 -0
- package/dist/types/quality/SomaQualityRegistry.d.ts +31 -0
- package/dist/types/runtime/SomaRuntimeServices.d.ts +35 -0
- package/dist/types/runtime/SomaSnapshotStore.d.ts +13 -0
- package/dist/types/scheduler/SomaScheduler.d.ts +25 -0
- package/dist/types/types/domain.types.d.ts +82 -0
- package/dist/types/types/engine.types.d.ts +22 -0
- package/dist/types/types/event.types.d.ts +61 -0
- package/dist/types/types/keyboard.types.d.ts +4 -0
- package/dist/types/types/manifest.types.d.ts +29 -0
- package/dist/types/types/scheduler.types.d.ts +8 -0
- package/dist/types/types/style-config.types.d.ts +62 -0
- package/dist/types/types/timer.types.d.ts +19 -0
- package/dist/types/types/trigger.types.d.ts +12 -0
- package/dist/types/types/ui-config.types.d.ts +85 -0
- package/dist/types/types/watcher.types.d.ts +24 -0
- package/dist/types/validation/contract-validator.d.ts +40 -0
- package/editor/vscode/extension.js +39 -0
- package/editor/vscode/language-configuration.json +17 -0
- package/editor/vscode/package.json +98 -0
- package/editor/vscode/syntaxes/soma-event-yaml.tmLanguage.json +30 -0
- package/editor/vscode/syntaxes/soma-ui-yaml.tmLanguage.json +42 -0
- package/global.d.ts +19 -0
- package/next.config.js +9 -4
- package/package.json +53 -16
- package/tailwind.config.ts +26 -7
- package/tsconfig.json +6 -2
- package/core/router/RouteHandler.ts +0 -93
|
@@ -4,8 +4,21 @@
|
|
|
4
4
|
import yaml from 'js-yaml';
|
|
5
5
|
import { parseUiConfig } from '../parser/ui-config-parser';
|
|
6
6
|
import { parseEventConfig } from '../parser/pipeline-parser';
|
|
7
|
+
import { splitEventConfigRaw } from '../parser/trigger-parser';
|
|
8
|
+
import { parseStyleConfig } from '../parser/style-config-parser';
|
|
7
9
|
import type { UiConfig } from '../types/ui-config.types';
|
|
8
10
|
import type { ParsedEvent } from '../types/event.types';
|
|
11
|
+
import type { PropertyTrigger } from '../types/trigger.types';
|
|
12
|
+
|
|
13
|
+
import type { ParsedTimer } from '../types/timer.types';
|
|
14
|
+
|
|
15
|
+
/** _event.yaml 预编译产物 */
|
|
16
|
+
export interface CompiledEventConfig {
|
|
17
|
+
events: ParsedEvent[];
|
|
18
|
+
triggers: PropertyTrigger[];
|
|
19
|
+
timers: ParsedTimer[];
|
|
20
|
+
}
|
|
21
|
+
import type { StyleConfig } from '../types/style-config.types';
|
|
9
22
|
|
|
10
23
|
/**
|
|
11
24
|
* 预编译 UI YAML → JSON 字符串
|
|
@@ -17,12 +30,24 @@ export function precompileUiYaml(yamlStr: string): string {
|
|
|
17
30
|
}
|
|
18
31
|
|
|
19
32
|
/**
|
|
20
|
-
* 预编译 Event YAML → JSON
|
|
33
|
+
* 预编译 Event YAML → JSON 字符串(含 events + triggers)
|
|
21
34
|
*/
|
|
22
35
|
export function precompileEventYaml(yamlStr: string): string {
|
|
36
|
+
const raw = yamlStr.trim() ? yaml.load(yamlStr) : {};
|
|
37
|
+
const compiled = compileEventConfigFromRaw(raw);
|
|
38
|
+
return JSON.stringify(compiled);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* 预编译 Style YAML → JSON 字符串
|
|
43
|
+
*/
|
|
44
|
+
export function precompileStyleYaml(yamlStr: string): string {
|
|
23
45
|
const raw = yaml.load(yamlStr);
|
|
24
|
-
|
|
25
|
-
|
|
46
|
+
if (!raw) {
|
|
47
|
+
return 'undefined';
|
|
48
|
+
}
|
|
49
|
+
const styleConfig = parseStyleConfig(raw);
|
|
50
|
+
return JSON.stringify(styleConfig);
|
|
26
51
|
}
|
|
27
52
|
|
|
28
53
|
/**
|
|
@@ -33,10 +58,31 @@ export function compileUiConfig(yamlStr: string): UiConfig {
|
|
|
33
58
|
}
|
|
34
59
|
|
|
35
60
|
/**
|
|
36
|
-
* 预编译 Event YAML →
|
|
61
|
+
* 预编译 Event YAML → CompiledEventConfig 对象
|
|
37
62
|
*/
|
|
38
|
-
export function compileEventConfig(yamlStr: string):
|
|
39
|
-
|
|
63
|
+
export function compileEventConfig(yamlStr: string): CompiledEventConfig {
|
|
64
|
+
if (!yamlStr.trim()) {
|
|
65
|
+
return { events: [], triggers: [], timers: [] };
|
|
66
|
+
}
|
|
67
|
+
return compileEventConfigFromRaw(yaml.load(yamlStr));
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export function compileEventConfigFromRaw(raw: unknown): CompiledEventConfig {
|
|
71
|
+
const { eventsRaw, triggers, timers } = splitEventConfigRaw(raw);
|
|
72
|
+
return {
|
|
73
|
+
events: parseEventConfig(eventsRaw as any),
|
|
74
|
+
triggers,
|
|
75
|
+
timers,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* 预编译 Style YAML → StyleConfig 对象
|
|
81
|
+
*/
|
|
82
|
+
export function compileStyleConfig(yamlStr: string): StyleConfig | undefined {
|
|
83
|
+
const raw = yaml.load(yamlStr);
|
|
84
|
+
if (!raw) return undefined;
|
|
85
|
+
return parseStyleConfig(raw);
|
|
40
86
|
}
|
|
41
87
|
|
|
42
88
|
/**
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const {
|
|
2
|
+
precompileUiYaml,
|
|
3
|
+
precompileEventYaml,
|
|
4
|
+
precompileStyleYaml,
|
|
5
|
+
precompileYaml,
|
|
6
|
+
} = require('./soma-precompile');
|
|
7
|
+
|
|
8
|
+
module.exports = function somaRspackYamlLoader(source) {
|
|
9
|
+
const options = this.getOptions?.() ?? {};
|
|
10
|
+
const uiSuffix = options.uiSuffix ?? '_ui.yaml';
|
|
11
|
+
const eventSuffix = options.eventSuffix ?? '_event.yaml';
|
|
12
|
+
const styleSuffix = options.styleSuffix ?? '_style.yaml';
|
|
13
|
+
const resourcePath = this.resourcePath ?? '';
|
|
14
|
+
|
|
15
|
+
let compiled;
|
|
16
|
+
if (resourcePath.endsWith(uiSuffix)) compiled = precompileUiYaml(source);
|
|
17
|
+
else if (resourcePath.endsWith(eventSuffix)) compiled = precompileEventYaml(source);
|
|
18
|
+
else if (resourcePath.endsWith(styleSuffix)) compiled = precompileStyleYaml(source);
|
|
19
|
+
else compiled = precompileYaml(source);
|
|
20
|
+
|
|
21
|
+
return `export default ${compiled};`;
|
|
22
|
+
};
|
|
@@ -7,7 +7,7 @@ module.exports = function somaWebpackLoader(source) {
|
|
|
7
7
|
const resourcePath = this.resourcePath;
|
|
8
8
|
|
|
9
9
|
try {
|
|
10
|
-
const { precompileUiYaml, precompileEventYaml, precompileYaml } = require('./soma-precompile');
|
|
10
|
+
const { precompileUiYaml, precompileEventYaml, precompileStyleYaml, precompileYaml } = require('./soma-precompile');
|
|
11
11
|
|
|
12
12
|
// SOMA UI 配置
|
|
13
13
|
if (resourcePath.endsWith('_ui.yaml')) {
|
|
@@ -21,6 +21,12 @@ module.exports = function somaWebpackLoader(source) {
|
|
|
21
21
|
return `export default ${compiled};`;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
// SOMA Style 配置
|
|
25
|
+
if (resourcePath.endsWith('_style.yaml')) {
|
|
26
|
+
const compiled = precompileStyleYaml(source);
|
|
27
|
+
return `export default ${compiled};`;
|
|
28
|
+
}
|
|
29
|
+
|
|
24
30
|
// 通用 YAML(locale、app.config 等)
|
|
25
31
|
if (resourcePath.endsWith('.yaml') || resourcePath.endsWith('.yml')) {
|
|
26
32
|
const compiled = precompileYaml(source);
|
|
@@ -2,13 +2,15 @@
|
|
|
2
2
|
// Vite 预编译插件:在构建阶段将所有声明式 YAML 配置编译为 JS 模块
|
|
3
3
|
|
|
4
4
|
import type { Plugin } from 'vite';
|
|
5
|
-
import { precompileUiYaml, precompileEventYaml, precompileYaml } from './soma-precompile';
|
|
5
|
+
import { precompileUiYaml, precompileEventYaml, precompileStyleYaml, precompileYaml } from './soma-precompile';
|
|
6
6
|
|
|
7
7
|
export interface SomaPluginOptions {
|
|
8
8
|
/** UI 配置文件后缀,默认 _ui.yaml */
|
|
9
9
|
uiSuffix?: string;
|
|
10
10
|
/** 事件配置文件后缀,默认 _event.yaml */
|
|
11
11
|
eventSuffix?: string;
|
|
12
|
+
/** 样式配置文件后缀,默认 _style.yaml */
|
|
13
|
+
styleSuffix?: string;
|
|
12
14
|
}
|
|
13
15
|
|
|
14
16
|
/**
|
|
@@ -20,6 +22,7 @@ export interface SomaPluginOptions {
|
|
|
20
22
|
* 覆盖范围:
|
|
21
23
|
* - `_ui.yaml` → UiConfig 对象(parseUiConfig 预编译)
|
|
22
24
|
* - `_event.yaml` → ParsedEvent[] 数组(parseEventConfig 预编译)
|
|
25
|
+
* - `_style.yaml` → StyleConfig 对象(parseStyleConfig 预编译)
|
|
23
26
|
* - `locale.yaml` → Record<string, unknown>
|
|
24
27
|
* - `*.config.yaml` → 任意配置对象
|
|
25
28
|
* - 其他 `.yaml` → 通用 YAML → JS 对象
|
|
@@ -37,6 +40,7 @@ export interface SomaPluginOptions {
|
|
|
37
40
|
export function somaPlugin(options: SomaPluginOptions = {}): Plugin {
|
|
38
41
|
const uiSuffix = options.uiSuffix ?? '_ui.yaml';
|
|
39
42
|
const eventSuffix = options.eventSuffix ?? '_event.yaml';
|
|
43
|
+
const styleSuffix = options.styleSuffix ?? '_style.yaml';
|
|
40
44
|
|
|
41
45
|
return {
|
|
42
46
|
name: 'vite-plugin-soma',
|
|
@@ -60,6 +64,12 @@ export function somaPlugin(options: SomaPluginOptions = {}): Plugin {
|
|
|
60
64
|
return { code: `export default ${compiled};`, map: null };
|
|
61
65
|
}
|
|
62
66
|
|
|
67
|
+
// SOMA Style 配置
|
|
68
|
+
if (id.endsWith(styleSuffix)) {
|
|
69
|
+
const compiled = precompileStyleYaml(code);
|
|
70
|
+
return { code: `export default ${compiled};`, map: null };
|
|
71
|
+
}
|
|
72
|
+
|
|
63
73
|
// 通用 YAML(locale、app.config 等)
|
|
64
74
|
const compiled = precompileYaml(code);
|
|
65
75
|
return { code: `export default ${compiled};`, map: null };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/** 容器适配层协议 — Web / Test / RN / 小程序统一接口 */
|
|
2
|
+
export interface SomaAnchorStats {
|
|
3
|
+
anchors: Set<string>;
|
|
4
|
+
duplicates: Map<string, number>;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export interface IContainerAdapter {
|
|
8
|
+
mount(container: HTMLElement, html: string, includes?: Record<string, string>): void;
|
|
9
|
+
collectAnchors(container: HTMLElement): SomaAnchorStats;
|
|
10
|
+
findAnchor(root: ParentNode, somaId: string): HTMLElement | null;
|
|
11
|
+
findClosestAnchor(target: EventTarget | null): HTMLElement | null;
|
|
12
|
+
getAnchorId(element: HTMLElement): string | null;
|
|
13
|
+
readRole(element: HTMLElement): string | null;
|
|
14
|
+
getTemplate(element: HTMLElement): HTMLTemplateElement | null;
|
|
15
|
+
cloneTemplate(element: HTMLElement): DocumentFragment | null;
|
|
16
|
+
clearRenderedChildren(element: HTMLElement): void;
|
|
17
|
+
appendFragment(element: HTMLElement, fragment: DocumentFragment): void;
|
|
18
|
+
setText(element: HTMLElement, value: string): void;
|
|
19
|
+
setAttribute(element: HTMLElement, attrName: string, value: string): void;
|
|
20
|
+
setHtml(element: HTMLElement, value: string): void;
|
|
21
|
+
setVisibility(element: HTMLElement, visible: boolean): void;
|
|
22
|
+
isVisible(element: HTMLElement): boolean;
|
|
23
|
+
toggleClasses(element: HTMLElement, classes: string[], enabled: boolean): void;
|
|
24
|
+
setValue(element: HTMLElement, value: string): void;
|
|
25
|
+
getValue(element: HTMLElement): string;
|
|
26
|
+
listen(
|
|
27
|
+
element: HTMLElement,
|
|
28
|
+
eventType: string,
|
|
29
|
+
listener: (event: Event) => void,
|
|
30
|
+
signal: AbortSignal,
|
|
31
|
+
): void;
|
|
32
|
+
confirm(message: string): boolean;
|
|
33
|
+
navigate(url: string): void;
|
|
34
|
+
now(): number;
|
|
35
|
+
setNavigateHandler?(handler: (url: string) => void): void;
|
|
36
|
+
}
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 小程序容器适配器 — 映射 WXML 风格节点树(示范实现)
|
|
3
|
+
*/
|
|
4
|
+
import type { IContainerAdapter, SomaAnchorStats } from './IContainerAdapter';
|
|
5
|
+
|
|
6
|
+
export interface MpElementNode {
|
|
7
|
+
somaId: string | null;
|
|
8
|
+
tag: string;
|
|
9
|
+
attrs: Record<string, string>;
|
|
10
|
+
children: MpElementNode[];
|
|
11
|
+
text?: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** 模拟 wx API 表面 */
|
|
15
|
+
export interface MiniProgramHost {
|
|
16
|
+
setData?(data: Record<string, unknown>): void;
|
|
17
|
+
navigateTo?(opts: { url: string }): void;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export class MiniProgramContainerAdapter implements IContainerAdapter {
|
|
21
|
+
readonly platform = 'miniprogram' as const;
|
|
22
|
+
private tree: MpElementNode = { somaId: null, tag: 'view', attrs: {}, children: [] };
|
|
23
|
+
private domBridge: HTMLElement | null = null;
|
|
24
|
+
private host: MiniProgramHost = {};
|
|
25
|
+
private navigateHandler: ((url: string) => void) | null = null;
|
|
26
|
+
|
|
27
|
+
constructor(host?: MiniProgramHost) {
|
|
28
|
+
if (host) this.host = host;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
setNavigateHandler(handler: (url: string) => void): void {
|
|
32
|
+
this.navigateHandler = handler;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
mount(container: HTMLElement, html: string, includes?: Record<string, string>): void {
|
|
36
|
+
this.domBridge = container;
|
|
37
|
+
let merged = html;
|
|
38
|
+
if (includes) {
|
|
39
|
+
for (const f of Object.values(includes)) merged += f;
|
|
40
|
+
}
|
|
41
|
+
this.tree = this.htmlToMpTree(merged);
|
|
42
|
+
if (this.domBridge) {
|
|
43
|
+
this.domBridge.innerHTML = `<view data-soma-platform="miniprogram">${merged}</view>`;
|
|
44
|
+
}
|
|
45
|
+
this.host.setData?.({ somaTree: this.tree });
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
collectAnchors(container: HTMLElement): SomaAnchorStats {
|
|
49
|
+
const anchors = new Set<string>();
|
|
50
|
+
const walk = (n: MpElementNode) => {
|
|
51
|
+
if (n.somaId) anchors.add(n.somaId);
|
|
52
|
+
n.children.forEach(walk);
|
|
53
|
+
};
|
|
54
|
+
walk(this.tree);
|
|
55
|
+
container.querySelectorAll('[data-soma-id]').forEach((el) => {
|
|
56
|
+
const id = el.getAttribute('data-soma-id');
|
|
57
|
+
if (id) anchors.add(id);
|
|
58
|
+
});
|
|
59
|
+
return { anchors, duplicates: new Map() };
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
findAnchor(root: ParentNode, somaId: string): HTMLElement | null {
|
|
63
|
+
if (this.domBridge) {
|
|
64
|
+
return this.domBridge.querySelector(`[data-soma-id="${somaId}"]`);
|
|
65
|
+
}
|
|
66
|
+
const el = document.createElement('view');
|
|
67
|
+
el.setAttribute('data-soma-id', somaId);
|
|
68
|
+
return el as unknown as HTMLElement;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
findClosestAnchor(target: EventTarget | null): HTMLElement | null {
|
|
72
|
+
if (target instanceof HTMLElement) return target.closest('[data-soma-id]');
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
getAnchorId(element: HTMLElement): string | null {
|
|
77
|
+
return element.getAttribute('data-soma-id');
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
readRole(element: HTMLElement): string | null {
|
|
81
|
+
return element.getAttribute('data-soma-role');
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
getTemplate(element: HTMLElement): HTMLTemplateElement | null {
|
|
85
|
+
return element.querySelector('template');
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
cloneTemplate(element: HTMLElement): DocumentFragment | null {
|
|
89
|
+
const t = this.getTemplate(element);
|
|
90
|
+
return t ? (t.content.cloneNode(true) as DocumentFragment) : null;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
clearRenderedChildren(element: HTMLElement): void {
|
|
94
|
+
for (const child of Array.from(element.children)) {
|
|
95
|
+
if (child.tagName !== 'TEMPLATE') child.remove();
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
appendFragment(element: HTMLElement, fragment: DocumentFragment): void {
|
|
100
|
+
element.appendChild(fragment);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
setText(element: HTMLElement, value: string): void {
|
|
104
|
+
element.textContent = value;
|
|
105
|
+
const id = element.getAttribute('data-soma-id');
|
|
106
|
+
if (id) {
|
|
107
|
+
const node = this.findMpNode(this.tree, id);
|
|
108
|
+
if (node) {
|
|
109
|
+
node.text = value;
|
|
110
|
+
this.host.setData?.({ [`soma.${id}`]: value });
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
setAttribute(element: HTMLElement, attrName: string, value: string): void {
|
|
116
|
+
element.setAttribute(attrName, value);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
setHtml(element: HTMLElement, value: string): void {
|
|
120
|
+
element.textContent = value;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
setVisibility(element: HTMLElement, visible: boolean): void {
|
|
124
|
+
element.style.display = visible ? '' : 'none';
|
|
125
|
+
element.hidden = !visible;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
isVisible(element: HTMLElement): boolean {
|
|
129
|
+
return !element.hidden && element.style.display !== 'none';
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
toggleClasses(element: HTMLElement, classes: string[], enabled: boolean): void {
|
|
133
|
+
if (enabled) element.classList.add(...classes);
|
|
134
|
+
else element.classList.remove(...classes);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
setValue(element: HTMLElement, value: string): void {
|
|
138
|
+
(element as HTMLInputElement).value = value;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
getValue(element: HTMLElement): string {
|
|
142
|
+
return (element as HTMLInputElement).value ?? '';
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
listen(
|
|
146
|
+
element: HTMLElement,
|
|
147
|
+
eventType: string,
|
|
148
|
+
listener: (event: Event) => void,
|
|
149
|
+
signal: AbortSignal,
|
|
150
|
+
): void {
|
|
151
|
+
element.addEventListener(eventType, listener, { signal });
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
confirm(_message: string): boolean {
|
|
155
|
+
return true;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
navigate(url: string): void {
|
|
159
|
+
if (this.navigateHandler) {
|
|
160
|
+
this.navigateHandler(url);
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
this.host.navigateTo?.({ url });
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
now(): number {
|
|
167
|
+
return Date.now();
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
getMpTree(): MpElementNode {
|
|
171
|
+
return this.tree;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
private findMpNode(node: MpElementNode, somaId: string): MpElementNode | null {
|
|
175
|
+
if (node.somaId === somaId) return node;
|
|
176
|
+
for (const c of node.children) {
|
|
177
|
+
const hit = this.findMpNode(c, somaId);
|
|
178
|
+
if (hit) return hit;
|
|
179
|
+
}
|
|
180
|
+
return null;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
private htmlToMpTree(html: string): MpElementNode {
|
|
184
|
+
const root: MpElementNode = { somaId: null, tag: 'view', attrs: {}, children: [] };
|
|
185
|
+
for (const m of html.matchAll(/data-soma-id=["']([^"']+)["']/g)) {
|
|
186
|
+
root.children.push({ somaId: m[1], tag: 'text', attrs: {}, children: [] });
|
|
187
|
+
}
|
|
188
|
+
return root;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React Native 容器适配器 — 将 SOMA 渲染指令映射为 RN 样式树(示范实现)
|
|
3
|
+
* 生产环境需对接 react-native 组件;此处用内存节点 + jsdom HTMLElement 桥接测试。
|
|
4
|
+
*/
|
|
5
|
+
import type { IContainerAdapter, SomaAnchorStats } from './IContainerAdapter';
|
|
6
|
+
|
|
7
|
+
export interface RNElementNode {
|
|
8
|
+
somaId: string | null;
|
|
9
|
+
tag: string;
|
|
10
|
+
props: Record<string, string>;
|
|
11
|
+
children: RNElementNode[];
|
|
12
|
+
text?: string;
|
|
13
|
+
templateRole?: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export class ReactNativeContainerAdapter implements IContainerAdapter {
|
|
17
|
+
readonly platform = 'react-native' as const;
|
|
18
|
+
private root: RNElementNode = { somaId: null, tag: 'View', props: {}, children: [] };
|
|
19
|
+
private navigateHandler: ((url: string) => void) | null = null;
|
|
20
|
+
private listeners = new Map<string, Array<{ type: string; fn: (e: Event) => void; signal: AbortSignal }>>();
|
|
21
|
+
|
|
22
|
+
/** 桥接用 DOM 容器(测试 / 混合渲染) */
|
|
23
|
+
private domBridge: HTMLElement | null = null;
|
|
24
|
+
|
|
25
|
+
setNavigateHandler(handler: (url: string) => void): void {
|
|
26
|
+
this.navigateHandler = handler;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
mount(container: HTMLElement, html: string, includes?: Record<string, string>): void {
|
|
30
|
+
this.domBridge = container;
|
|
31
|
+
let merged = html;
|
|
32
|
+
if (includes) {
|
|
33
|
+
for (const fragment of Object.values(includes)) merged += fragment;
|
|
34
|
+
}
|
|
35
|
+
this.root = this.parseHtmlToTree(merged);
|
|
36
|
+
if (this.domBridge) {
|
|
37
|
+
this.domBridge.innerHTML = `<div data-soma-platform="react-native">${merged}</div>`;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
collectAnchors(container: HTMLElement): SomaAnchorStats {
|
|
42
|
+
const anchors = new Set<string>();
|
|
43
|
+
const counts = new Map<string, number>();
|
|
44
|
+
const walk = (node: RNElementNode) => {
|
|
45
|
+
if (node.somaId) {
|
|
46
|
+
anchors.add(node.somaId);
|
|
47
|
+
counts.set(node.somaId, (counts.get(node.somaId) ?? 0) + 1);
|
|
48
|
+
}
|
|
49
|
+
node.children.forEach(walk);
|
|
50
|
+
};
|
|
51
|
+
walk(this.root);
|
|
52
|
+
const duplicates = new Map<string, number>();
|
|
53
|
+
for (const [id, c] of counts) if (c > 1) duplicates.set(id, c);
|
|
54
|
+
if (container) {
|
|
55
|
+
container.querySelectorAll('[data-soma-id]').forEach((el) => {
|
|
56
|
+
const id = el.getAttribute('data-soma-id');
|
|
57
|
+
if (id) anchors.add(id);
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
return { anchors, duplicates };
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
findAnchor(root: ParentNode, somaId: string): HTMLElement | null {
|
|
64
|
+
if (this.domBridge) {
|
|
65
|
+
return this.domBridge.querySelector(`[data-soma-id="${somaId}"]`);
|
|
66
|
+
}
|
|
67
|
+
const found = this.findInTree(this.root, somaId);
|
|
68
|
+
if (!found) return null;
|
|
69
|
+
const el = document.createElement('div');
|
|
70
|
+
el.setAttribute('data-soma-id', somaId);
|
|
71
|
+
if (found.text) el.textContent = found.text;
|
|
72
|
+
return el;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
findClosestAnchor(target: EventTarget | null): HTMLElement | null {
|
|
76
|
+
if (target instanceof HTMLElement) {
|
|
77
|
+
return target.closest('[data-soma-id]');
|
|
78
|
+
}
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
getAnchorId(element: HTMLElement): string | null {
|
|
83
|
+
return element.getAttribute('data-soma-id');
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
readRole(element: HTMLElement): string | null {
|
|
87
|
+
return element.getAttribute('data-soma-role');
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
getTemplate(element: HTMLElement): HTMLTemplateElement | null {
|
|
91
|
+
return element.querySelector('template');
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
cloneTemplate(element: HTMLElement): DocumentFragment | null {
|
|
95
|
+
const t = this.getTemplate(element);
|
|
96
|
+
return t ? t.content.cloneNode(true) as DocumentFragment : null;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
clearRenderedChildren(element: HTMLElement): void {
|
|
100
|
+
for (const child of Array.from(element.children)) {
|
|
101
|
+
if (child.tagName !== 'TEMPLATE') child.remove();
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
appendFragment(element: HTMLElement, fragment: DocumentFragment): void {
|
|
106
|
+
element.appendChild(fragment);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
setText(element: HTMLElement, value: string): void {
|
|
110
|
+
element.textContent = value;
|
|
111
|
+
const id = element.getAttribute('data-soma-id');
|
|
112
|
+
if (id) {
|
|
113
|
+
const node = this.findInTree(this.root, id);
|
|
114
|
+
if (node) node.text = value;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
setAttribute(element: HTMLElement, attrName: string, value: string): void {
|
|
119
|
+
element.setAttribute(attrName, value);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
setHtml(element: HTMLElement, value: string): void {
|
|
123
|
+
element.textContent = value;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
setVisibility(element: HTMLElement, visible: boolean): void {
|
|
127
|
+
element.style.display = visible ? '' : 'none';
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
isVisible(element: HTMLElement): boolean {
|
|
131
|
+
return element.style.display !== 'none';
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
toggleClasses(element: HTMLElement, classes: string[], enabled: boolean): void {
|
|
135
|
+
element.classList.toggle(classes.join(' '), enabled);
|
|
136
|
+
if (enabled) element.classList.add(...classes);
|
|
137
|
+
else element.classList.remove(...classes);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
setValue(element: HTMLElement, value: string): void {
|
|
141
|
+
(element as HTMLInputElement).value = value;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
getValue(element: HTMLElement): string {
|
|
145
|
+
return (element as HTMLInputElement).value ?? '';
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
listen(
|
|
149
|
+
element: HTMLElement,
|
|
150
|
+
eventType: string,
|
|
151
|
+
listener: (event: Event) => void,
|
|
152
|
+
signal: AbortSignal,
|
|
153
|
+
): void {
|
|
154
|
+
element.addEventListener(eventType, listener, { signal });
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
confirm(_message: string): boolean {
|
|
158
|
+
return true;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
navigate(url: string): void {
|
|
162
|
+
if (this.navigateHandler) this.navigateHandler(url);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
now(): number {
|
|
166
|
+
return performance.now();
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
getStyleTree(): RNElementNode {
|
|
170
|
+
return this.root;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
private findInTree(node: RNElementNode, somaId: string): RNElementNode | null {
|
|
174
|
+
if (node.somaId === somaId) return node;
|
|
175
|
+
for (const child of node.children) {
|
|
176
|
+
const hit = this.findInTree(child, somaId);
|
|
177
|
+
if (hit) return hit;
|
|
178
|
+
}
|
|
179
|
+
return null;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
private parseHtmlToTree(html: string): RNElementNode {
|
|
183
|
+
const root: RNElementNode = { somaId: null, tag: 'View', props: {}, children: [] };
|
|
184
|
+
for (const m of html.matchAll(/data-soma-id=["']([^"']+)["']/g)) {
|
|
185
|
+
root.children.push({ somaId: m[1], tag: 'Text', props: {}, children: [] });
|
|
186
|
+
}
|
|
187
|
+
return root;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import type { IContainerAdapter, SomaAnchorStats } from './IContainerAdapter';
|
|
2
|
+
|
|
3
|
+
export type { SomaAnchorStats } from './IContainerAdapter';
|
|
4
|
+
|
|
5
|
+
export class SomaContainerAdapter implements IContainerAdapter {
|
|
6
|
+
private navigateHandler: ((url: string) => void) | null = null;
|
|
7
|
+
|
|
8
|
+
/** 注入自定义导航处理器(如 SomaRouter + Next.js 路由) */
|
|
9
|
+
setNavigateHandler(handler: (url: string) => void): void {
|
|
10
|
+
this.navigateHandler = handler;
|
|
11
|
+
}
|
|
5
12
|
|
|
6
|
-
export class SomaContainerAdapter {
|
|
7
13
|
mount(
|
|
8
14
|
container: HTMLElement,
|
|
9
15
|
html: string,
|
|
@@ -107,12 +113,13 @@ export class SomaContainerAdapter {
|
|
|
107
113
|
|
|
108
114
|
setVisibility(element: HTMLElement, visible: boolean): void {
|
|
109
115
|
element.style.display = visible ? '' : 'none';
|
|
116
|
+
element.classList.toggle('hidden', !visible);
|
|
110
117
|
element.classList.toggle('soma-visible', visible);
|
|
111
118
|
element.classList.toggle('soma-hidden', !visible);
|
|
112
119
|
}
|
|
113
120
|
|
|
114
121
|
isVisible(element: HTMLElement): boolean {
|
|
115
|
-
return element.style.display !== 'none';
|
|
122
|
+
return !element.classList.contains('hidden') && element.style.display !== 'none';
|
|
116
123
|
}
|
|
117
124
|
|
|
118
125
|
toggleClasses(element: HTMLElement, classes: string[], enabled: boolean): void {
|
|
@@ -146,6 +153,10 @@ export class SomaContainerAdapter {
|
|
|
146
153
|
}
|
|
147
154
|
|
|
148
155
|
navigate(url: string): void {
|
|
156
|
+
if (this.navigateHandler) {
|
|
157
|
+
this.navigateHandler(url);
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
149
160
|
window.location.href = url;
|
|
150
161
|
}
|
|
151
162
|
|