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.
Files changed (323) hide show
  1. package/app/SomaPageClient.tsx +12 -49
  2. package/app/[...path]/page.tsx +21 -0
  3. package/app/api/[...path]/route.ts +86 -77
  4. package/app/components/SomaHostPage.tsx +133 -0
  5. package/app/components/SomaHydrationShell.tsx +1 -1
  6. package/app/layout.tsx +22 -18
  7. package/app/page.tsx +7 -18
  8. package/app/soma/[...path]/route.ts +9 -0
  9. package/app/{api/soma-manifest → soma/manifest}/route.ts +3 -3
  10. package/app/soma/page/route.ts +29 -0
  11. package/app/soma/page-object/route.ts +159 -0
  12. package/app/soma/route.ts +9 -0
  13. package/bin/soma-lsp.cjs +5 -5
  14. package/bin/soma-mock.mjs +38 -0
  15. package/bin/soma-sync.cjs +1 -1
  16. package/core/{compiler → build/compiler}/full-manifest-builder.ts +84 -69
  17. package/core/build/compiler/host-config-sync.cjs +64 -0
  18. package/core/{compiler → build/compiler}/precompiled-manifest-loader.ts +1 -1
  19. package/core/{compiler → build/compiler}/rollup-plugin-soma.ts +1 -1
  20. package/core/{compiler → build/compiler}/route-builder.ts +31 -31
  21. package/core/{compiler → build/compiler}/soma-manifest-webpack-plugin.js +41 -7
  22. package/core/{compiler → build/compiler}/soma-precompile.js +8 -8
  23. package/core/{compiler → build/compiler}/soma-precompile.ts +94 -94
  24. package/core/{compiler → build/compiler}/soma-webpack-loader.js +41 -41
  25. package/core/{compiler → build/compiler}/vite-plugin-soma.ts +83 -83
  26. package/core/{base → client/base}/SomaApi.ts +14 -14
  27. package/core/{base → client/base}/SomaDict.ts +168 -168
  28. package/core/{base → client/base}/SomaHttpClient.ts +128 -126
  29. package/core/{base → client/base}/SomaPageRootBase.ts +71 -71
  30. package/core/{base → client/base}/SomaValidator.ts +147 -147
  31. package/core/{compiler → client/compiler}/manifest-compiler.ts +238 -238
  32. package/core/{engine → client/engine}/asset-resolver.ts +102 -102
  33. package/core/{engine → client/engine}/dom-renderer.ts +341 -341
  34. package/core/{engine → client/engine}/event-engine.ts +356 -356
  35. package/core/{engine → client/engine}/lis.ts +60 -60
  36. package/core/{engine → client/engine}/on-change-engine.ts +3 -3
  37. package/core/{engine → client/engine}/property-watcher.ts +2 -2
  38. package/core/{engine → client/engine}/reactive-proxy.ts +231 -231
  39. package/core/{engine → client/engine}/render-engine.ts +350 -350
  40. package/core/{engine → client/engine}/runtime-builder.ts +177 -177
  41. package/core/{engine → client/engine}/scope-resolver.ts +308 -308
  42. package/core/{engine → client/engine}/soma-bootstrap.ts +8 -8
  43. package/core/{engine → client/engine}/style-binder.ts +423 -423
  44. package/core/{engine → client/engine}/theme-variables.ts +1 -1
  45. package/core/{engine → client/engine}/timer-engine.ts +3 -3
  46. package/core/{engine → client/engine}/trigger-engine.ts +2 -2
  47. package/core/client/host-bridge/index.ts +27 -0
  48. package/core/client/host-bridge/load-host-domain-class.ts +87 -0
  49. package/core/client/host-bridge/soma-domain-loaders.stub.ts +6 -0
  50. package/core/client/host-bridge/soma-domain-loaders.ts +69 -0
  51. package/core/{infra → client/infra}/http/SomaHttpService.ts +208 -199
  52. package/core/{parser → client/parser}/annotation-extractor.ts +2 -2
  53. package/core/{parser → client/parser}/pipeline-parser.ts +3 -3
  54. package/core/{parser → client/parser}/style-config-parser.ts +340 -340
  55. package/core/{parser → client/parser}/timer-parser.ts +3 -3
  56. package/core/{parser → client/parser}/trigger-parser.ts +3 -3
  57. package/core/{parser → client/parser}/ui-config-parser.ts +408 -408
  58. package/core/{parser → client/parser}/yaml-loader.ts +36 -36
  59. package/core/{runtime → client/runtime}/SomaRuntimeServices.ts +5 -1
  60. package/core/client/runtime/serialize-page-state.ts +152 -0
  61. package/core/{scheduler → client/scheduler}/SomaScheduler.ts +190 -190
  62. package/core/{validation → client/validation}/contract-validator.ts +2 -2
  63. package/core/index.ts +55 -32
  64. package/core/{api → server/api}/IService.ts +29 -29
  65. package/core/server/headless/soma-headless-page.ts +103 -0
  66. package/core/server/host/app-config-composer.ts +90 -0
  67. package/core/server/host/host-config-paths.cjs +100 -0
  68. package/core/server/host/host-config-paths.ts +132 -0
  69. package/core/server/host/invoke-host-request-hook.ts +37 -0
  70. package/core/server/host/page-response-mode.cjs +96 -0
  71. package/core/server/host/page-response-request.ts +35 -0
  72. package/core/server/host/request-origin.ts +18 -0
  73. package/core/server/host/resolve-host-request-hook.ts +29 -0
  74. package/core/server/host/server-page-assets.ts +193 -0
  75. package/core/server/host/soma-request-hook-host.stub.ts +4 -0
  76. package/core/{host → server/host}/source-packages.ts +46 -5
  77. package/core/server/index.ts +41 -0
  78. package/core/{infra → server/infra}/cache/ServerFileCache.ts +123 -123
  79. package/core/server/infra/db/soma-db.ts +70 -0
  80. package/core/server/infra/http/soma-server-request-context.ts +126 -0
  81. package/core/server/mock/node/catch-all.mjs +35 -0
  82. package/core/server/mock/node/cli.d.mts +58 -0
  83. package/core/server/mock/node/cli.mjs +243 -0
  84. package/core/server/mock/node/context.mjs +167 -0
  85. package/core/server/mock/node/environment-policy.mjs +52 -0
  86. package/core/server/mock/node/plugin-loader.mjs +212 -0
  87. package/core/server/mock/node/preload.mjs +91 -0
  88. package/core/server/mock/node/process-lifecycle.mjs +236 -0
  89. package/core/server/mock/node/public.d.mts +110 -0
  90. package/core/server/mock/node/public.mjs +4 -0
  91. package/core/server/mock/node/registry.mjs +336 -0
  92. package/core/server/mock/node/schema-generator.mjs +1310 -0
  93. package/core/server/mock/testing/host-harness.d.mts +66 -0
  94. package/core/server/mock/testing/host-harness.mjs +276 -0
  95. package/core/server/mock/testing/host-runtime.mjs +48 -0
  96. package/core/server/server-only.d.ts +1 -0
  97. package/core/{types → shared/types}/domain.types.ts +91 -91
  98. package/dist/cli/soma.js +374 -3
  99. package/dist/core/index.cjs +2933 -2460
  100. package/dist/diagnostics/telemetry.cjs +1 -1
  101. package/dist/tsconfig.types.tsbuildinfo +1 -1
  102. package/dist/types/{compiler → build/compiler}/full-manifest-builder.d.ts +7 -5
  103. package/dist/types/{compiler → build/compiler}/precompiled-manifest-loader.d.ts +1 -1
  104. package/dist/types/{compiler → build/compiler}/soma-precompile.d.ts +5 -5
  105. package/dist/types/{compiler → build/compiler}/vite-plugin-soma.d.ts +1 -1
  106. package/dist/types/{base → client/base}/SomaHttpClient.d.ts +2 -0
  107. package/dist/types/{base → client/base}/SomaPageRootBase.d.ts +1 -1
  108. package/dist/types/{base → client/base}/SomaValidator.d.ts +1 -1
  109. package/dist/types/{compiler → client/compiler}/manifest-compiler.d.ts +3 -3
  110. package/dist/types/{engine → client/engine}/dom-renderer.d.ts +2 -2
  111. package/dist/types/{engine → client/engine}/event-engine.d.ts +1 -1
  112. package/dist/types/{engine → client/engine}/on-change-engine.d.ts +1 -1
  113. package/dist/types/{engine → client/engine}/property-watcher.d.ts +1 -1
  114. package/dist/types/{engine → client/engine}/render-engine.d.ts +3 -3
  115. package/dist/types/{engine → client/engine}/runtime-builder.d.ts +5 -5
  116. package/dist/types/{engine → client/engine}/scope-resolver.d.ts +1 -1
  117. package/dist/types/{engine → client/engine}/soma-bootstrap.d.ts +7 -7
  118. package/dist/types/{engine → client/engine}/style-binder.d.ts +1 -1
  119. package/dist/types/{engine → client/engine}/theme-variables.d.ts +1 -1
  120. package/dist/types/{engine → client/engine}/timer-engine.d.ts +1 -1
  121. package/dist/types/{engine → client/engine}/trigger-engine.d.ts +1 -1
  122. package/dist/types/client/host-bridge/index.d.ts +9 -0
  123. package/dist/types/client/host-bridge/load-host-domain-class.d.ts +12 -0
  124. package/dist/types/client/host-bridge/soma-domain-loaders.d.ts +19 -0
  125. package/dist/types/client/host-bridge/soma-domain-loaders.stub.d.ts +4 -0
  126. package/dist/types/{infra → client/infra}/http/SomaHttpService.d.ts +3 -1
  127. package/dist/types/{parser → client/parser}/annotation-extractor.d.ts +2 -2
  128. package/dist/types/{parser → client/parser}/pipeline-parser.d.ts +1 -1
  129. package/dist/types/{parser → client/parser}/style-config-parser.d.ts +1 -1
  130. package/dist/types/{parser → client/parser}/timer-parser.d.ts +2 -2
  131. package/dist/types/{parser → client/parser}/trigger-parser.d.ts +2 -2
  132. package/dist/types/{parser → client/parser}/ui-config-parser.d.ts +1 -1
  133. package/dist/types/client/runtime/serialize-page-state.d.ts +10 -0
  134. package/dist/types/{scheduler → client/scheduler}/SomaScheduler.d.ts +1 -1
  135. package/dist/types/{validation → client/validation}/contract-validator.d.ts +2 -2
  136. package/dist/types/index.d.ts +35 -32
  137. package/dist/types/{api → server/api}/IService.d.ts +1 -1
  138. package/dist/types/server/headless/soma-headless-page.d.ts +12 -0
  139. package/dist/types/server/host/app-config-composer.d.ts +6 -0
  140. package/dist/types/server/host/host-config-paths.d.ts +23 -0
  141. package/dist/types/server/host/invoke-host-request-hook.d.ts +8 -0
  142. package/dist/types/server/host/page-response-request.d.ts +9 -0
  143. package/dist/types/server/host/request-origin.d.ts +1 -0
  144. package/dist/types/server/host/resolve-host-request-hook.d.ts +16 -0
  145. package/dist/types/server/host/server-page-assets.d.ts +29 -0
  146. package/dist/types/server/host/soma-request-hook-host.stub.d.ts +2 -0
  147. package/dist/types/server/host/source-packages.d.ts +12 -0
  148. package/dist/types/server/index.d.ts +19 -0
  149. package/dist/types/server/infra/db/soma-db.d.ts +31 -0
  150. package/dist/types/server/infra/http/soma-server-request-context.d.ts +5 -0
  151. package/dist/types/{types → shared/types}/domain.types.d.ts +1 -1
  152. 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
  153. 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
  154. 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
  155. package/global.d.ts +67 -26
  156. package/middleware.ts +33 -0
  157. package/next.config.js +116 -30
  158. package/package.json +59 -21
  159. package/tailwind.config.ts +24 -24
  160. package/tsconfig.json +1 -5
  161. package/app/api/page/route.ts +0 -119
  162. package/app/loading.tsx +0 -5
  163. package/core/compiler/host-config-sync.cjs +0 -38
  164. package/dist/types/host/source-packages.d.ts +0 -8
  165. /package/core/{compiler → build/compiler}/page-base-resolver.ts +0 -0
  166. /package/core/{compiler → build/compiler}/rspack-plugin-soma.js +0 -0
  167. /package/core/{compiler → build/compiler}/soma-rspack-yaml-loader.js +0 -0
  168. /package/core/{lsp → build/lsp}/cross-file-diagnostics.cjs +0 -0
  169. /package/core/{lsp → build/lsp}/event-yaml-completion.cjs +0 -0
  170. /package/core/{lsp → build/lsp}/extra-completion.cjs +0 -0
  171. /package/core/{lsp → build/lsp}/lsp-navigation.cjs +0 -0
  172. /package/core/{lsp → build/lsp}/ui-yaml-completion.cjs +0 -0
  173. /package/core/{base → client/base}/SomaEntity.ts +0 -0
  174. /package/core/{base → client/base}/SomaLocaleOnlyPageRoot.ts +0 -0
  175. /package/core/{base → client/base}/decorators/Event.ts +0 -0
  176. /package/core/{base → client/base}/decorators/Locale.ts +0 -0
  177. /package/core/{base → client/base}/decorators/Page.ts +0 -0
  178. /package/core/{base → client/base}/decorators/Show.ts +0 -0
  179. /package/core/{base → client/base}/decorators/ShowList.ts +0 -0
  180. /package/core/{base → client/base}/decorators/index.ts +0 -0
  181. /package/core/{base → client/base}/index.ts +0 -0
  182. /package/core/{base → client/base}/runAsync.ts +0 -0
  183. /package/core/{container → client/container}/IContainerAdapter.ts +0 -0
  184. /package/core/{container → client/container}/MiniProgramContainerAdapter.ts +0 -0
  185. /package/core/{container → client/container}/ReactNativeContainerAdapter.ts +0 -0
  186. /package/core/{container → client/container}/SomaContainerAdapter.ts +0 -0
  187. /package/core/{diagnostics → client/diagnostics}/SomaDiagnostics.ts +0 -0
  188. /package/core/{diagnostics → client/diagnostics}/SomaTelemetry.ts +0 -0
  189. /package/core/{diagnostics → client/diagnostics}/telemetry-context.ts +0 -0
  190. /package/core/{host → client/host-bridge}/resolve-host-bootstrap.ts +0 -0
  191. /package/core/{host → client/host-bridge}/soma-bootstrap-host.stub.ts +0 -0
  192. /package/core/{infra → client/infra}/auth/IAuthService.ts +0 -0
  193. /package/core/{infra → client/infra}/auth/TokenAuthService.ts +0 -0
  194. /package/core/{infra → client/infra}/cache/ICache.ts +0 -0
  195. /package/core/{infra → client/infra}/cache/MemoryCache.ts +0 -0
  196. /package/core/{infra → client/infra}/config/IConfig.ts +0 -0
  197. /package/core/{infra → client/infra}/config/SomaConfig.ts +0 -0
  198. /package/core/{infra → client/infra}/event-bus/IEventBus.ts +0 -0
  199. /package/core/{infra → client/infra}/event-bus/SomaEventBus.ts +0 -0
  200. /package/core/{infra → client/infra}/http/IHttpClient.ts +0 -0
  201. /package/core/{infra → client/infra}/i18n/DefaultI18n.ts +0 -0
  202. /package/core/{infra → client/infra}/i18n/II18n.ts +0 -0
  203. /package/core/{infra → client/infra}/logger/ConsoleLogger.ts +0 -0
  204. /package/core/{infra → client/infra}/logger/ILogger.ts +0 -0
  205. /package/core/{infra → client/infra}/notify/DefaultNotifyService.ts +0 -0
  206. /package/core/{infra → client/infra}/notify/DomNotifyService.ts +0 -0
  207. /package/core/{infra → client/infra}/notify/INotifyService.ts +0 -0
  208. /package/core/{infra → client/infra}/notify/INotifyTheme.ts +0 -0
  209. /package/core/{infra → client/infra}/permission/IPermission.ts +0 -0
  210. /package/core/{infra → client/infra}/permission/SomaPermission.ts +0 -0
  211. /package/core/{infra → client/infra}/realtime/IRealtimeService.ts +0 -0
  212. /package/core/{infra → client/infra}/realtime/IRealtimeTransport.ts +0 -0
  213. /package/core/{infra → client/infra}/realtime/SomaRealtimeService.ts +0 -0
  214. /package/core/{infra → client/infra}/realtime/SseRealtimeTransport.ts +0 -0
  215. /package/core/{infra → client/infra}/realtime/WebSocketRealtimeTransport.ts +0 -0
  216. /package/core/{infra → client/infra}/router/IRouter.ts +0 -0
  217. /package/core/{infra → client/infra}/router/SomaRouter.ts +0 -0
  218. /package/core/{infra → client/infra}/router/router-path.ts +0 -0
  219. /package/core/{infra → client/infra}/storage/IStorageService.ts +0 -0
  220. /package/core/{infra → client/infra}/storage/MemoryStorageService.ts +0 -0
  221. /package/core/{infra → client/infra}/storage/SessionStorageService.ts +0 -0
  222. /package/core/{infra → client/infra}/timer/ITimer.ts +0 -0
  223. /package/core/{infra → client/infra}/timer/SomaTimer.ts +0 -0
  224. /package/core/{middleware → client/middleware}/SomaMiddlewareChain.ts +0 -0
  225. /package/core/{middleware → client/middleware}/createPermissionMiddleware.ts +0 -0
  226. /package/core/{quality → client/quality}/SomaQualityRegistry.ts +0 -0
  227. /package/core/{runtime → client/runtime}/SomaSnapshotStore.ts +0 -0
  228. /package/core/{api → server/api}/load-host-service.ts +0 -0
  229. /package/core/{api → server/api}/service-path.ts +0 -0
  230. /package/core/{host → server/host}/app-config.stub.ts +0 -0
  231. /package/core/{host → server/host}/locale.stub.ts +0 -0
  232. /package/core/{manifest → shared/manifest}/manifest-contract.ts +0 -0
  233. /package/core/{types → shared/types}/engine.types.ts +0 -0
  234. /package/core/{types → shared/types}/event.types.ts +0 -0
  235. /package/core/{types → shared/types}/keyboard.types.ts +0 -0
  236. /package/core/{types → shared/types}/manifest.types.ts +0 -0
  237. /package/core/{types → shared/types}/scheduler.types.ts +0 -0
  238. /package/core/{types → shared/types}/style-config.types.ts +0 -0
  239. /package/core/{types → shared/types}/timer.types.ts +0 -0
  240. /package/core/{types → shared/types}/trigger.types.ts +0 -0
  241. /package/core/{types → shared/types}/ui-config.types.ts +0 -0
  242. /package/core/{types → shared/types}/watcher.types.ts +0 -0
  243. /package/dist/types/{compiler → build/compiler}/page-base-resolver.d.ts +0 -0
  244. /package/dist/types/{compiler → build/compiler}/rollup-plugin-soma.d.ts +0 -0
  245. /package/dist/types/{compiler → build/compiler}/route-builder.d.ts +0 -0
  246. /package/dist/types/{base → client/base}/SomaApi.d.ts +0 -0
  247. /package/dist/types/{base → client/base}/SomaDict.d.ts +0 -0
  248. /package/dist/types/{base → client/base}/SomaEntity.d.ts +0 -0
  249. /package/dist/types/{base → client/base}/SomaLocaleOnlyPageRoot.d.ts +0 -0
  250. /package/dist/types/{base → client/base}/decorators/Event.d.ts +0 -0
  251. /package/dist/types/{base → client/base}/decorators/Locale.d.ts +0 -0
  252. /package/dist/types/{base → client/base}/decorators/Page.d.ts +0 -0
  253. /package/dist/types/{base → client/base}/decorators/Show.d.ts +0 -0
  254. /package/dist/types/{base → client/base}/decorators/ShowList.d.ts +0 -0
  255. /package/dist/types/{base → client/base}/decorators/index.d.ts +0 -0
  256. /package/dist/types/{base → client/base}/index.d.ts +0 -0
  257. /package/dist/types/{base → client/base}/runAsync.d.ts +0 -0
  258. /package/dist/types/{container → client/container}/IContainerAdapter.d.ts +0 -0
  259. /package/dist/types/{container → client/container}/MiniProgramContainerAdapter.d.ts +0 -0
  260. /package/dist/types/{container → client/container}/ReactNativeContainerAdapter.d.ts +0 -0
  261. /package/dist/types/{container → client/container}/SomaContainerAdapter.d.ts +0 -0
  262. /package/dist/types/{diagnostics → client/diagnostics}/SomaDiagnostics.d.ts +0 -0
  263. /package/dist/types/{diagnostics → client/diagnostics}/SomaTelemetry.d.ts +0 -0
  264. /package/dist/types/{diagnostics → client/diagnostics}/telemetry-context.d.ts +0 -0
  265. /package/dist/types/{engine → client/engine}/asset-resolver.d.ts +0 -0
  266. /package/dist/types/{engine → client/engine}/lis.d.ts +0 -0
  267. /package/dist/types/{engine → client/engine}/reactive-proxy.d.ts +0 -0
  268. /package/dist/types/{host → client/host-bridge}/resolve-host-bootstrap.d.ts +0 -0
  269. /package/dist/types/{host → client/host-bridge}/soma-bootstrap-host.stub.d.ts +0 -0
  270. /package/dist/types/{infra → client/infra}/auth/IAuthService.d.ts +0 -0
  271. /package/dist/types/{infra → client/infra}/auth/TokenAuthService.d.ts +0 -0
  272. /package/dist/types/{infra → client/infra}/cache/ICache.d.ts +0 -0
  273. /package/dist/types/{infra → client/infra}/cache/MemoryCache.d.ts +0 -0
  274. /package/dist/types/{infra → client/infra}/config/IConfig.d.ts +0 -0
  275. /package/dist/types/{infra → client/infra}/config/SomaConfig.d.ts +0 -0
  276. /package/dist/types/{infra → client/infra}/event-bus/IEventBus.d.ts +0 -0
  277. /package/dist/types/{infra → client/infra}/event-bus/SomaEventBus.d.ts +0 -0
  278. /package/dist/types/{infra → client/infra}/http/IHttpClient.d.ts +0 -0
  279. /package/dist/types/{infra → client/infra}/i18n/DefaultI18n.d.ts +0 -0
  280. /package/dist/types/{infra → client/infra}/i18n/II18n.d.ts +0 -0
  281. /package/dist/types/{infra → client/infra}/logger/ConsoleLogger.d.ts +0 -0
  282. /package/dist/types/{infra → client/infra}/logger/ILogger.d.ts +0 -0
  283. /package/dist/types/{infra → client/infra}/notify/DefaultNotifyService.d.ts +0 -0
  284. /package/dist/types/{infra → client/infra}/notify/DomNotifyService.d.ts +0 -0
  285. /package/dist/types/{infra → client/infra}/notify/INotifyService.d.ts +0 -0
  286. /package/dist/types/{infra → client/infra}/notify/INotifyTheme.d.ts +0 -0
  287. /package/dist/types/{infra → client/infra}/permission/IPermission.d.ts +0 -0
  288. /package/dist/types/{infra → client/infra}/permission/SomaPermission.d.ts +0 -0
  289. /package/dist/types/{infra → client/infra}/realtime/IRealtimeService.d.ts +0 -0
  290. /package/dist/types/{infra → client/infra}/realtime/IRealtimeTransport.d.ts +0 -0
  291. /package/dist/types/{infra → client/infra}/realtime/SomaRealtimeService.d.ts +0 -0
  292. /package/dist/types/{infra → client/infra}/realtime/SseRealtimeTransport.d.ts +0 -0
  293. /package/dist/types/{infra → client/infra}/realtime/WebSocketRealtimeTransport.d.ts +0 -0
  294. /package/dist/types/{infra → client/infra}/router/IRouter.d.ts +0 -0
  295. /package/dist/types/{infra → client/infra}/router/SomaRouter.d.ts +0 -0
  296. /package/dist/types/{infra → client/infra}/router/router-path.d.ts +0 -0
  297. /package/dist/types/{infra → client/infra}/storage/IStorageService.d.ts +0 -0
  298. /package/dist/types/{infra → client/infra}/storage/MemoryStorageService.d.ts +0 -0
  299. /package/dist/types/{infra → client/infra}/storage/SessionStorageService.d.ts +0 -0
  300. /package/dist/types/{infra → client/infra}/timer/ITimer.d.ts +0 -0
  301. /package/dist/types/{infra → client/infra}/timer/SomaTimer.d.ts +0 -0
  302. /package/dist/types/{middleware → client/middleware}/SomaMiddlewareChain.d.ts +0 -0
  303. /package/dist/types/{middleware → client/middleware}/createPermissionMiddleware.d.ts +0 -0
  304. /package/dist/types/{parser → client/parser}/yaml-loader.d.ts +0 -0
  305. /package/dist/types/{quality → client/quality}/SomaQualityRegistry.d.ts +0 -0
  306. /package/dist/types/{runtime → client/runtime}/SomaRuntimeServices.d.ts +0 -0
  307. /package/dist/types/{runtime → client/runtime}/SomaSnapshotStore.d.ts +0 -0
  308. /package/dist/types/{api → server/api}/load-host-service.d.ts +0 -0
  309. /package/dist/types/{api → server/api}/service-path.d.ts +0 -0
  310. /package/dist/types/{host → server/host}/app-config.stub.d.ts +0 -0
  311. /package/dist/types/{host → server/host}/locale.stub.d.ts +0 -0
  312. /package/dist/types/{infra → server/infra}/cache/ServerFileCache.d.ts +0 -0
  313. /package/dist/types/{manifest → shared/manifest}/manifest-contract.d.ts +0 -0
  314. /package/dist/types/{types → shared/types}/engine.types.d.ts +0 -0
  315. /package/dist/types/{types → shared/types}/event.types.d.ts +0 -0
  316. /package/dist/types/{types → shared/types}/keyboard.types.d.ts +0 -0
  317. /package/dist/types/{types → shared/types}/manifest.types.d.ts +0 -0
  318. /package/dist/types/{types → shared/types}/scheduler.types.d.ts +0 -0
  319. /package/dist/types/{types → shared/types}/style-config.types.d.ts +0 -0
  320. /package/dist/types/{types → shared/types}/timer.types.d.ts +0 -0
  321. /package/dist/types/{types → shared/types}/trigger.types.d.ts +0 -0
  322. /package/dist/types/{types → shared/types}/ui-config.types.d.ts +0 -0
  323. /package/dist/types/{types → shared/types}/watcher.types.d.ts +0 -0
package/next.config.js CHANGED
@@ -1,7 +1,29 @@
1
1
  /** @type {import('next').NextConfig} */
2
2
  const fs = require('fs');
3
3
  const path = require('path');
4
- const { SomaManifestWebpackPlugin } = require('./core/compiler/soma-manifest-webpack-plugin');
4
+ const { SomaManifestWebpackPlugin } = require('./core/build/compiler/soma-manifest-webpack-plugin');
5
+ const {
6
+ resolveHostConfigRoot,
7
+ resolveHostAppConfigPath,
8
+ } = require('./core/server/host/host-config-paths.cjs');
9
+ const {
10
+ readSomaPageResponseMode,
11
+ } = require('./core/server/host/page-response-mode.cjs');
12
+
13
+ function readSomaWebpackCacheMode(env = process.env) {
14
+ const mode = env.SOMA_WEBPACK_CACHE_MODE;
15
+ if (mode === undefined) {
16
+ return null;
17
+ }
18
+ if (mode !== 'memory') {
19
+ throw new Error(
20
+ '[soma-core] Unsupported SOMA_WEBPACK_CACHE_MODE '
21
+ + JSON.stringify(mode)
22
+ + '; expected "memory" or leave it unset.',
23
+ );
24
+ }
25
+ return mode;
26
+ }
5
27
 
6
28
  const rawHostDir = process.env.SOMA_HOST_DIR;
7
29
  if (!rawHostDir || !String(rawHostDir).trim()) {
@@ -10,15 +32,68 @@ if (!rawHostDir || !String(rawHostDir).trim()) {
10
32
  );
11
33
  }
12
34
  const hostDir = path.resolve(rawHostDir);
35
+ const webpackCacheMode = readSomaWebpackCacheMode();
36
+ const pageResponseConfig = readSomaPageResponseMode(hostDir);
37
+ process.env.SOMA_PAGE_RESPONSE_MODE = pageResponseConfig.mode;
38
+ if (pageResponseConfig.mode === 'json') {
39
+ console.log(
40
+ '[soma-core] pageResponseMode=json enabled from '
41
+ + (pageResponseConfig.configPath || 'App defaults'),
42
+ );
43
+ }
44
+
45
+ function readJson(filePath) {
46
+ try {
47
+ if (!fs.existsSync(filePath)) return null;
48
+ return JSON.parse(fs.readFileSync(filePath, 'utf8'));
49
+ } catch {
50
+ return null;
51
+ }
52
+ }
53
+
54
+ function resolveSafeChildRoot(parent, relativePath) {
55
+ const trimmed = typeof relativePath === 'string' ? relativePath.trim() : '';
56
+ if (!trimmed) return parent;
57
+
58
+ const resolved = path.resolve(parent, trimmed);
59
+ if ((resolved === parent || resolved.startsWith(`${parent}${path.sep}`)) && fs.existsSync(resolved)) {
60
+ return resolved;
61
+ }
62
+ return parent;
63
+ }
64
+
65
+ function readHostSourceRoot() {
66
+ const packageJson = readJson(path.join(hostDir, 'package.json'));
67
+ return resolveSafeChildRoot(hostDir, packageJson?.soma?.hostRoot);
68
+ }
69
+
70
+ const hostSourceRoot = readHostSourceRoot();
71
+ const hostConfigRoot = resolveHostConfigRoot(hostDir);
72
+
73
+ function resolveOptionalHostSourceFile(relativePath, fallbackPath) {
74
+ const hostFile = path.resolve(hostSourceRoot, relativePath);
75
+ if (fs.existsSync(hostFile)) {
76
+ return hostFile;
77
+ }
78
+ return path.resolve(__dirname, fallbackPath);
79
+ }
13
80
 
14
- function resolveOptionalHostFile(relativePath, fallbackPath) {
15
- const hostFile = path.resolve(hostDir, relativePath);
81
+ function resolveOptionalHostConfigFile(fileName, fallbackPath) {
82
+ const hostFile = path.resolve(hostConfigRoot, fileName);
16
83
  if (fs.existsSync(hostFile)) {
17
84
  return hostFile;
18
85
  }
19
86
  return path.resolve(__dirname, fallbackPath);
20
87
  }
21
88
 
89
+ function resolveHostAppConfigAlias(fallbackPath) {
90
+ const envConfig = resolveHostAppConfigPath(hostDir);
91
+ if (envConfig) {
92
+ return envConfig;
93
+ }
94
+ return path.resolve(__dirname, fallbackPath);
95
+ }
96
+
22
97
  function readHostFileDependencyEntries() {
23
98
  const packageJsonPath = path.join(hostDir, 'package.json');
24
99
  if (!fs.existsSync(packageJsonPath)) {
@@ -56,6 +131,10 @@ const transpilePackages = [
56
131
  ];
57
132
 
58
133
  const nextConfig = {
134
+ env: {
135
+ SOMA_PAGE_RESPONSE_MODE: pageResponseConfig.mode,
136
+ },
137
+
59
138
  experimental: {
60
139
  externalDir: true,
61
140
  serverComponentsExternalPackages: ['jiti'],
@@ -63,27 +142,47 @@ const nextConfig = {
63
142
 
64
143
  transpilePackages,
65
144
 
66
- webpack: (config) => {
145
+ webpack: (config, { dev }) => {
146
+ if (webpackCacheMode === 'memory' && dev) {
147
+ config.cache = { type: 'memory' };
148
+ }
67
149
  config.resolve.alias['@'] = __dirname;
68
150
  config.resolve.alias['soma-core$'] = path.resolve(__dirname, 'core/index.ts');
69
- config.resolve.alias['soma-core/base$'] = path.resolve(__dirname, 'core/base/index.ts');
151
+ config.resolve.alias['soma-core/base$'] = path.resolve(__dirname, 'core/client/base/index.ts');
70
152
  config.resolve.alias['@core'] = path.resolve(__dirname, 'core');
71
153
  for (const entry of hostFileDependencyEntries) {
72
- config.resolve.alias[entry.name] = entry.root;
154
+ const packageJson = readJson(path.join(entry.root, 'package.json'));
155
+ if (packageJson?.soma?.configRoot) {
156
+ config.resolve.alias[`${entry.name}/config`] = resolveSafeChildRoot(
157
+ entry.root,
158
+ packageJson.soma.configRoot,
159
+ );
160
+ }
161
+ config.resolve.alias[entry.name] = resolveSafeChildRoot(
162
+ entry.root,
163
+ packageJson?.soma?.hostRoot,
164
+ );
73
165
  }
74
- config.resolve.alias['@soma-host/bootstrap/soma-bootstrap'] = resolveOptionalHostFile(
166
+ config.resolve.alias['@soma-host/bootstrap/soma-bootstrap'] = resolveOptionalHostSourceFile(
75
167
  'bootstrap/soma-bootstrap.ts',
76
- 'core/host/soma-bootstrap-host.stub.ts',
168
+ 'core/client/host-bridge/soma-bootstrap-host.stub.ts',
169
+ );
170
+ config.resolve.alias['@soma-host/bootstrap/soma-request-hook'] = resolveOptionalHostSourceFile(
171
+ 'bootstrap/soma-request-hook.ts',
172
+ 'core/server/host/soma-request-hook-host.stub.ts',
77
173
  );
78
- config.resolve.alias['@soma-host/config/locale.yaml'] = resolveOptionalHostFile(
79
- 'config/locale.yaml',
80
- 'core/host/locale.stub.ts',
174
+ config.resolve.alias['@soma-host/bootstrap/soma-domain-loaders'] = resolveOptionalHostSourceFile(
175
+ 'bootstrap/soma-domain-loaders.ts',
176
+ 'core/client/host-bridge/soma-domain-loaders.stub.ts',
81
177
  );
82
- config.resolve.alias['@soma-host/config/app.config.yaml'] = resolveOptionalHostFile(
83
- 'config/app.config.yaml',
84
- 'core/host/app-config.stub.ts',
178
+ config.resolve.alias['@soma-host/config/locale.yaml'] = resolveOptionalHostConfigFile(
179
+ 'locale.yaml',
180
+ 'core/server/host/locale.stub.ts',
85
181
  );
86
- config.resolve.alias['@soma-host'] = hostDir;
182
+ config.resolve.alias['@soma-host/config/app.config.yaml'] = resolveHostAppConfigAlias(
183
+ 'core/server/host/app-config.stub.ts',
184
+ );
185
+ config.resolve.alias['@soma-host'] = hostSourceRoot;
87
186
 
88
187
  config.plugins.push(new SomaManifestWebpackPlugin({ hostDir }));
89
188
 
@@ -92,14 +191,14 @@ const nextConfig = {
92
191
  test: /_(ui|event|style)\.ya?ml$/,
93
192
  type: 'javascript/auto',
94
193
  use: [
95
- { loader: path.resolve(__dirname, 'core/compiler/soma-webpack-loader.js') },
194
+ { loader: path.resolve(__dirname, 'core/build/compiler/soma-webpack-loader.js') },
96
195
  ],
97
196
  },
98
197
  {
99
198
  test: /\.(config|locale(\.[a-zA-Z-]+)?)\.ya?ml$/,
100
199
  type: 'javascript/auto',
101
200
  use: [
102
- { loader: path.resolve(__dirname, 'core/compiler/soma-webpack-loader.js') },
201
+ { loader: path.resolve(__dirname, 'core/build/compiler/soma-webpack-loader.js') },
103
202
  ],
104
203
  },
105
204
  { test: /\.html$/, type: 'asset/source' },
@@ -112,19 +211,6 @@ const nextConfig = {
112
211
  );
113
212
  return config;
114
213
  },
115
-
116
- async rewrites() {
117
- return [
118
- {
119
- source: '/:path*.html',
120
- destination: '/',
121
- },
122
- {
123
- source: '/:path((?!api|_next|favicon\\.ico)(?![^/]*\\.[a-zA-Z0-9]+$).*)',
124
- destination: '/',
125
- },
126
- ];
127
- },
128
214
  };
129
215
 
130
216
  module.exports = nextConfig;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "soma-core",
3
- "version": "1.0.3",
3
+ "version": "1.1.1",
4
4
  "description": "SOMA — Semantic Oriented Modular Architecture. A declarative frontend framework runtime built on Next.js 14+ App Router.",
5
5
  "keywords": [
6
6
  "soma",
@@ -21,13 +21,14 @@
21
21
  "typesVersions": {
22
22
  "*": {
23
23
  "diagnostics": [
24
- "./core/diagnostics/SomaTelemetry.ts"
24
+ "./core/client/diagnostics/SomaTelemetry.ts"
25
25
  ]
26
26
  }
27
27
  },
28
28
  "bin": {
29
29
  "soma": "bin/soma.cjs",
30
- "soma-lsp": "bin/soma-lsp.cjs"
30
+ "soma-lsp": "bin/soma-lsp.cjs",
31
+ "soma-mock": "bin/soma-mock.mjs"
31
32
  },
32
33
  "exports": {
33
34
  ".": {
@@ -37,28 +38,56 @@
37
38
  "default": "./core/index.ts"
38
39
  },
39
40
  "./base": {
40
- "types": "./dist/types/base/index.d.ts",
41
- "import": "./core/base/index.ts",
42
- "default": "./core/base/index.ts"
41
+ "types": "./dist/types/client/base/index.d.ts",
42
+ "import": "./core/client/base/index.ts",
43
+ "default": "./core/client/base/index.ts"
43
44
  },
44
- "./compiler/vite": "./core/compiler/vite-plugin-soma.ts",
45
- "./compiler/webpack-loader": "./core/compiler/soma-webpack-loader.js",
45
+ "./compiler/vite": "./core/build/compiler/vite-plugin-soma.ts",
46
+ "./compiler/webpack-loader": "./core/build/compiler/soma-webpack-loader.js",
46
47
  "./diagnostics": {
47
- "types": "./dist/types/diagnostics/SomaTelemetry.d.ts",
48
- "import": "./core/diagnostics/SomaTelemetry.ts",
48
+ "types": "./dist/types/client/diagnostics/SomaTelemetry.d.ts",
49
+ "import": "./core/client/diagnostics/SomaTelemetry.ts",
49
50
  "require": "./dist/diagnostics/telemetry.cjs",
50
- "default": "./core/diagnostics/SomaTelemetry.ts"
51
+ "default": "./core/client/diagnostics/SomaTelemetry.ts"
52
+ },
53
+ "./host/request-hook": {
54
+ "types": "./dist/types/server/host/resolve-host-request-hook.d.ts",
55
+ "import": "./core/server/host/resolve-host-request-hook.ts",
56
+ "default": "./core/server/host/resolve-host-request-hook.ts"
57
+ },
58
+ "./server": {
59
+ "types": "./dist/types/server/index.d.ts",
60
+ "import": "./core/server/index.ts",
61
+ "default": "./core/server/index.ts"
62
+ },
63
+ "./mock/node": {
64
+ "types": "./core/server/mock/node/public.d.mts",
65
+ "import": "./core/server/mock/node/public.mjs",
66
+ "default": "./core/server/mock/node/public.mjs"
67
+ },
68
+ "./mock/node/cli": {
69
+ "types": "./core/server/mock/node/cli.d.mts",
70
+ "import": "./core/server/mock/node/cli.mjs",
71
+ "default": "./core/server/mock/node/cli.mjs"
72
+ },
73
+ "./testing/mock-host": {
74
+ "types": "./core/server/mock/testing/host-harness.d.mts",
75
+ "import": "./core/server/mock/testing/host-harness.mjs",
76
+ "default": "./core/server/mock/testing/host-harness.mjs"
51
77
  }
52
78
  },
53
79
  "files": [
54
80
  "bin/soma.cjs",
55
81
  "bin/soma-lsp.cjs",
56
82
  "bin/soma-sync.cjs",
83
+ "bin/soma-mock.mjs",
57
84
  "core/",
85
+ "docs/",
58
86
  "editor/",
59
87
  "app/",
60
88
  "dist/",
61
89
  "dist/vscode/",
90
+ "middleware.ts",
62
91
  "next.config.js",
63
92
  "tailwind.config.ts",
64
93
  "postcss.config.js",
@@ -70,9 +99,9 @@
70
99
  },
71
100
  "scripts": {
72
101
  "build:cli": "tsc -p tsconfig.cli.json",
73
- "build:precompile": "esbuild core/compiler/soma-precompile.ts --bundle --platform=node --format=cjs --outfile=core/compiler/soma-precompile.js",
102
+ "build:precompile": "esbuild core/build/compiler/soma-precompile.ts --bundle --platform=node --format=cjs --outfile=core/build/compiler/soma-precompile.js",
74
103
  "build:core-dist": "node scripts/build-core-dist.mjs",
75
- "build:types": "tsc -p tsconfig.types.json",
104
+ "build:types": "rm -rf dist/types && tsc -p tsconfig.types.json",
76
105
  "build:all": "npm run build:cli && npm run build:core-dist && npm run build:types",
77
106
  "package:vscode": "node scripts/package-vscode.mjs",
78
107
  "prepublishOnly": "npm run build:all",
@@ -80,15 +109,22 @@
80
109
  "build": "next build",
81
110
  "start": "next start",
82
111
  "lint": "next lint",
83
- "test": "vitest run",
112
+ "test": "vitest run && npm run test:mock",
113
+ "test:mock": "node --test tests/mock/*.test.mjs",
114
+ "verify:mock-pack": "node scripts/verify-mock-pack.mjs",
115
+ "verify:client-boundary": "node scripts/verify-client-boundary.mjs",
116
+ "verify:client-dep-graph": "node scripts/verify-client-dep-graph.mjs",
84
117
  "test:watch": "vitest",
85
118
  "typecheck": "tsc --noEmit"
86
119
  },
87
120
  "dependencies": {
88
- "dompurify": "^3.0.9",
121
+ "ajv": "8.20.0",
122
+ "dompurify": "^3.4.12",
89
123
  "jiti": "^1.21.7",
90
- "js-yaml": "^4.1.0",
91
- "reflect-metadata": "^0.2.1"
124
+ "js-yaml": "^4.3.0",
125
+ "msw": "2.15.0",
126
+ "reflect-metadata": "^0.2.1",
127
+ "server-only": "^0.0.1"
92
128
  },
93
129
  "peerDependencies": {
94
130
  "next": ">=14.0.0",
@@ -101,7 +137,9 @@
101
137
  "@types/node": "^20.11.0",
102
138
  "@types/react": "^18.3.0",
103
139
  "@types/react-dom": "^18.3.0",
104
- "@vitest/coverage-v8": "^3.2.4",
140
+ "@types/ws": "^8.5.13",
141
+ "@vitest/coverage-v8": "^3.2.7",
142
+ "ajv-formats": "3.0.1",
105
143
  "autoprefixer": "^10.4.17",
106
144
  "esbuild": "^0.25.12",
107
145
  "jsdom": "^26.1.0",
@@ -111,8 +149,8 @@
111
149
  "react-dom": "^18.3.0",
112
150
  "tailwindcss": "^3.4.1",
113
151
  "typescript": "^5.3.3",
114
- "vitest": "^3.2.4",
115
- "ws": "^8.21.0",
116
- "@types/ws": "^8.5.13"
152
+ "vite": "6.4.3",
153
+ "vitest": "^3.2.7",
154
+ "ws": "^8.21.0"
117
155
  }
118
156
  }
@@ -1,30 +1,30 @@
1
- import type { Config } from 'tailwindcss';
2
- import fs from 'node:fs';
3
- import path from 'node:path';
1
+ import type { Config } from 'tailwindcss';
2
+ import fs from 'node:fs';
3
+ import path from 'node:path';
4
4
  import { createRequire } from 'node:module';
5
5
  import { fileURLToPath } from 'node:url';
6
- import { getSomaAssetSources } from './core/host/source-packages';
7
-
8
- /**
9
- * Framework Tailwind config (loaded with soma-core / Next).
6
+ import { getSomaAssetSources } from './core/server/host/source-packages';
7
+
8
+ /**
9
+ * Framework Tailwind config (loaded with soma-core / Next).
10
10
  * Host theme/plugins come from SOMA_HOST_DIR/tailwind.config.cjs/js via presets.
11
- */
12
- if (!process.env.SOMA_HOST_DIR) {
13
- throw new Error('[soma-core] tailwind: SOMA_HOST_DIR is not set');
14
- }
15
- const hostDir = path.resolve(process.env.SOMA_HOST_DIR);
16
- const require = createRequire(fileURLToPath(import.meta.url));
17
-
11
+ */
12
+ if (!process.env.SOMA_HOST_DIR) {
13
+ throw new Error('[soma-core] tailwind: SOMA_HOST_DIR is not set');
14
+ }
15
+ const hostDir = path.resolve(process.env.SOMA_HOST_DIR);
16
+ const require = createRequire(fileURLToPath(import.meta.url));
17
+
18
18
  function loadHostPreset(): Config | null {
19
19
  for (const name of ['tailwind.config.cjs', 'tailwind.config.js']) {
20
- const cfgPath = path.join(hostDir, name);
21
- if (!fs.existsSync(cfgPath)) continue;
22
- const mod = require(cfgPath) as Config | { default: Config };
23
- return ('default' in mod && mod.default) ? mod.default : (mod as Config);
24
- }
25
- return null;
26
- }
27
-
20
+ const cfgPath = path.join(hostDir, name);
21
+ if (!fs.existsSync(cfgPath)) continue;
22
+ const mod = require(cfgPath) as Config | { default: Config };
23
+ return ('default' in mod && mod.default) ? mod.default : (mod as Config);
24
+ }
25
+ return null;
26
+ }
27
+
28
28
  const hostPreset = loadHostPreset();
29
29
  const sourceContent = getSomaAssetSources(hostDir).flatMap((source) => [
30
30
  path.join(source.assetRoot, 'html/**/*.html'),
@@ -40,5 +40,5 @@ const config: Config = {
40
40
  ...sourceContent,
41
41
  ],
42
42
  };
43
-
44
- export default config;
43
+
44
+ export default config;
package/tsconfig.json CHANGED
@@ -20,11 +20,7 @@
20
20
  ],
21
21
  "paths": {
22
22
  "@core/*": ["./core/*"],
23
- "@/*": ["./*"],
24
- "@soma-host/config/locale.yaml": ["./tests/fixtures/host/config/locale.stub.ts"],
25
- "@soma-host/config/app.config.yaml": ["./tests/fixtures/host/config/app.config.stub.ts"],
26
- "@soma-host/bootstrap/soma-bootstrap": ["./tests/fixtures/host/bootstrap/soma-bootstrap.ts"],
27
- "@soma-host/*": ["./tests/fixtures/host/*"]
23
+ "@/*": ["./*"]
28
24
  },
29
25
  "baseUrl": "."
30
26
  },
@@ -1,119 +0,0 @@
1
- // URL → html/ui/event files: / → index.html, /a/b → a/b.html; */index.html also maps to short path /a
2
-
3
- import { existsSync } from 'fs';
4
- import { join, resolve } from 'path';
5
- import { NextRequest } from 'next/server';
6
- import { isSafePageBase, urlPathToCandidates } from '../../../core/compiler/page-base-resolver';
7
- import { getSomaAssetSources, type SomaAssetSource } from '../../../core/host/source-packages';
8
- import { ServerFileCache } from '../../../core/infra/cache/ServerFileCache';
9
-
10
- const cache = ServerFileCache.getInstance();
11
-
12
- function getHostDir(): string | undefined {
13
- return process.env.SOMA_HOST_DIR || undefined;
14
- }
15
-
16
- const watchedRoots = new Set<string>();
17
-
18
- function ensureWatch(root: string) {
19
- if (watchedRoots.has(root)) return;
20
- watchedRoots.add(root);
21
- cache.watchAndInvalidate(root);
22
- }
23
-
24
- function resolvePageSource(sources: SomaAssetSource[], urlPath: string): { source: SomaAssetSource; base: string } | null {
25
- for (const candidate of urlPathToCandidates(urlPath)) {
26
- if (!isSafePageBase(candidate)) continue;
27
- for (const source of sources) {
28
- const htmlPath = join(source.assetRoot, 'html', `${candidate}.html`);
29
- if (existsSync(htmlPath)) {
30
- return { source, base: candidate };
31
- }
32
- }
33
- }
34
- return null;
35
- }
36
-
37
- function collectIncludes(sources: SomaAssetSource[]): Record<string, string> {
38
- const includes: Record<string, string> = {};
39
- const ordered = [
40
- ...sources.filter((source) => source.type === 'package'),
41
- ...sources.filter((source) => source.type === 'host'),
42
- ];
43
- for (const source of ordered) {
44
- const sharedDir = join(source.assetRoot, 'html', 'shared');
45
- try {
46
- const files = cache.readDirFiles(sharedDir, '.html');
47
- const names = cache.readDirNames(sharedDir, '.html');
48
- for (let i = 0; i < names.length; i++) {
49
- includes[`shared/${names[i]}`] = files[i];
50
- }
51
- } catch {}
52
- }
53
- return includes;
54
- }
55
-
56
- export async function GET(req: NextRequest) {
57
- const hostDir = getHostDir();
58
- if (!hostDir) {
59
- return Response.json(
60
- { error: 'SOMA_HOST_DIR is not set. Run: npx soma dev from your app root.' },
61
- { status: 503 },
62
- );
63
- }
64
-
65
- const sources = getSomaAssetSources(hostDir);
66
- sources.forEach((source) => ensureWatch(source.assetRoot));
67
- sources.forEach((source) => {
68
- if (source.codeRoot !== source.assetRoot) {
69
- ensureWatch(source.codeRoot);
70
- }
71
- });
72
-
73
- const urlPath = req.nextUrl.searchParams.get('path') || '/';
74
- const resolvedPage = resolvePageSource(sources, urlPath);
75
-
76
- if (!resolvedPage) {
77
- return Response.json({ error: `Page not found: ${urlPath}` }, { status: 404 });
78
- }
79
-
80
- const { source, base } = resolvedPage;
81
- const htmlPath = join(source.assetRoot, 'html', `${base}.html`);
82
- const resolvedHtml = resolve(htmlPath);
83
- const resolvedSourceHtml = resolve(source.assetRoot, 'html');
84
- if (!resolvedHtml.startsWith(resolvedSourceHtml)) {
85
- return Response.json({ error: 'Invalid path' }, { status: 400 });
86
- }
87
-
88
- try {
89
- const html = cache.readFile(htmlPath);
90
-
91
- let ui: string, event: string, style: string, localeYaml: string, appConfigYaml: string;
92
- try {
93
- ui = cache.tryReadFile(join(source.assetRoot, 'ui', `${base}_ui.yaml`));
94
- event = cache.tryReadFile(join(source.assetRoot, 'event', `${base}_event.yaml`));
95
- style = cache.tryReadFile(join(source.assetRoot, 'ui', `${base}_style.yaml`));
96
- localeYaml = cache.tryReadFile(join(hostDir, 'config', 'locale.yaml'));
97
- appConfigYaml = cache.tryReadFile(join(hostDir, 'config', 'app.config.yaml'));
98
- } catch (e: any) {
99
- return Response.json({ error: `Asset read error: ${e.message}` }, { status: 500 });
100
- }
101
-
102
- const includes = collectIncludes(sources);
103
-
104
- return Response.json({
105
- base,
106
- sourceType: source.type,
107
- sourcePackage: source.packageName ?? null,
108
- html,
109
- ui,
110
- event,
111
- styleYaml: style,
112
- localeYaml,
113
- appConfigYaml,
114
- includes,
115
- });
116
- } catch (e: any) {
117
- return Response.json({ error: `Page not found: ${base}.html` }, { status: 404 });
118
- }
119
- }
package/app/loading.tsx DELETED
@@ -1,5 +0,0 @@
1
- import { SomaHydrationShell } from './components/SomaHydrationShell';
2
-
3
- export default function Loading() {
4
- return <SomaHydrationShell />;
5
- }
@@ -1,38 +0,0 @@
1
- /** HOST 配置同步 — 供 bin/soma-sync.cjs 使用 */
2
- const fs = require('node:fs');
3
- const path = require('node:path');
4
-
5
- const SYNC_FILES = [
6
- 'config/locale.yaml',
7
- 'config/app.config.yaml',
8
- 'tailwind.config.js',
9
- ];
10
-
11
- function syncHostConfig(hostDir, outputDir) {
12
- const target = outputDir ?? path.join(hostDir, '.soma-sync');
13
- const copied = [];
14
- const skipped = [];
15
-
16
- if (!fs.existsSync(target)) fs.mkdirSync(target, { recursive: true });
17
-
18
- for (const rel of SYNC_FILES) {
19
- const src = path.join(hostDir, rel);
20
- const dest = path.join(target, rel);
21
- if (!fs.existsSync(src)) {
22
- skipped.push(rel);
23
- continue;
24
- }
25
- fs.mkdirSync(path.dirname(dest), { recursive: true });
26
- fs.copyFileSync(src, dest);
27
- copied.push(rel);
28
- }
29
-
30
- fs.writeFileSync(
31
- path.join(target, 'sync-manifest.json'),
32
- JSON.stringify({ syncedAt: new Date().toISOString(), hostDir, files: copied }, null, 2),
33
- );
34
-
35
- return { copied, skipped, target };
36
- }
37
-
38
- module.exports = { syncHostConfig, SYNC_FILES };
@@ -1,8 +0,0 @@
1
- export interface SomaAssetSource {
2
- type: 'host' | 'package';
3
- name: string;
4
- assetRoot: string;
5
- codeRoot: string;
6
- packageName?: string;
7
- }
8
- export declare function getSomaAssetSources(hostDir: string): SomaAssetSource[];
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes