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,96 @@
|
|
|
1
|
+
const fs = require('node:fs');
|
|
2
|
+
const yaml = require('js-yaml');
|
|
3
|
+
const {
|
|
4
|
+
readSomaEnv,
|
|
5
|
+
resolveHostAppConfigPath,
|
|
6
|
+
} = require('./host-config-paths.cjs');
|
|
7
|
+
|
|
8
|
+
const PAGE_RESPONSE_MODES = new Set(['html', 'json']);
|
|
9
|
+
|
|
10
|
+
class SomaPageResponseModeConfigError extends Error {
|
|
11
|
+
constructor(code, message, configPath) {
|
|
12
|
+
super(message);
|
|
13
|
+
this.name = 'SomaPageResponseModeConfigError';
|
|
14
|
+
this.code = code;
|
|
15
|
+
this.configPath = configPath;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function isRecord(value) {
|
|
20
|
+
return Boolean(value) && typeof value === 'object' && !Array.isArray(value);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function readSomaPageResponseMode(hostDir, env = process.env) {
|
|
24
|
+
const environment = readSomaEnv(env);
|
|
25
|
+
const configPath = resolveHostAppConfigPath(hostDir, environment);
|
|
26
|
+
if (!configPath) {
|
|
27
|
+
return { mode: 'html', environment, configPath: null };
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
let document;
|
|
31
|
+
try {
|
|
32
|
+
document = yaml.load(fs.readFileSync(configPath, 'utf8')) ?? {};
|
|
33
|
+
} catch (error) {
|
|
34
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
35
|
+
throw new SomaPageResponseModeConfigError(
|
|
36
|
+
'SOMA_PAGE_RESPONSE_CONFIG_INVALID',
|
|
37
|
+
'Cannot read App config for page response mode: ' + detail,
|
|
38
|
+
configPath,
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (!isRecord(document)) {
|
|
43
|
+
throw new SomaPageResponseModeConfigError(
|
|
44
|
+
'SOMA_PAGE_RESPONSE_CONFIG_INVALID',
|
|
45
|
+
'App config must be a YAML object: ' + configPath,
|
|
46
|
+
configPath,
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const somaConfig = document.soma;
|
|
51
|
+
if (somaConfig === undefined || somaConfig === null) {
|
|
52
|
+
return { mode: 'html', environment, configPath };
|
|
53
|
+
}
|
|
54
|
+
if (!isRecord(somaConfig)) {
|
|
55
|
+
throw new SomaPageResponseModeConfigError(
|
|
56
|
+
'SOMA_PAGE_RESPONSE_CONFIG_INVALID',
|
|
57
|
+
'App config field "soma" must be an object: ' + configPath,
|
|
58
|
+
configPath,
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const rawMode = somaConfig.pageResponseMode;
|
|
63
|
+
if (rawMode === undefined || rawMode === null || rawMode === '') {
|
|
64
|
+
return { mode: 'html', environment, configPath };
|
|
65
|
+
}
|
|
66
|
+
if (typeof rawMode !== 'string') {
|
|
67
|
+
throw new SomaPageResponseModeConfigError(
|
|
68
|
+
'SOMA_PAGE_RESPONSE_MODE_INVALID',
|
|
69
|
+
'App config field "soma.pageResponseMode" must be "html" or "json": ' + configPath,
|
|
70
|
+
configPath,
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const mode = rawMode.trim().toLowerCase();
|
|
75
|
+
if (!PAGE_RESPONSE_MODES.has(mode)) {
|
|
76
|
+
throw new SomaPageResponseModeConfigError(
|
|
77
|
+
'SOMA_PAGE_RESPONSE_MODE_INVALID',
|
|
78
|
+
'Unsupported soma.pageResponseMode "' + rawMode + '"; expected "html" or "json": ' + configPath,
|
|
79
|
+
configPath,
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
if (mode === 'json' && environment !== 'test') {
|
|
83
|
+
throw new SomaPageResponseModeConfigError(
|
|
84
|
+
'SOMA_PAGE_RESPONSE_MODE_PRODUCTION_FORBIDDEN',
|
|
85
|
+
'soma.pageResponseMode=json is test-only and cannot run in production: ' + configPath,
|
|
86
|
+
configPath,
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return { mode, environment, configPath };
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
module.exports = {
|
|
94
|
+
SomaPageResponseModeConfigError,
|
|
95
|
+
readSomaPageResponseMode,
|
|
96
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export type SomaPageResponseMode = 'html' | 'json';
|
|
2
|
+
|
|
3
|
+
export const SOMA_PAGE_REQUEST_URL_HEADER = 'x-soma-page-request-url';
|
|
4
|
+
|
|
5
|
+
export function isJsonPageResponseMode(mode: string | undefined): boolean {
|
|
6
|
+
return mode?.trim().toLowerCase() === 'json';
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function isSomaPageRequestPath(pathname: string): boolean {
|
|
10
|
+
const normalized = pathname.startsWith('/') ? pathname : '/' + pathname;
|
|
11
|
+
const firstSegment = normalized.split('/').filter(Boolean)[0] ?? '';
|
|
12
|
+
if (firstSegment === 'api' || firstSegment === 'soma' || firstSegment === '_next') {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const lastSegment = normalized.split('/').filter(Boolean).at(-1) ?? '';
|
|
17
|
+
if (lastSegment === 'favicon.ico') {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
const extension = lastSegment.match(/\.([^./]+)$/)?.[1]?.toLowerCase();
|
|
21
|
+
return !extension || extension === 'html';
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function shouldUseJsonPageResponse(options: {
|
|
25
|
+
mode: string | undefined;
|
|
26
|
+
method: string;
|
|
27
|
+
pathname: string;
|
|
28
|
+
}): boolean {
|
|
29
|
+
const method = options.method.toUpperCase();
|
|
30
|
+
return (
|
|
31
|
+
isJsonPageResponseMode(options.mode)
|
|
32
|
+
&& (method === 'GET' || method === 'HEAD')
|
|
33
|
+
&& isSomaPageRequestPath(options.pathname)
|
|
34
|
+
);
|
|
35
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
function firstForwardedValue(value: string | null): string {
|
|
2
|
+
return value?.split(',')[0]?.trim() ?? '';
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export function resolveSomaRequestOrigin(requestHeaders: Headers): string {
|
|
6
|
+
const host = firstForwardedValue(requestHeaders.get('x-forwarded-host'))
|
|
7
|
+
|| firstForwardedValue(requestHeaders.get('host'))
|
|
8
|
+
|| 'localhost';
|
|
9
|
+
const closingBracket = host.indexOf(']');
|
|
10
|
+
const hostname = (host.startsWith('[') && closingBracket > 0
|
|
11
|
+
? host.slice(1, closingBracket)
|
|
12
|
+
: host.split(':')[0]).toLowerCase();
|
|
13
|
+
const forwardedProtocol = firstForwardedValue(requestHeaders.get('x-forwarded-proto'));
|
|
14
|
+
const protocol = forwardedProtocol === 'http' || forwardedProtocol === 'https'
|
|
15
|
+
? forwardedProtocol
|
|
16
|
+
: (hostname === 'localhost' || hostname === '127.0.0.1' || hostname === '::1' ? 'http' : 'https');
|
|
17
|
+
return protocol + '://' + host;
|
|
18
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export type SomaHostRequestKind = 'page' | 'api';
|
|
2
|
+
|
|
3
|
+
export interface SomaHostRequestContext {
|
|
4
|
+
kind: SomaHostRequestKind;
|
|
5
|
+
path: string;
|
|
6
|
+
pageHref?: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Generic server ingress extension. soma-core does not know authentication,
|
|
11
|
+
* authorization, Admin, or any business application.
|
|
12
|
+
*/
|
|
13
|
+
export type SomaRequestHook = (
|
|
14
|
+
request: Request,
|
|
15
|
+
context: SomaHostRequestContext,
|
|
16
|
+
) => Response | undefined | Promise<Response | undefined>;
|
|
17
|
+
|
|
18
|
+
export interface SomaRequestHookModule {
|
|
19
|
+
somaRequestHook?: SomaRequestHook;
|
|
20
|
+
handleSomaRequest?: SomaRequestHook;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export async function resolveHostRequestHook(): Promise<SomaRequestHook | null> {
|
|
24
|
+
const module = await import(
|
|
25
|
+
/* webpackInclude: /\/bootstrap\/soma-request-hook\.ts$/ */
|
|
26
|
+
'@soma-host/bootstrap/soma-request-hook'
|
|
27
|
+
) as SomaRequestHookModule;
|
|
28
|
+
return module.somaRequestHook ?? module.handleSomaRequest ?? null;
|
|
29
|
+
}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import { isAbsolute, join, relative, resolve } from 'node:path';
|
|
3
|
+
import { isSafePageBase, urlPathToCandidates } from '../../build/compiler/page-base-resolver';
|
|
4
|
+
import { ServerFileCache } from '../infra/cache/ServerFileCache';
|
|
5
|
+
import { composeAppConfigYaml } from './app-config-composer';
|
|
6
|
+
import {
|
|
7
|
+
resolveAppConfigPath,
|
|
8
|
+
resolveHostAppConfigPath,
|
|
9
|
+
} from './host-config-paths';
|
|
10
|
+
import {
|
|
11
|
+
getSomaAssetSources,
|
|
12
|
+
type SomaAssetSource,
|
|
13
|
+
} from './source-packages';
|
|
14
|
+
|
|
15
|
+
export type SomaPageAssetLoadProfile = 'render' | 'headless';
|
|
16
|
+
|
|
17
|
+
export interface SomaServerPageAssets {
|
|
18
|
+
base: string;
|
|
19
|
+
sourceType: SomaAssetSource['type'];
|
|
20
|
+
sourcePackage: string | null;
|
|
21
|
+
html?: string;
|
|
22
|
+
ui: string;
|
|
23
|
+
event: string;
|
|
24
|
+
styleYaml: string;
|
|
25
|
+
localeYaml: string;
|
|
26
|
+
appConfigYaml: string;
|
|
27
|
+
includes?: Record<string, string>;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export class SomaPageAssetError extends Error {
|
|
31
|
+
readonly code: string;
|
|
32
|
+
readonly status: number;
|
|
33
|
+
|
|
34
|
+
constructor(code: string, status: number, message: string) {
|
|
35
|
+
super(message);
|
|
36
|
+
this.name = 'SomaPageAssetError';
|
|
37
|
+
this.code = code;
|
|
38
|
+
this.status = status;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const cache = ServerFileCache.getInstance();
|
|
43
|
+
const watchedRoots = new Set<string>();
|
|
44
|
+
|
|
45
|
+
function ensureWatch(root: string): void {
|
|
46
|
+
if (watchedRoots.has(root)) return;
|
|
47
|
+
watchedRoots.add(root);
|
|
48
|
+
cache.watchAndInvalidate(root);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function resolveSomaPageSource(
|
|
52
|
+
sources: SomaAssetSource[],
|
|
53
|
+
urlPath: string,
|
|
54
|
+
): { source: SomaAssetSource; base: string } | null {
|
|
55
|
+
for (const candidate of urlPathToCandidates(urlPath)) {
|
|
56
|
+
if (!isSafePageBase(candidate)) continue;
|
|
57
|
+
for (const source of sources) {
|
|
58
|
+
const htmlPath = join(source.assetRoot, 'html', candidate + '.html');
|
|
59
|
+
if (existsSync(htmlPath)) {
|
|
60
|
+
return { source, base: candidate };
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function collectIncludes(sources: SomaAssetSource[]): Record<string, string> {
|
|
68
|
+
const includes: Record<string, string> = {};
|
|
69
|
+
const ordered = [
|
|
70
|
+
...sources.filter((source) => source.type === 'package'),
|
|
71
|
+
...sources.filter((source) => source.type === 'host'),
|
|
72
|
+
];
|
|
73
|
+
for (const source of ordered) {
|
|
74
|
+
const sharedDir = join(source.assetRoot, 'html', 'shared');
|
|
75
|
+
try {
|
|
76
|
+
const files = cache.readDirFiles(sharedDir, '.html');
|
|
77
|
+
const names = cache.readDirNames(sharedDir, '.html');
|
|
78
|
+
for (let index = 0; index < names.length; index += 1) {
|
|
79
|
+
includes['shared/' + names[index]] = files[index];
|
|
80
|
+
}
|
|
81
|
+
} catch {
|
|
82
|
+
// A source package does not need a shared directory.
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return includes;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function assertContainedHtmlPath(source: SomaAssetSource, base: string): string {
|
|
89
|
+
const htmlRoot = resolve(source.assetRoot, 'html');
|
|
90
|
+
const htmlPath = resolve(htmlRoot, base + '.html');
|
|
91
|
+
const childPath = relative(htmlRoot, htmlPath);
|
|
92
|
+
if (!childPath || childPath.startsWith('..') || isAbsolute(childPath)) {
|
|
93
|
+
throw new SomaPageAssetError(
|
|
94
|
+
'SOMA_PAGE_PATH_INVALID',
|
|
95
|
+
400,
|
|
96
|
+
'Invalid page path',
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
return htmlPath;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export function loadSomaServerPageAssets(options: {
|
|
103
|
+
hostDir: string | undefined;
|
|
104
|
+
urlPath: string;
|
|
105
|
+
profile?: SomaPageAssetLoadProfile;
|
|
106
|
+
watch?: boolean;
|
|
107
|
+
}): SomaServerPageAssets {
|
|
108
|
+
const { hostDir, urlPath } = options;
|
|
109
|
+
if (!hostDir) {
|
|
110
|
+
throw new SomaPageAssetError(
|
|
111
|
+
'SOMA_HOST_DIR_MISSING',
|
|
112
|
+
503,
|
|
113
|
+
'SOMA_HOST_DIR is not set. Run: npx soma dev from your app root.',
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const profile = options.profile ?? 'render';
|
|
118
|
+
const sources = getSomaAssetSources(hostDir);
|
|
119
|
+
const hostSource = sources.find((source) => source.type === 'host');
|
|
120
|
+
const hostConfigRoot = hostSource?.configRoot ?? hostDir;
|
|
121
|
+
if (options.watch !== false) {
|
|
122
|
+
for (const source of sources) {
|
|
123
|
+
ensureWatch(source.assetRoot);
|
|
124
|
+
if (source.codeRoot !== source.assetRoot) {
|
|
125
|
+
ensureWatch(source.codeRoot);
|
|
126
|
+
}
|
|
127
|
+
if (existsSync(source.configRoot)) {
|
|
128
|
+
ensureWatch(source.configRoot);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const resolvedPage = resolveSomaPageSource(sources, urlPath);
|
|
134
|
+
if (!resolvedPage) {
|
|
135
|
+
throw new SomaPageAssetError(
|
|
136
|
+
'SOMA_PAGE_NOT_FOUND',
|
|
137
|
+
404,
|
|
138
|
+
'Page not found: ' + urlPath,
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const { source, base } = resolvedPage;
|
|
143
|
+
const htmlPath = assertContainedHtmlPath(source, base);
|
|
144
|
+
try {
|
|
145
|
+
const ui = cache.tryReadFile(join(source.assetRoot, 'ui', base + '_ui.yaml'));
|
|
146
|
+
const localeYaml = cache.tryReadFile(join(hostConfigRoot, 'locale.yaml'));
|
|
147
|
+
const hostAppConfigPath = resolveHostAppConfigPath(hostDir);
|
|
148
|
+
const hostAppConfigYaml = hostAppConfigPath
|
|
149
|
+
? cache.tryReadFile(hostAppConfigPath)
|
|
150
|
+
: '';
|
|
151
|
+
const sourceAppConfigPath = resolveAppConfigPath(source.configRoot);
|
|
152
|
+
const sourceAppConfigYaml = sourceAppConfigPath
|
|
153
|
+
? cache.tryReadFile(sourceAppConfigPath)
|
|
154
|
+
: '';
|
|
155
|
+
const appConfigYaml = source.type === 'host'
|
|
156
|
+
? hostAppConfigYaml
|
|
157
|
+
: composeAppConfigYaml(sourceAppConfigYaml, hostAppConfigYaml);
|
|
158
|
+
|
|
159
|
+
if (profile === 'headless') {
|
|
160
|
+
return {
|
|
161
|
+
base,
|
|
162
|
+
sourceType: source.type,
|
|
163
|
+
sourcePackage: source.packageName ?? null,
|
|
164
|
+
ui,
|
|
165
|
+
event: '',
|
|
166
|
+
styleYaml: '',
|
|
167
|
+
localeYaml,
|
|
168
|
+
appConfigYaml,
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
return {
|
|
173
|
+
base,
|
|
174
|
+
sourceType: source.type,
|
|
175
|
+
sourcePackage: source.packageName ?? null,
|
|
176
|
+
html: cache.readFile(htmlPath),
|
|
177
|
+
ui,
|
|
178
|
+
event: cache.tryReadFile(join(source.assetRoot, 'event', base + '_event.yaml')),
|
|
179
|
+
styleYaml: cache.tryReadFile(join(source.assetRoot, 'ui', base + '_style.yaml')),
|
|
180
|
+
localeYaml,
|
|
181
|
+
appConfigYaml,
|
|
182
|
+
includes: collectIncludes(sources),
|
|
183
|
+
};
|
|
184
|
+
} catch (error) {
|
|
185
|
+
if (error instanceof SomaPageAssetError) throw error;
|
|
186
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
187
|
+
throw new SomaPageAssetError(
|
|
188
|
+
'SOMA_PAGE_ASSET_READ_FAILED',
|
|
189
|
+
500,
|
|
190
|
+
'Asset read error: ' + detail,
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
+
import { getSomaHostConfigRoot } from './host-config-paths';
|
|
3
4
|
|
|
4
5
|
export interface SomaAssetSource {
|
|
5
6
|
type: 'host' | 'package';
|
|
6
7
|
name: string;
|
|
7
8
|
assetRoot: string;
|
|
8
9
|
codeRoot: string;
|
|
10
|
+
configRoot: string;
|
|
9
11
|
packageName?: string;
|
|
10
12
|
}
|
|
11
13
|
|
|
@@ -14,9 +16,21 @@ interface PackageJson {
|
|
|
14
16
|
devDependencies?: Record<string, string>;
|
|
15
17
|
soma?: {
|
|
16
18
|
source?: boolean;
|
|
19
|
+
hostRoot?: string;
|
|
20
|
+
configRoot?: string;
|
|
17
21
|
};
|
|
18
22
|
}
|
|
19
23
|
|
|
24
|
+
export {
|
|
25
|
+
getSomaHostConfigRoot,
|
|
26
|
+
normalizeSomaEnv,
|
|
27
|
+
readSomaEnv,
|
|
28
|
+
resolveAppConfigPath,
|
|
29
|
+
resolveHostAppConfigPath,
|
|
30
|
+
resolveHostConfigRoot,
|
|
31
|
+
} from './host-config-paths';
|
|
32
|
+
export type { SomaEnvName } from './host-config-paths';
|
|
33
|
+
|
|
20
34
|
function readJson<T>(filePath: string): T | null {
|
|
21
35
|
try {
|
|
22
36
|
if (!fs.existsSync(filePath)) {
|
|
@@ -63,6 +77,27 @@ function readHostDependencies(hostDir: string): Record<string, string> {
|
|
|
63
77
|
};
|
|
64
78
|
}
|
|
65
79
|
|
|
80
|
+
function resolveSafeChildRoot(parent: string, relativePath: string | undefined): string {
|
|
81
|
+
const trimmed = relativePath?.trim();
|
|
82
|
+
if (!trimmed) {
|
|
83
|
+
return parent;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const resolved = path.resolve(parent, trimmed);
|
|
87
|
+
const normalizedParent = path.resolve(parent);
|
|
88
|
+
if (resolved === normalizedParent || resolved.startsWith(`${normalizedParent}${path.sep}`)) {
|
|
89
|
+
return fs.existsSync(resolved) ? resolved : normalizedParent;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return normalizedParent;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export function getSomaHostSourceRoot(hostDir: string): string {
|
|
96
|
+
const normalizedHostDir = path.resolve(hostDir);
|
|
97
|
+
const packageJson = readJson<PackageJson>(path.join(normalizedHostDir, 'package.json'));
|
|
98
|
+
return resolveSafeChildRoot(normalizedHostDir, packageJson?.soma?.hostRoot);
|
|
99
|
+
}
|
|
100
|
+
|
|
66
101
|
function isSomaSourcePackage(packageRoot: string, explicit: boolean): boolean {
|
|
67
102
|
if (explicit) {
|
|
68
103
|
return true;
|
|
@@ -72,18 +107,23 @@ function isSomaSourcePackage(packageRoot: string, explicit: boolean): boolean {
|
|
|
72
107
|
}
|
|
73
108
|
|
|
74
109
|
function toPackageSource(packageName: string, packageRoot: string): SomaAssetSource {
|
|
75
|
-
const
|
|
110
|
+
const packageJson = readJson<PackageJson>(path.join(packageRoot, 'package.json'));
|
|
111
|
+
const codeRoot = resolveSafeChildRoot(packageRoot, packageJson?.soma?.hostRoot);
|
|
112
|
+
const configRoot = resolveSafeChildRoot(packageRoot, packageJson?.soma?.configRoot);
|
|
113
|
+
const shellRoot = path.join(codeRoot, 'shell');
|
|
76
114
|
return {
|
|
77
115
|
type: 'package',
|
|
78
116
|
name: packageName,
|
|
79
117
|
packageName,
|
|
80
|
-
assetRoot: fs.existsSync(path.join(shellRoot, 'html')) ? shellRoot :
|
|
81
|
-
codeRoot
|
|
118
|
+
assetRoot: fs.existsSync(path.join(shellRoot, 'html')) ? shellRoot : codeRoot,
|
|
119
|
+
codeRoot,
|
|
120
|
+
configRoot,
|
|
82
121
|
};
|
|
83
122
|
}
|
|
84
123
|
|
|
85
124
|
export function getSomaAssetSources(hostDir: string): SomaAssetSource[] {
|
|
86
125
|
const normalizedHostDir = path.resolve(hostDir);
|
|
126
|
+
const hostSourceRoot = getSomaHostSourceRoot(normalizedHostDir);
|
|
87
127
|
const dependencies = readHostDependencies(normalizedHostDir);
|
|
88
128
|
const explicitPackages = new Set(readExplicitSourcePackages());
|
|
89
129
|
const packageNames = new Set([
|
|
@@ -95,8 +135,9 @@ export function getSomaAssetSources(hostDir: string): SomaAssetSource[] {
|
|
|
95
135
|
{
|
|
96
136
|
type: 'host',
|
|
97
137
|
name: 'host',
|
|
98
|
-
assetRoot:
|
|
99
|
-
codeRoot:
|
|
138
|
+
assetRoot: hostSourceRoot,
|
|
139
|
+
codeRoot: hostSourceRoot,
|
|
140
|
+
configRoot: getSomaHostConfigRoot(normalizedHostDir),
|
|
100
141
|
},
|
|
101
142
|
];
|
|
102
143
|
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server-only SOMA capabilities.
|
|
3
|
+
*
|
|
4
|
+
* Import from Host `api/service`, Route Handlers, and other Node/Next server entries.
|
|
5
|
+
* Do not import this module from Domain classes or `'use client'` files.
|
|
6
|
+
*
|
|
7
|
+
* Public Host imports should keep using `soma-core` / `soma-core/base` for page code.
|
|
8
|
+
* This entry is additive and optional.
|
|
9
|
+
*/
|
|
10
|
+
import 'server-only';
|
|
11
|
+
|
|
12
|
+
export { ServerFileCache } from './infra/cache/ServerFileCache';
|
|
13
|
+
export {
|
|
14
|
+
withSomaServerRequestContext,
|
|
15
|
+
type SomaServerRequestContextOptions,
|
|
16
|
+
} from './infra/http/soma-server-request-context';
|
|
17
|
+
|
|
18
|
+
export type { IService } from './api/IService';
|
|
19
|
+
export { loadHostService } from './api/load-host-service';
|
|
20
|
+
export { resolveServiceFilePath, toPascalCase } from './api/service-path';
|
|
21
|
+
|
|
22
|
+
export { invokeHostRequestHook } from './host/invoke-host-request-hook';
|
|
23
|
+
export {
|
|
24
|
+
resolveHostRequestHook,
|
|
25
|
+
type SomaHostRequestContext,
|
|
26
|
+
type SomaHostRequestKind,
|
|
27
|
+
type SomaRequestHook,
|
|
28
|
+
} from './host/resolve-host-request-hook';
|
|
29
|
+
export {
|
|
30
|
+
loadSomaServerPageAssets,
|
|
31
|
+
SomaPageAssetError,
|
|
32
|
+
type SomaServerPageAssets,
|
|
33
|
+
type SomaPageAssetLoadProfile,
|
|
34
|
+
} from './host/server-page-assets';
|
|
35
|
+
|
|
36
|
+
export {
|
|
37
|
+
setSomaDb,
|
|
38
|
+
getSomaDb,
|
|
39
|
+
resetSomaDb,
|
|
40
|
+
createSomaDbSingleton,
|
|
41
|
+
} from './infra/db/soma-db';
|