soma-core 1.0.3 → 1.1.1
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 +12 -49
- package/app/[...path]/page.tsx +21 -0
- package/app/api/[...path]/route.ts +86 -77
- package/app/components/SomaHostPage.tsx +133 -0
- package/app/components/SomaHydrationShell.tsx +1 -1
- package/app/layout.tsx +22 -18
- package/app/page.tsx +7 -18
- package/app/soma/[...path]/route.ts +9 -0
- package/app/{api/soma-manifest → soma/manifest}/route.ts +3 -3
- package/app/soma/page/route.ts +29 -0
- package/app/soma/page-object/route.ts +159 -0
- package/app/soma/route.ts +9 -0
- package/bin/soma-lsp.cjs +5 -5
- package/bin/soma-mock.mjs +38 -0
- package/bin/soma-sync.cjs +1 -1
- package/core/{compiler → build/compiler}/full-manifest-builder.ts +84 -69
- package/core/build/compiler/host-config-sync.cjs +64 -0
- package/core/{compiler → build/compiler}/precompiled-manifest-loader.ts +1 -1
- package/core/{compiler → build/compiler}/rollup-plugin-soma.ts +1 -1
- package/core/{compiler → build/compiler}/route-builder.ts +31 -31
- package/core/{compiler → build/compiler}/soma-manifest-webpack-plugin.js +41 -7
- package/core/{compiler → build/compiler}/soma-precompile.js +8 -8
- package/core/{compiler → build/compiler}/soma-precompile.ts +94 -94
- package/core/{compiler → build/compiler}/soma-webpack-loader.js +41 -41
- package/core/{compiler → build/compiler}/vite-plugin-soma.ts +83 -83
- package/core/{base → client/base}/SomaApi.ts +14 -14
- package/core/{base → client/base}/SomaDict.ts +168 -168
- package/core/{base → client/base}/SomaHttpClient.ts +128 -126
- package/core/{base → client/base}/SomaPageRootBase.ts +71 -71
- package/core/{base → client/base}/SomaValidator.ts +147 -147
- package/core/{compiler → client/compiler}/manifest-compiler.ts +238 -238
- package/core/{engine → client/engine}/asset-resolver.ts +102 -102
- package/core/{engine → client/engine}/dom-renderer.ts +341 -341
- package/core/{engine → client/engine}/event-engine.ts +356 -356
- package/core/{engine → client/engine}/lis.ts +60 -60
- package/core/{engine → client/engine}/on-change-engine.ts +3 -3
- package/core/{engine → client/engine}/property-watcher.ts +2 -2
- package/core/{engine → client/engine}/reactive-proxy.ts +231 -231
- package/core/{engine → client/engine}/render-engine.ts +350 -350
- package/core/{engine → client/engine}/runtime-builder.ts +177 -177
- package/core/{engine → client/engine}/scope-resolver.ts +308 -308
- package/core/{engine → client/engine}/soma-bootstrap.ts +8 -8
- package/core/{engine → client/engine}/style-binder.ts +423 -423
- package/core/{engine → client/engine}/theme-variables.ts +1 -1
- package/core/{engine → client/engine}/timer-engine.ts +3 -3
- package/core/{engine → client/engine}/trigger-engine.ts +2 -2
- package/core/client/host-bridge/index.ts +27 -0
- package/core/client/host-bridge/load-host-domain-class.ts +87 -0
- package/core/client/host-bridge/soma-domain-loaders.stub.ts +6 -0
- package/core/client/host-bridge/soma-domain-loaders.ts +69 -0
- package/core/{infra → client/infra}/http/SomaHttpService.ts +208 -199
- package/core/{parser → client/parser}/annotation-extractor.ts +2 -2
- package/core/{parser → client/parser}/pipeline-parser.ts +3 -3
- package/core/{parser → client/parser}/style-config-parser.ts +340 -340
- package/core/{parser → client/parser}/timer-parser.ts +3 -3
- package/core/{parser → client/parser}/trigger-parser.ts +3 -3
- package/core/{parser → client/parser}/ui-config-parser.ts +408 -408
- package/core/{parser → client/parser}/yaml-loader.ts +36 -36
- package/core/{runtime → client/runtime}/SomaRuntimeServices.ts +5 -1
- package/core/client/runtime/serialize-page-state.ts +152 -0
- package/core/{scheduler → client/scheduler}/SomaScheduler.ts +190 -190
- package/core/{validation → client/validation}/contract-validator.ts +2 -2
- package/core/index.ts +55 -32
- package/core/{api → server/api}/IService.ts +29 -29
- package/core/server/headless/soma-headless-page.ts +103 -0
- package/core/server/host/app-config-composer.ts +90 -0
- package/core/server/host/host-config-paths.cjs +100 -0
- package/core/server/host/host-config-paths.ts +132 -0
- package/core/server/host/invoke-host-request-hook.ts +37 -0
- package/core/server/host/page-response-mode.cjs +96 -0
- package/core/server/host/page-response-request.ts +35 -0
- package/core/server/host/request-origin.ts +18 -0
- package/core/server/host/resolve-host-request-hook.ts +29 -0
- package/core/server/host/server-page-assets.ts +193 -0
- package/core/server/host/soma-request-hook-host.stub.ts +4 -0
- package/core/{host → server/host}/source-packages.ts +46 -5
- package/core/server/index.ts +41 -0
- package/core/{infra → server/infra}/cache/ServerFileCache.ts +123 -123
- package/core/server/infra/db/soma-db.ts +70 -0
- package/core/server/infra/http/soma-server-request-context.ts +126 -0
- package/core/server/mock/node/catch-all.mjs +35 -0
- package/core/server/mock/node/cli.d.mts +58 -0
- package/core/server/mock/node/cli.mjs +243 -0
- package/core/server/mock/node/context.mjs +167 -0
- package/core/server/mock/node/environment-policy.mjs +52 -0
- package/core/server/mock/node/plugin-loader.mjs +212 -0
- package/core/server/mock/node/preload.mjs +91 -0
- package/core/server/mock/node/process-lifecycle.mjs +236 -0
- package/core/server/mock/node/public.d.mts +110 -0
- package/core/server/mock/node/public.mjs +4 -0
- package/core/server/mock/node/registry.mjs +336 -0
- package/core/server/mock/node/schema-generator.mjs +1310 -0
- package/core/server/mock/testing/host-harness.d.mts +66 -0
- package/core/server/mock/testing/host-harness.mjs +276 -0
- package/core/server/mock/testing/host-runtime.mjs +48 -0
- package/core/server/server-only.d.ts +1 -0
- package/core/{types → shared/types}/domain.types.ts +91 -91
- package/dist/cli/soma.js +374 -3
- package/dist/core/index.cjs +2933 -2460
- package/dist/diagnostics/telemetry.cjs +1 -1
- package/dist/tsconfig.types.tsbuildinfo +1 -1
- package/dist/types/{compiler → build/compiler}/full-manifest-builder.d.ts +7 -5
- package/dist/types/{compiler → build/compiler}/precompiled-manifest-loader.d.ts +1 -1
- package/dist/types/{compiler → build/compiler}/soma-precompile.d.ts +5 -5
- package/dist/types/{compiler → build/compiler}/vite-plugin-soma.d.ts +1 -1
- package/dist/types/{base → client/base}/SomaHttpClient.d.ts +2 -0
- package/dist/types/{base → client/base}/SomaPageRootBase.d.ts +1 -1
- package/dist/types/{base → client/base}/SomaValidator.d.ts +1 -1
- package/dist/types/{compiler → client/compiler}/manifest-compiler.d.ts +3 -3
- package/dist/types/{engine → client/engine}/dom-renderer.d.ts +2 -2
- package/dist/types/{engine → client/engine}/event-engine.d.ts +1 -1
- package/dist/types/{engine → client/engine}/on-change-engine.d.ts +1 -1
- package/dist/types/{engine → client/engine}/property-watcher.d.ts +1 -1
- package/dist/types/{engine → client/engine}/render-engine.d.ts +3 -3
- package/dist/types/{engine → client/engine}/runtime-builder.d.ts +5 -5
- package/dist/types/{engine → client/engine}/scope-resolver.d.ts +1 -1
- package/dist/types/{engine → client/engine}/soma-bootstrap.d.ts +7 -7
- package/dist/types/{engine → client/engine}/style-binder.d.ts +1 -1
- package/dist/types/{engine → client/engine}/theme-variables.d.ts +1 -1
- package/dist/types/{engine → client/engine}/timer-engine.d.ts +1 -1
- package/dist/types/{engine → client/engine}/trigger-engine.d.ts +1 -1
- package/dist/types/client/host-bridge/index.d.ts +9 -0
- package/dist/types/client/host-bridge/load-host-domain-class.d.ts +12 -0
- package/dist/types/client/host-bridge/soma-domain-loaders.d.ts +19 -0
- package/dist/types/client/host-bridge/soma-domain-loaders.stub.d.ts +4 -0
- package/dist/types/{infra → client/infra}/http/SomaHttpService.d.ts +3 -1
- package/dist/types/{parser → client/parser}/annotation-extractor.d.ts +2 -2
- package/dist/types/{parser → client/parser}/pipeline-parser.d.ts +1 -1
- package/dist/types/{parser → client/parser}/style-config-parser.d.ts +1 -1
- package/dist/types/{parser → client/parser}/timer-parser.d.ts +2 -2
- package/dist/types/{parser → client/parser}/trigger-parser.d.ts +2 -2
- package/dist/types/{parser → client/parser}/ui-config-parser.d.ts +1 -1
- package/dist/types/client/runtime/serialize-page-state.d.ts +10 -0
- package/dist/types/{scheduler → client/scheduler}/SomaScheduler.d.ts +1 -1
- package/dist/types/{validation → client/validation}/contract-validator.d.ts +2 -2
- package/dist/types/index.d.ts +35 -32
- package/dist/types/{api → server/api}/IService.d.ts +1 -1
- package/dist/types/server/headless/soma-headless-page.d.ts +12 -0
- package/dist/types/server/host/app-config-composer.d.ts +6 -0
- package/dist/types/server/host/host-config-paths.d.ts +23 -0
- package/dist/types/server/host/invoke-host-request-hook.d.ts +8 -0
- package/dist/types/server/host/page-response-request.d.ts +9 -0
- package/dist/types/server/host/request-origin.d.ts +1 -0
- package/dist/types/server/host/resolve-host-request-hook.d.ts +16 -0
- package/dist/types/server/host/server-page-assets.d.ts +29 -0
- package/dist/types/server/host/soma-request-hook-host.stub.d.ts +2 -0
- package/dist/types/server/host/source-packages.d.ts +12 -0
- package/dist/types/server/index.d.ts +19 -0
- package/dist/types/server/infra/db/soma-db.d.ts +31 -0
- package/dist/types/server/infra/http/soma-server-request-context.d.ts +5 -0
- package/dist/types/{types → shared/types}/domain.types.d.ts +1 -1
- package/docs//345/256/242/346/210/267/347/253/257/346/234/215/345/212/241/347/253/257/351/232/224/347/246/273/346/226/271/346/241/210.md +399 -0
- package/docs//351/232/224/347/246/273/346/216/245/345/205/245/345/217/230/346/233/264/346/226/271/346/241/210.md +250 -0
- package/docs//351/241/265/351/235/242JSON/346/250/241/345/274/217/346/216/245/345/205/245/346/214/207/345/215/227.md +141 -0
- package/global.d.ts +67 -26
- package/middleware.ts +33 -0
- package/next.config.js +116 -30
- package/package.json +59 -21
- package/tailwind.config.ts +24 -24
- package/tsconfig.json +1 -5
- package/app/api/page/route.ts +0 -119
- package/app/loading.tsx +0 -5
- package/core/compiler/host-config-sync.cjs +0 -38
- package/dist/types/host/source-packages.d.ts +0 -8
- /package/core/{compiler → build/compiler}/page-base-resolver.ts +0 -0
- /package/core/{compiler → build/compiler}/rspack-plugin-soma.js +0 -0
- /package/core/{compiler → build/compiler}/soma-rspack-yaml-loader.js +0 -0
- /package/core/{lsp → build/lsp}/cross-file-diagnostics.cjs +0 -0
- /package/core/{lsp → build/lsp}/event-yaml-completion.cjs +0 -0
- /package/core/{lsp → build/lsp}/extra-completion.cjs +0 -0
- /package/core/{lsp → build/lsp}/lsp-navigation.cjs +0 -0
- /package/core/{lsp → build/lsp}/ui-yaml-completion.cjs +0 -0
- /package/core/{base → client/base}/SomaEntity.ts +0 -0
- /package/core/{base → client/base}/SomaLocaleOnlyPageRoot.ts +0 -0
- /package/core/{base → client/base}/decorators/Event.ts +0 -0
- /package/core/{base → client/base}/decorators/Locale.ts +0 -0
- /package/core/{base → client/base}/decorators/Page.ts +0 -0
- /package/core/{base → client/base}/decorators/Show.ts +0 -0
- /package/core/{base → client/base}/decorators/ShowList.ts +0 -0
- /package/core/{base → client/base}/decorators/index.ts +0 -0
- /package/core/{base → client/base}/index.ts +0 -0
- /package/core/{base → client/base}/runAsync.ts +0 -0
- /package/core/{container → client/container}/IContainerAdapter.ts +0 -0
- /package/core/{container → client/container}/MiniProgramContainerAdapter.ts +0 -0
- /package/core/{container → client/container}/ReactNativeContainerAdapter.ts +0 -0
- /package/core/{container → client/container}/SomaContainerAdapter.ts +0 -0
- /package/core/{diagnostics → client/diagnostics}/SomaDiagnostics.ts +0 -0
- /package/core/{diagnostics → client/diagnostics}/SomaTelemetry.ts +0 -0
- /package/core/{diagnostics → client/diagnostics}/telemetry-context.ts +0 -0
- /package/core/{host → client/host-bridge}/resolve-host-bootstrap.ts +0 -0
- /package/core/{host → client/host-bridge}/soma-bootstrap-host.stub.ts +0 -0
- /package/core/{infra → client/infra}/auth/IAuthService.ts +0 -0
- /package/core/{infra → client/infra}/auth/TokenAuthService.ts +0 -0
- /package/core/{infra → client/infra}/cache/ICache.ts +0 -0
- /package/core/{infra → client/infra}/cache/MemoryCache.ts +0 -0
- /package/core/{infra → client/infra}/config/IConfig.ts +0 -0
- /package/core/{infra → client/infra}/config/SomaConfig.ts +0 -0
- /package/core/{infra → client/infra}/event-bus/IEventBus.ts +0 -0
- /package/core/{infra → client/infra}/event-bus/SomaEventBus.ts +0 -0
- /package/core/{infra → client/infra}/http/IHttpClient.ts +0 -0
- /package/core/{infra → client/infra}/i18n/DefaultI18n.ts +0 -0
- /package/core/{infra → client/infra}/i18n/II18n.ts +0 -0
- /package/core/{infra → client/infra}/logger/ConsoleLogger.ts +0 -0
- /package/core/{infra → client/infra}/logger/ILogger.ts +0 -0
- /package/core/{infra → client/infra}/notify/DefaultNotifyService.ts +0 -0
- /package/core/{infra → client/infra}/notify/DomNotifyService.ts +0 -0
- /package/core/{infra → client/infra}/notify/INotifyService.ts +0 -0
- /package/core/{infra → client/infra}/notify/INotifyTheme.ts +0 -0
- /package/core/{infra → client/infra}/permission/IPermission.ts +0 -0
- /package/core/{infra → client/infra}/permission/SomaPermission.ts +0 -0
- /package/core/{infra → client/infra}/realtime/IRealtimeService.ts +0 -0
- /package/core/{infra → client/infra}/realtime/IRealtimeTransport.ts +0 -0
- /package/core/{infra → client/infra}/realtime/SomaRealtimeService.ts +0 -0
- /package/core/{infra → client/infra}/realtime/SseRealtimeTransport.ts +0 -0
- /package/core/{infra → client/infra}/realtime/WebSocketRealtimeTransport.ts +0 -0
- /package/core/{infra → client/infra}/router/IRouter.ts +0 -0
- /package/core/{infra → client/infra}/router/SomaRouter.ts +0 -0
- /package/core/{infra → client/infra}/router/router-path.ts +0 -0
- /package/core/{infra → client/infra}/storage/IStorageService.ts +0 -0
- /package/core/{infra → client/infra}/storage/MemoryStorageService.ts +0 -0
- /package/core/{infra → client/infra}/storage/SessionStorageService.ts +0 -0
- /package/core/{infra → client/infra}/timer/ITimer.ts +0 -0
- /package/core/{infra → client/infra}/timer/SomaTimer.ts +0 -0
- /package/core/{middleware → client/middleware}/SomaMiddlewareChain.ts +0 -0
- /package/core/{middleware → client/middleware}/createPermissionMiddleware.ts +0 -0
- /package/core/{quality → client/quality}/SomaQualityRegistry.ts +0 -0
- /package/core/{runtime → client/runtime}/SomaSnapshotStore.ts +0 -0
- /package/core/{api → server/api}/load-host-service.ts +0 -0
- /package/core/{api → server/api}/service-path.ts +0 -0
- /package/core/{host → server/host}/app-config.stub.ts +0 -0
- /package/core/{host → server/host}/locale.stub.ts +0 -0
- /package/core/{manifest → shared/manifest}/manifest-contract.ts +0 -0
- /package/core/{types → shared/types}/engine.types.ts +0 -0
- /package/core/{types → shared/types}/event.types.ts +0 -0
- /package/core/{types → shared/types}/keyboard.types.ts +0 -0
- /package/core/{types → shared/types}/manifest.types.ts +0 -0
- /package/core/{types → shared/types}/scheduler.types.ts +0 -0
- /package/core/{types → shared/types}/style-config.types.ts +0 -0
- /package/core/{types → shared/types}/timer.types.ts +0 -0
- /package/core/{types → shared/types}/trigger.types.ts +0 -0
- /package/core/{types → shared/types}/ui-config.types.ts +0 -0
- /package/core/{types → shared/types}/watcher.types.ts +0 -0
- /package/dist/types/{compiler → build/compiler}/page-base-resolver.d.ts +0 -0
- /package/dist/types/{compiler → build/compiler}/rollup-plugin-soma.d.ts +0 -0
- /package/dist/types/{compiler → build/compiler}/route-builder.d.ts +0 -0
- /package/dist/types/{base → client/base}/SomaApi.d.ts +0 -0
- /package/dist/types/{base → client/base}/SomaDict.d.ts +0 -0
- /package/dist/types/{base → client/base}/SomaEntity.d.ts +0 -0
- /package/dist/types/{base → client/base}/SomaLocaleOnlyPageRoot.d.ts +0 -0
- /package/dist/types/{base → client/base}/decorators/Event.d.ts +0 -0
- /package/dist/types/{base → client/base}/decorators/Locale.d.ts +0 -0
- /package/dist/types/{base → client/base}/decorators/Page.d.ts +0 -0
- /package/dist/types/{base → client/base}/decorators/Show.d.ts +0 -0
- /package/dist/types/{base → client/base}/decorators/ShowList.d.ts +0 -0
- /package/dist/types/{base → client/base}/decorators/index.d.ts +0 -0
- /package/dist/types/{base → client/base}/index.d.ts +0 -0
- /package/dist/types/{base → client/base}/runAsync.d.ts +0 -0
- /package/dist/types/{container → client/container}/IContainerAdapter.d.ts +0 -0
- /package/dist/types/{container → client/container}/MiniProgramContainerAdapter.d.ts +0 -0
- /package/dist/types/{container → client/container}/ReactNativeContainerAdapter.d.ts +0 -0
- /package/dist/types/{container → client/container}/SomaContainerAdapter.d.ts +0 -0
- /package/dist/types/{diagnostics → client/diagnostics}/SomaDiagnostics.d.ts +0 -0
- /package/dist/types/{diagnostics → client/diagnostics}/SomaTelemetry.d.ts +0 -0
- /package/dist/types/{diagnostics → client/diagnostics}/telemetry-context.d.ts +0 -0
- /package/dist/types/{engine → client/engine}/asset-resolver.d.ts +0 -0
- /package/dist/types/{engine → client/engine}/lis.d.ts +0 -0
- /package/dist/types/{engine → client/engine}/reactive-proxy.d.ts +0 -0
- /package/dist/types/{host → client/host-bridge}/resolve-host-bootstrap.d.ts +0 -0
- /package/dist/types/{host → client/host-bridge}/soma-bootstrap-host.stub.d.ts +0 -0
- /package/dist/types/{infra → client/infra}/auth/IAuthService.d.ts +0 -0
- /package/dist/types/{infra → client/infra}/auth/TokenAuthService.d.ts +0 -0
- /package/dist/types/{infra → client/infra}/cache/ICache.d.ts +0 -0
- /package/dist/types/{infra → client/infra}/cache/MemoryCache.d.ts +0 -0
- /package/dist/types/{infra → client/infra}/config/IConfig.d.ts +0 -0
- /package/dist/types/{infra → client/infra}/config/SomaConfig.d.ts +0 -0
- /package/dist/types/{infra → client/infra}/event-bus/IEventBus.d.ts +0 -0
- /package/dist/types/{infra → client/infra}/event-bus/SomaEventBus.d.ts +0 -0
- /package/dist/types/{infra → client/infra}/http/IHttpClient.d.ts +0 -0
- /package/dist/types/{infra → client/infra}/i18n/DefaultI18n.d.ts +0 -0
- /package/dist/types/{infra → client/infra}/i18n/II18n.d.ts +0 -0
- /package/dist/types/{infra → client/infra}/logger/ConsoleLogger.d.ts +0 -0
- /package/dist/types/{infra → client/infra}/logger/ILogger.d.ts +0 -0
- /package/dist/types/{infra → client/infra}/notify/DefaultNotifyService.d.ts +0 -0
- /package/dist/types/{infra → client/infra}/notify/DomNotifyService.d.ts +0 -0
- /package/dist/types/{infra → client/infra}/notify/INotifyService.d.ts +0 -0
- /package/dist/types/{infra → client/infra}/notify/INotifyTheme.d.ts +0 -0
- /package/dist/types/{infra → client/infra}/permission/IPermission.d.ts +0 -0
- /package/dist/types/{infra → client/infra}/permission/SomaPermission.d.ts +0 -0
- /package/dist/types/{infra → client/infra}/realtime/IRealtimeService.d.ts +0 -0
- /package/dist/types/{infra → client/infra}/realtime/IRealtimeTransport.d.ts +0 -0
- /package/dist/types/{infra → client/infra}/realtime/SomaRealtimeService.d.ts +0 -0
- /package/dist/types/{infra → client/infra}/realtime/SseRealtimeTransport.d.ts +0 -0
- /package/dist/types/{infra → client/infra}/realtime/WebSocketRealtimeTransport.d.ts +0 -0
- /package/dist/types/{infra → client/infra}/router/IRouter.d.ts +0 -0
- /package/dist/types/{infra → client/infra}/router/SomaRouter.d.ts +0 -0
- /package/dist/types/{infra → client/infra}/router/router-path.d.ts +0 -0
- /package/dist/types/{infra → client/infra}/storage/IStorageService.d.ts +0 -0
- /package/dist/types/{infra → client/infra}/storage/MemoryStorageService.d.ts +0 -0
- /package/dist/types/{infra → client/infra}/storage/SessionStorageService.d.ts +0 -0
- /package/dist/types/{infra → client/infra}/timer/ITimer.d.ts +0 -0
- /package/dist/types/{infra → client/infra}/timer/SomaTimer.d.ts +0 -0
- /package/dist/types/{middleware → client/middleware}/SomaMiddlewareChain.d.ts +0 -0
- /package/dist/types/{middleware → client/middleware}/createPermissionMiddleware.d.ts +0 -0
- /package/dist/types/{parser → client/parser}/yaml-loader.d.ts +0 -0
- /package/dist/types/{quality → client/quality}/SomaQualityRegistry.d.ts +0 -0
- /package/dist/types/{runtime → client/runtime}/SomaRuntimeServices.d.ts +0 -0
- /package/dist/types/{runtime → client/runtime}/SomaSnapshotStore.d.ts +0 -0
- /package/dist/types/{api → server/api}/load-host-service.d.ts +0 -0
- /package/dist/types/{api → server/api}/service-path.d.ts +0 -0
- /package/dist/types/{host → server/host}/app-config.stub.d.ts +0 -0
- /package/dist/types/{host → server/host}/locale.stub.d.ts +0 -0
- /package/dist/types/{infra → server/infra}/cache/ServerFileCache.d.ts +0 -0
- /package/dist/types/{manifest → shared/manifest}/manifest-contract.d.ts +0 -0
- /package/dist/types/{types → shared/types}/engine.types.d.ts +0 -0
- /package/dist/types/{types → shared/types}/event.types.d.ts +0 -0
- /package/dist/types/{types → shared/types}/keyboard.types.d.ts +0 -0
- /package/dist/types/{types → shared/types}/manifest.types.d.ts +0 -0
- /package/dist/types/{types → shared/types}/scheduler.types.d.ts +0 -0
- /package/dist/types/{types → shared/types}/style-config.types.d.ts +0 -0
- /package/dist/types/{types → shared/types}/timer.types.d.ts +0 -0
- /package/dist/types/{types → shared/types}/trigger.types.d.ts +0 -0
- /package/dist/types/{types → shared/types}/ui-config.types.d.ts +0 -0
- /package/dist/types/{types → shared/types}/watcher.types.d.ts +0 -0
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
# soma-core 客户端/服务端隔离 — 接入变更方案
|
|
2
|
+
|
|
3
|
+
状态:全量拆分已落地(无兼容 re-export)。公开 `package.json` exports 名称不变;深路径对照见下文。
|
|
4
|
+
|
|
5
|
+
**策略:不保留兼容 re-export。**
|
|
6
|
+
旧深路径直接删除或迁走,不在原处留转发层,避免长期垃圾。
|
|
7
|
+
对使用方的「少改动」靠 **公开 `package.json` exports 稳定** + **本文路径对照表** 解决,不靠门牌兼容。
|
|
8
|
+
|
|
9
|
+
关联设计:[客户端服务端隔离方案](./客户端服务端隔离方案.md)
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## 1. 结论
|
|
14
|
+
|
|
15
|
+
| 角色 | 要不要改 |
|
|
16
|
+
|------|----------|
|
|
17
|
+
| 按官方文档写的 Host(只用 `soma-core` / `soma-core/base` / mock / testing) | **不用改业务代码** |
|
|
18
|
+
| Host 目录约定(`html/ui/event/domain/api/service/config/mock`) | **不用改** |
|
|
19
|
+
| CLI(`soma` / `soma-mock` / `soma-lsp`) | **不用改** |
|
|
20
|
+
| 引用了未文档化深路径(如 `core/infra/...`、仓库内 `@core/host/...`) | **要改**,按本文对照表替换 |
|
|
21
|
+
| 需要服务端标准能力(文件缓存、request context、未来 db) | **改用** `soma-core/server`(加法) |
|
|
22
|
+
|
|
23
|
+
原则:公开入口继续可用;内部结构一次拆干净;变更靠文档,不靠兼容层。
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## 2. 目标目录(拆分后)
|
|
28
|
+
|
|
29
|
+
全部落在 `soma-core/core/` 下(单包多区,不拆 npm 包):
|
|
30
|
+
|
|
31
|
+
```text
|
|
32
|
+
core/
|
|
33
|
+
├── client/ # 可进浏览器编译图
|
|
34
|
+
│ ├── base/
|
|
35
|
+
│ ├── engine/ # 不含 headless
|
|
36
|
+
│ ├── runtime/
|
|
37
|
+
│ ├── infra/ # 仅浏览器安全 _services
|
|
38
|
+
│ ├── container/
|
|
39
|
+
│ ├── middleware/
|
|
40
|
+
│ ├── scheduler/
|
|
41
|
+
│ ├── quality/
|
|
42
|
+
│ ├── diagnostics/
|
|
43
|
+
│ ├── parser/ # 引擎运行时依赖
|
|
44
|
+
│ ├── validation/
|
|
45
|
+
│ ├── compiler/ # 仅 manifest-compiler(运行时)
|
|
46
|
+
│ └── host-bridge/ # Domain 加载、bootstrap 解析(客户端)
|
|
47
|
+
│
|
|
48
|
+
├── server/ # 禁止进浏览器
|
|
49
|
+
│ ├── api/
|
|
50
|
+
│ ├── host/ # 读盘、page assets、request hook…
|
|
51
|
+
│ ├── infra/ # ServerFileCache、server request context
|
|
52
|
+
│ ├── mock/
|
|
53
|
+
│ ├── headless/
|
|
54
|
+
│ └── index.ts # soma-core/server(server-only)
|
|
55
|
+
│
|
|
56
|
+
├── shared/ # 前后端都可依赖
|
|
57
|
+
│ ├── types/
|
|
58
|
+
│ └── manifest/
|
|
59
|
+
│
|
|
60
|
+
├── build/ # 仅构建 / CLI / LSP
|
|
61
|
+
│ ├── compiler/ # webpack/vite/precompile 等
|
|
62
|
+
│ └── lsp/
|
|
63
|
+
│
|
|
64
|
+
└── index.ts # 包根:公开、浏览器安全 API
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
**不做:** 在旧路径 `core/base`、`core/infra`、`core/host`… 留空壳 `export * from '../client/...'`。
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## 3. 公开包导出(使用方稳定面)
|
|
72
|
+
|
|
73
|
+
拆分后 `package.json` exports **名称不变**,只改内部指向:
|
|
74
|
+
|
|
75
|
+
| 导出 | 用途 | 拆分后指向 |
|
|
76
|
+
|------|------|------------|
|
|
77
|
+
| `soma-core` | `IService` 类型、Bootstrap、runtime 等(文档约定子集) | `core/index.ts`(聚合 client + shared 类型;不导出 Node 实现) |
|
|
78
|
+
| `soma-core/base` | Domain 基类 | `core/client/base` |
|
|
79
|
+
| `soma-core/server` | 服务端能力 | `core/server`(已有,`server-only`) |
|
|
80
|
+
| `soma-core/host/request-hook` | 服务端 Hook resolver | `core/server/host/resolve-host-request-hook` |
|
|
81
|
+
| `soma-core/mock/node` | Mock | `core/server/mock/node` |
|
|
82
|
+
| `soma-core/mock/node/cli` | Mock CLI | `core/server/mock/node/cli` |
|
|
83
|
+
| `soma-core/testing/mock-host` | 测试 Host | `core/server/mock/testing` |
|
|
84
|
+
| `soma-core/compiler/vite` | Vite 插件 | `core/build/compiler/vite-plugin-soma` |
|
|
85
|
+
| `soma-core/compiler/webpack-loader` | Webpack loader | `core/build/compiler/soma-webpack-loader` |
|
|
86
|
+
| `soma-core/diagnostics` | 诊断 | `core/client/diagnostics/...` |
|
|
87
|
+
|
|
88
|
+
因此:文档里的这些写法 **拆分后仍然有效,业务侧零改**:
|
|
89
|
+
|
|
90
|
+
```ts
|
|
91
|
+
import { SomaPageRootBase } from 'soma-core/base';
|
|
92
|
+
import type { IService } from 'soma-core';
|
|
93
|
+
import { http, HttpResponse } from 'soma-core/mock/node';
|
|
94
|
+
import { startMockHost } from 'soma-core/testing/mock-host';
|
|
95
|
+
import { resolveHostRequestHook } from 'soma-core/host/request-hook';
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
可选加法(服务端):
|
|
99
|
+
|
|
100
|
+
```ts
|
|
101
|
+
import { ServerFileCache, withSomaServerRequestContext } from 'soma-core/server';
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### DB(服务端可选)
|
|
105
|
+
|
|
106
|
+
框架只提供注册/单例,**不绑死 Prisma 依赖**。Schema 与查询仍在 Host。
|
|
107
|
+
|
|
108
|
+
```ts
|
|
109
|
+
// Host: lib/db.ts(仅服务端)
|
|
110
|
+
import { PrismaClient } from '@prisma/client';
|
|
111
|
+
import { createSomaDbSingleton } from 'soma-core/server';
|
|
112
|
+
|
|
113
|
+
export const db = createSomaDbSingleton(() => new PrismaClient());
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
```ts
|
|
117
|
+
// Host: api/service/orders/List.ts
|
|
118
|
+
import type { IService } from 'soma-core';
|
|
119
|
+
import { getSomaDb } from 'soma-core/server';
|
|
120
|
+
import type { PrismaClient } from '@prisma/client';
|
|
121
|
+
|
|
122
|
+
export default class OrdersListService implements IService {
|
|
123
|
+
async get() {
|
|
124
|
+
const db = getSomaDb<PrismaClient>();
|
|
125
|
+
return Response.json(await db.order.findMany());
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
不要:`_services.db`、Domain 里 import `soma-core/server`。
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
## 4. 路径对照表(有深路径才需要改)
|
|
135
|
+
|
|
136
|
+
仅当代码写了旧物理路径或 `@core/<旧目录>/...` 时使用。
|
|
137
|
+
|
|
138
|
+
### 4.1 → `core/client/`
|
|
139
|
+
|
|
140
|
+
| 旧路径 | 新路径 |
|
|
141
|
+
|--------|--------|
|
|
142
|
+
| `core/base/**` | `core/client/base/**` |
|
|
143
|
+
| `core/engine/**`(除 headless) | `core/client/engine/**` |
|
|
144
|
+
| `core/runtime/**` | `core/client/runtime/**` |
|
|
145
|
+
| `core/infra/**`(浏览器安全实现) | `core/client/infra/**` |
|
|
146
|
+
| `core/container/**` | `core/client/container/**` |
|
|
147
|
+
| `core/middleware/**` | `core/client/middleware/**` |
|
|
148
|
+
| `core/scheduler/**` | `core/client/scheduler/**` |
|
|
149
|
+
| `core/quality/**` | `core/client/quality/**` |
|
|
150
|
+
| `core/diagnostics/**` | `core/client/diagnostics/**` |
|
|
151
|
+
| `core/parser/**` | `core/client/parser/**`(引擎运行时依赖,故不在 build) |
|
|
152
|
+
| `core/validation/**` | `core/client/validation/**` |
|
|
153
|
+
| `core/compiler/manifest-compiler.ts` | `core/client/compiler/manifest-compiler.ts` |
|
|
154
|
+
| `core/host/load-host-domain-class.ts` 等 bridge | `core/client/host-bridge/**` |
|
|
155
|
+
|
|
156
|
+
### 4.2 → `core/server/`
|
|
157
|
+
|
|
158
|
+
| 旧路径 | 新路径 |
|
|
159
|
+
|--------|--------|
|
|
160
|
+
| `core/api/**` | `core/server/api/**` |
|
|
161
|
+
| `core/host/**`(读盘、hook、assets…) | `core/server/host/**` |
|
|
162
|
+
| `core/infra/cache/ServerFileCache.ts` | `core/server/infra/cache/ServerFileCache.ts` |
|
|
163
|
+
| `core/infra/http/soma-server-request-context.ts` | `core/server/infra/http/soma-server-request-context.ts` |
|
|
164
|
+
| `core/mock/**` | `core/server/mock/**` |
|
|
165
|
+
| `core/engine/soma-headless-page.ts` | `core/server/headless/soma-headless-page.ts` |
|
|
166
|
+
|
|
167
|
+
### 4.3 → `core/shared/`
|
|
168
|
+
|
|
169
|
+
| 旧路径 | 新路径 |
|
|
170
|
+
|--------|--------|
|
|
171
|
+
| `core/types/**` | `core/shared/types/**` |
|
|
172
|
+
| `core/manifest/**` | `core/shared/manifest/**` |
|
|
173
|
+
|
|
174
|
+
### 4.4 → `core/build/`
|
|
175
|
+
|
|
176
|
+
| 旧路径 | 新路径 |
|
|
177
|
+
|--------|--------|
|
|
178
|
+
| `core/compiler/**`(除 manifest-compiler) | `core/build/compiler/**` |
|
|
179
|
+
| `core/lsp/**` | `core/build/lsp/**` |
|
|
180
|
+
|
|
181
|
+
### 4.5 `@core` 别名(仓库内)
|
|
182
|
+
|
|
183
|
+
`tsconfig` 的 `@core/*` → `./core/*` 可继续,但子路径要跟新目录:
|
|
184
|
+
|
|
185
|
+
```text
|
|
186
|
+
@core/base/... → @core/client/base/...
|
|
187
|
+
@core/engine/... → @core/client/engine/...
|
|
188
|
+
@core/host/... → @core/server/host/... 或 @core/client/host-bridge/...
|
|
189
|
+
@core/api/... → @core/server/api/...
|
|
190
|
+
@core/types/... → @core/shared/types/...
|
|
191
|
+
@core/compiler/... → @core/build/compiler/...
|
|
192
|
+
@core/infra/http/SomaHttpService → @core/client/infra/http/SomaHttpService
|
|
193
|
+
@core/infra/cache/ServerFileCache → @core/server/infra/cache/ServerFileCache
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
也可增加更短的 path mapping(可选,非必须):
|
|
197
|
+
|
|
198
|
+
```json
|
|
199
|
+
"@core/client/*": ["./core/client/*"],
|
|
200
|
+
"@core/server/*": ["./core/server/*"],
|
|
201
|
+
"@core/shared/*": ["./core/shared/*"],
|
|
202
|
+
"@core/build/*": ["./core/build/*"]
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
---
|
|
206
|
+
|
|
207
|
+
## 5. 使用方自检清单
|
|
208
|
+
|
|
209
|
+
升级拆分版本后,在 Host 根目录:
|
|
210
|
+
|
|
211
|
+
1. 搜索是否出现未文档化深路径:
|
|
212
|
+
- `soma-core/core/`
|
|
213
|
+
- `node_modules/soma-core/core/infra`
|
|
214
|
+
- `node_modules/soma-core/core/host`
|
|
215
|
+
2. 确认 Domain 只用 `soma-core/base`,不要 `import 'soma-core/server'`。
|
|
216
|
+
3. `api/service` 若需要框架服务端工具,改为 `soma-core/server`。
|
|
217
|
+
4. `npm run build` / `soma build` 通过即可。
|
|
218
|
+
|
|
219
|
+
按 [业务应用接入指南](../../external-docs/业务应用接入指南.md) 与 [业务应用测试指南](../../external-docs/业务应用测试指南.md) 编写的项目,预期 **0 处业务改动**。
|
|
220
|
+
|
|
221
|
+
---
|
|
222
|
+
|
|
223
|
+
## 6. 框架仓库内改造清单(维护者)
|
|
224
|
+
|
|
225
|
+
全量拆分时一次性做完,**删除**现有临时兼容 re-export:
|
|
226
|
+
|
|
227
|
+
1. 物理搬家到 §2 目录。
|
|
228
|
+
2. 改所有内部 import(`app/`、`tests/`、`bin/`、`next.config.js`、`global.d.ts`)。
|
|
229
|
+
3. 更新 `package.json` exports 指向新文件;**不**在旧路径留转发。
|
|
230
|
+
4. 删除 Phase 1–3 留下的旧路径 re-export 文件(如仍指向 server 的 `core/infra/cache/ServerFileCache.ts` 外壳等)。
|
|
231
|
+
5. `SomaPageClient` 只允许依赖 `core/client/**` + `core/shared/**`。
|
|
232
|
+
6. 强化 `npm run verify:client-boundary`:校验客户端入口依赖图不含 `core/server`、`node:fs`、`jiti`、`server-only`。
|
|
233
|
+
7. 跑 vitest / mock 契约 / 最小 Host `soma build`。
|
|
234
|
+
|
|
235
|
+
---
|
|
236
|
+
|
|
237
|
+
## 7. 明确不做的事
|
|
238
|
+
|
|
239
|
+
- 不在旧目录留 `export { X } from '../client/...'` 兼容层。
|
|
240
|
+
- 不承诺未文档化深路径继续可用。
|
|
241
|
+
- 不把 DB 挂进 `_services` 或 `soma-core` 根入口。
|
|
242
|
+
- 不要求使用方为了隔离去改 Host 目录结构。
|
|
243
|
+
|
|
244
|
+
---
|
|
245
|
+
|
|
246
|
+
## 8. 一句话
|
|
247
|
+
|
|
248
|
+
> 公开 import 名不变 → 正规 Host 不用改。
|
|
249
|
+
> 目录一次拆干净 → 不留兼容垃圾。
|
|
250
|
+
> 有人用了深路径 → 按本文对照表改,改完即止。
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
# SOMA 页面 JSON 模式接入指南
|
|
2
|
+
|
|
3
|
+
## 1. 用途
|
|
4
|
+
|
|
5
|
+
页面 JSON 模式用于自动化测试。它让测试程序继续访问原来的页面 URL,但不挂载或渲染 HTML,而是在页面 Domain 完成初始化后直接返回 JSON 状态。
|
|
6
|
+
|
|
7
|
+
该模式适合:
|
|
8
|
+
|
|
9
|
+
- 对页面初始化数据做字段级断言。
|
|
10
|
+
- 对 Domain onMount 调用 BFF 后的结果做快照测试。
|
|
11
|
+
- 在不依赖 DOM 选择器和浏览器渲染时序的情况下验证页面业务状态。
|
|
12
|
+
|
|
13
|
+
该模式不是 DOM 模拟器,不执行样式绑定、浏览器事件、声明式定时器或 HTML 渲染。
|
|
14
|
+
|
|
15
|
+
## 2. App 开启方式
|
|
16
|
+
|
|
17
|
+
在 App 的测试环境配置中增加:
|
|
18
|
+
|
|
19
|
+
# config/app.config.test.yaml
|
|
20
|
+
soma:
|
|
21
|
+
pageResponseMode: json
|
|
22
|
+
|
|
23
|
+
未声明该字段或声明为 html 时,SOMA 保持普通 HTML 渲染。
|
|
24
|
+
|
|
25
|
+
配置约束:
|
|
26
|
+
|
|
27
|
+
- pageResponseMode 只接受 html 或 json。
|
|
28
|
+
- json 只允许 SOMA test 环境使用。
|
|
29
|
+
- 在生产环境配置 json 会在 Next 配置加载阶段直接失败。
|
|
30
|
+
- 修改配置后需要重启 dev 服务;已经构建的服务需要重新 build。
|
|
31
|
+
|
|
32
|
+
Host App 会保留项目根目录作为 soma-core 的 Host 根,并传递 SOMA_ENV,因此业务 App 不需要维护生成 Host 中的配置副本。
|
|
33
|
+
|
|
34
|
+
## 3. 请求范围
|
|
35
|
+
|
|
36
|
+
JSON 模式会处理以下 GET 或 HEAD 页面请求:
|
|
37
|
+
|
|
38
|
+
| 请求 | 对应页面 |
|
|
39
|
+
| --- | --- |
|
|
40
|
+
| / | index.html |
|
|
41
|
+
| /demo | demo.html 或 demo/index.html |
|
|
42
|
+
| /demo/index | demo/index.html |
|
|
43
|
+
| /demo/index.html | demo/index.html |
|
|
44
|
+
|
|
45
|
+
以下路径不进入页面 JSON 模式:
|
|
46
|
+
|
|
47
|
+
- /api/**
|
|
48
|
+
- /soma/**
|
|
49
|
+
- /_next/**
|
|
50
|
+
- favicon.ico
|
|
51
|
+
- JS、CSS、图片、字体等非 HTML 静态资源
|
|
52
|
+
|
|
53
|
+
## 4. 成功响应
|
|
54
|
+
|
|
55
|
+
成功响应为 HTTP 200、application/json,并带有:
|
|
56
|
+
|
|
57
|
+
Cache-Control: no-store
|
|
58
|
+
X-Content-Type-Options: nosniff
|
|
59
|
+
|
|
60
|
+
响应体直接是页面对象状态,不增加 data 或 page 包装层:
|
|
61
|
+
|
|
62
|
+
{
|
|
63
|
+
"title": "业务接口联调",
|
|
64
|
+
"items": [],
|
|
65
|
+
"pageLoading": false,
|
|
66
|
+
"lastErrorMessage": ""
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
Core 会为每次页面请求创建新的 Domain 实例,依次完成:
|
|
70
|
+
|
|
71
|
+
1. 注入 locale、app config、router 和运行时服务。
|
|
72
|
+
2. 应用 UI YAML 中的 initProps。
|
|
73
|
+
3. 等待 Domain onMount 完成。
|
|
74
|
+
4. 序列化当前状态。
|
|
75
|
+
5. 调用 onUnmount 清理资源。
|
|
76
|
+
|
|
77
|
+
## 5. 精确控制 JSON 字段
|
|
78
|
+
|
|
79
|
+
未声明 toJSON 时,Core 返回 Domain 的可序列化字段和 getter 值,并排除以下内容:
|
|
80
|
+
|
|
81
|
+
- 以下划线开头的框架内部字段。
|
|
82
|
+
- 函数、undefined 和 Symbol。
|
|
83
|
+
- 无法安全表示的循环引用。
|
|
84
|
+
|
|
85
|
+
为了得到稳定、明确且不会暴露 api/client 等实现字段的测试契约,推荐页面 Domain 实现 toJSON:
|
|
86
|
+
|
|
87
|
+
export default class DemoPage {
|
|
88
|
+
title = "";
|
|
89
|
+
items = [];
|
|
90
|
+
private readonly api = new DemoApiClient();
|
|
91
|
+
|
|
92
|
+
toJSON() {
|
|
93
|
+
return {
|
|
94
|
+
title: this.title,
|
|
95
|
+
items: this.items,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
toJSON 的返回值就是最终 HTTP JSON 响应。它应当无副作用,并只返回 JSON 可表示的数据。
|
|
101
|
+
|
|
102
|
+
## 6. onMount 中的 API 请求
|
|
103
|
+
|
|
104
|
+
Headless Domain 在 Node.js 中运行。Core 会建立请求级 Fetch 上下文,使 onMount 中的相对请求继续工作:
|
|
105
|
+
|
|
106
|
+
- /api/list 会解析到当前 Host Origin。
|
|
107
|
+
- 同源请求会透传 Cookie、Authorization、X-Request-Id 和链路追踪头。
|
|
108
|
+
- 自动增加 X-Soma-Page-Href。
|
|
109
|
+
- 跨域请求不会继承当前页面 Cookie 或 Authorization。
|
|
110
|
+
- 并发请求使用 AsyncLocalStorage 隔离,不共享 Origin、Cookie 或页面路径。
|
|
111
|
+
|
|
112
|
+
页面请求 Hook 在 Domain 执行前调用一次。onMount 发起的每个 /api 请求仍通过现有 API Route,并分别执行自己的 API Hook。
|
|
113
|
+
|
|
114
|
+
## 7. 错误与权限
|
|
115
|
+
|
|
116
|
+
框架错误使用结构化 JSON:
|
|
117
|
+
|
|
118
|
+
{
|
|
119
|
+
"error": {
|
|
120
|
+
"code": "SOMA_PAGE_NOT_FOUND",
|
|
121
|
+
"message": "Page not found: /missing.html",
|
|
122
|
+
"path": "/missing.html"
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
常见状态:
|
|
127
|
+
|
|
128
|
+
- 400:目标不是合法 Host 页面路径。
|
|
129
|
+
- 404:页面不存在、模式未开启。
|
|
130
|
+
- 500:Domain 加载、onMount 或状态序列化失败。
|
|
131
|
+
- 503:SOMA_HOST_DIR 未设置。
|
|
132
|
+
|
|
133
|
+
Host 页面 Hook 的拒绝响应会原样返回,包括登录跳转、401 或 403。JSON 模式不会绕过或改写 App 的认证授权语义。
|
|
134
|
+
|
|
135
|
+
## 8. 测试示例
|
|
136
|
+
|
|
137
|
+
curl -i \
|
|
138
|
+
-H "Cookie: session=test-session" \
|
|
139
|
+
"http://localhost:3000/demo/index.html?id=42"
|
|
140
|
+
|
|
141
|
+
测试应按 JSON 字段断言,不依赖字段顺序。对于包含当前时间或随机值的页面,应由 App 的测试数据、Mock 或 toJSON 投影提供确定性。
|
package/global.d.ts
CHANGED
|
@@ -1,33 +1,74 @@
|
|
|
1
|
-
declare module '*.html' {
|
|
2
|
-
const content: string;
|
|
3
|
-
export default content;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
declare module '*.yaml' {
|
|
7
|
-
const content: string;
|
|
8
|
-
export default content;
|
|
9
|
-
}
|
|
10
|
-
|
|
1
|
+
declare module '*.html' {
|
|
2
|
+
const content: string;
|
|
3
|
+
export default content;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
declare module '*.yaml' {
|
|
7
|
+
const content: string;
|
|
8
|
+
export default content;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
11
|
declare module '*.yml' {
|
|
12
12
|
const content: string;
|
|
13
13
|
export default content;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
declare module '@soma-host/bootstrap/soma-bootstrap' {
|
|
17
|
+
export const configureSomaBootstrap:
|
|
18
|
+
| import('./core/client/host-bridge/resolve-host-bootstrap').SomaBootstrapConfigurator
|
|
19
|
+
| undefined;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
declare module '@soma-host/bootstrap/soma-request-hook' {
|
|
23
|
+
export const somaRequestHook:
|
|
24
|
+
| import('./core/server/host/resolve-host-request-hook').SomaRequestHook
|
|
25
|
+
| undefined;
|
|
26
|
+
export const handleSomaRequest:
|
|
27
|
+
| import('./core/server/host/resolve-host-request-hook').SomaRequestHook
|
|
28
|
+
| undefined;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
declare module '@soma-host/bootstrap/soma-domain-loaders' {
|
|
32
|
+
export const somaDomainLoaders:
|
|
33
|
+
| import('./core/client/host-bridge/soma-domain-loaders').SomaDomainLoaderMap
|
|
34
|
+
| undefined;
|
|
35
|
+
export const loadSomaDomainModule:
|
|
36
|
+
| import('./core/client/host-bridge/soma-domain-loaders').SomaDomainModuleResolver
|
|
37
|
+
| undefined;
|
|
38
|
+
const defaultExport:
|
|
39
|
+
| import('./core/client/host-bridge/soma-domain-loaders').SomaDomainLoaderMap
|
|
40
|
+
| import('./core/client/host-bridge/soma-domain-loaders').SomaDomainModuleResolver
|
|
41
|
+
| undefined;
|
|
42
|
+
export default defaultExport;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
declare module '@soma-host/config/locale.yaml' {
|
|
46
|
+
const content: Record<string, unknown>;
|
|
47
|
+
export default content;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
declare module '@soma-host/config/app.config.yaml' {
|
|
51
|
+
const content: Record<string, unknown>;
|
|
52
|
+
export default content;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** Host dynamic asset paths (domain/ui/event); runtime resolves via webpack alias */
|
|
56
|
+
declare module '@soma-host/*' {
|
|
57
|
+
const content: unknown;
|
|
58
|
+
export default content;
|
|
59
|
+
}
|
|
60
|
+
|
|
16
61
|
/** Dev console API (window.__SOMA__ in npm run dev) */
|
|
17
62
|
interface SomaDevConsole {
|
|
18
|
-
getDiagnosticsSnapshot: () => import('./core/diagnostics/SomaDiagnostics').SomaDiagnosticsSnapshot | null;
|
|
19
|
-
getTelemetrySnapshot: () => Record<string, { count: number; avg: number; max: number; min: number }> | null;
|
|
20
|
-
getAvailableThemes?: () => string[];
|
|
21
|
-
getDomainInstance: () => unknown;
|
|
22
|
-
captureSnapshot: () => number | null;
|
|
23
|
-
restoreSnapshot: (id: number) => void;
|
|
24
|
-
switchTheme: (name: string | null) => void;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export {};
|
|
63
|
+
getDiagnosticsSnapshot: () => import('./core/client/diagnostics/SomaDiagnostics').SomaDiagnosticsSnapshot | null;
|
|
64
|
+
getTelemetrySnapshot: () => Record<string, { count: number; avg: number; max: number; min: number }> | null;
|
|
65
|
+
getAvailableThemes?: () => string[];
|
|
66
|
+
getDomainInstance: () => unknown;
|
|
67
|
+
captureSnapshot: () => number | null;
|
|
68
|
+
restoreSnapshot: (id: number) => void;
|
|
69
|
+
switchTheme: (name: string | null) => void;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
interface Window {
|
|
73
|
+
__SOMA__?: SomaDevConsole;
|
|
74
|
+
}
|
package/middleware.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { NextRequest, NextResponse } from 'next/server';
|
|
2
|
+
import {
|
|
3
|
+
SOMA_PAGE_REQUEST_URL_HEADER,
|
|
4
|
+
shouldUseJsonPageResponse,
|
|
5
|
+
} from './core/server/host/page-response-request';
|
|
6
|
+
|
|
7
|
+
export function middleware(request: NextRequest) {
|
|
8
|
+
if (!shouldUseJsonPageResponse({
|
|
9
|
+
mode: process.env.SOMA_PAGE_RESPONSE_MODE,
|
|
10
|
+
method: request.method,
|
|
11
|
+
pathname: request.nextUrl.pathname,
|
|
12
|
+
})) {
|
|
13
|
+
return NextResponse.next();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const requestHeaders = new Headers(request.headers);
|
|
17
|
+
requestHeaders.set(
|
|
18
|
+
SOMA_PAGE_REQUEST_URL_HEADER,
|
|
19
|
+
request.nextUrl.pathname + request.nextUrl.search,
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
const destination = new URL('/soma/page-object', request.url);
|
|
23
|
+
destination.search = '';
|
|
24
|
+
destination.searchParams.set('path', request.nextUrl.pathname);
|
|
25
|
+
|
|
26
|
+
return NextResponse.rewrite(destination, {
|
|
27
|
+
request: { headers: requestHeaders },
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export const config = {
|
|
32
|
+
matcher: ['/:path*'],
|
|
33
|
+
};
|