akanjs 3.3.0-rc.8 → 3.3.0-rc.80

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 (608) hide show
  1. package/README.ko.md +9 -5
  2. package/README.md +7 -5
  3. package/base/utils.ts +2 -0
  4. package/client/appOpenedTab.ts +2 -1
  5. package/client/clientRuntime.ts +2 -0
  6. package/client/cookie.ts +15 -6
  7. package/client/csrLocation.ts +61 -9
  8. package/client/csrRuntimeParams.ts +33 -0
  9. package/client/csrTypes.ts +22 -2
  10. package/client/device.ts +26 -14
  11. package/client/dictionaryAsset.ts +103 -25
  12. package/client/dictionaryGroups.ts +113 -0
  13. package/client/dictionaryModule.ts +23 -0
  14. package/client/dictionaryPart.ts +113 -0
  15. package/client/frameConfig.ts +9 -0
  16. package/client/index.ts +10 -0
  17. package/client/keyboardRide.ts +396 -0
  18. package/client/makePageProto.tsx +22 -2
  19. package/client/nativeBoot.ts +3 -0
  20. package/client/nativeErrorReport.ts +55 -0
  21. package/client/nativeHost.ts +2 -31
  22. package/client/nativeShell.ts +32 -0
  23. package/client/notFoundView.ts +9 -0
  24. package/client/pendingNavigation.ts +103 -0
  25. package/client/pressLoading.ts +29 -0
  26. package/client/redirectMove.ts +13 -0
  27. package/client/reportText.ts +27 -0
  28. package/client/route/RouteDefinition.ts +33 -7
  29. package/client/router.ts +39 -26
  30. package/client/rscClientErrorSender.ts +85 -0
  31. package/client/rscNavigation.ts +8 -1
  32. package/client/scriptPolicy.ts +14 -0
  33. package/client/sharedContext.ts +3 -1
  34. package/client/sharedContextKey.ts +2 -0
  35. package/client/shellState.ts +151 -0
  36. package/client/shellStateHooks.ts +2 -0
  37. package/client/translator.ts +7 -1
  38. package/client/translatorState.ts +18 -1
  39. package/client/usePendingNavigation.ts +38 -0
  40. package/common/Logger.ts +1 -1
  41. package/common/TraceContext.ts +5 -3
  42. package/common/index.ts +1 -0
  43. package/common/sessionTokenContract.ts +7 -0
  44. package/common/websocketContract.ts +5 -2
  45. package/constant/constantRegistry.ts +36 -33
  46. package/constant/immerable.ts +2 -0
  47. package/constant/immerify.ts +1 -1
  48. package/constant/index.ts +1 -0
  49. package/constant/inputParser.ts +7 -0
  50. package/constant/types.ts +10 -9
  51. package/constant/via.ts +1 -1
  52. package/dictionary/agent.dictionary.ts +4 -0
  53. package/fetch/client/fetchClient.ts +22 -42
  54. package/fetch/client/fetchHandle.ts +3 -1
  55. package/fetch/client/httpClient.ts +15 -1
  56. package/fetch/client/modelRuntimes.ts +89 -0
  57. package/fetch/client/requestScope.ts +4 -1
  58. package/fetch/client/signalCatalog.ts +9 -4
  59. package/fetch/client/sliceInitHandle.ts +5 -3
  60. package/fetch/client/wsClient.ts +10 -1
  61. package/fetch/fetchType/appliedReturn.type.ts +4 -2
  62. package/fetch/requestStorage.ts +20 -0
  63. package/index.ts +58 -1
  64. package/package.json +17 -2
  65. package/server/SSR_MEMORY_DIAGNOSIS.md +4 -0
  66. package/server/akanApp.ts +21 -5
  67. package/server/akanOption.ts +28 -0
  68. package/server/akanServer.ts +136 -40
  69. package/server/appWorker.ts +177 -0
  70. package/server/appWorkerError.ts +5 -0
  71. package/server/appWorkerPath.ts +22 -0
  72. package/server/artifact/builderRpc.ts +1 -0
  73. package/server/artifact/ipcTypes.ts +4 -0
  74. package/server/artifact/routeClientCache.ts +4 -0
  75. package/server/assetHeaders.ts +11 -8
  76. package/server/clientErrorReport.ts +248 -0
  77. package/server/clientReportId.ts +54 -0
  78. package/server/devtools/devtoolsRouter.ts +27 -16
  79. package/server/devtools/signalSerializer.ts +18 -1
  80. package/server/devtools/studio/studioDocument.tsx +3 -1
  81. package/server/devtools/studio/studioRoute.ts +5 -2
  82. package/server/devtools/types.ts +6 -0
  83. package/server/di/diLifecycle.ts +25 -186
  84. package/server/di/moduleSelection.ts +202 -0
  85. package/server/flightSanitizeRecorded.fixture.json +36 -34
  86. package/server/forwardedError.ts +43 -0
  87. package/server/gateway/childSupervisor.ts +8 -4
  88. package/server/gateway/gatewayChildren.ts +1 -0
  89. package/server/gateway/gatewayConfig.ts +5 -0
  90. package/server/gateway/gatewayHttpProxy.ts +1 -1
  91. package/server/gateway/gatewayStatus.ts +11 -1
  92. package/server/gateway/gatewayStatusPage.ts +18 -11
  93. package/server/headSplice.ts +73 -0
  94. package/server/hmr/clientReport.ts +9 -9
  95. package/server/hmr/clientScript.ts +4 -1
  96. package/server/hmr/csrDevShell.ts +7 -4
  97. package/server/hmr/devArtifactPruner.ts +7 -1
  98. package/server/hmr/devBaseArtifact.ts +5 -1
  99. package/server/hmr/wsHub.ts +1 -0
  100. package/server/htmlResultCache.ts +107 -39
  101. package/server/index.ts +5 -0
  102. package/server/lifecycle/buildEnv.ts +2 -0
  103. package/server/lifecycle/envProfile.ts +27 -0
  104. package/server/lifecycle/parentChannel.ts +11 -4
  105. package/server/lifecycle/secretEnv.ts +98 -0
  106. package/server/lifecycle/shutdownManager.ts +6 -0
  107. package/server/logging/logForwarder.ts +2 -2
  108. package/server/logging/serverLogging.ts +24 -10
  109. package/server/mcp/McpAppFrame.ts +42 -0
  110. package/server/mcp/McpAuth.ts +12 -2
  111. package/server/mcp/McpDispatcher.ts +20 -3
  112. package/server/mcp/McpFoundTools.ts +69 -0
  113. package/server/mcp/McpRouter.ts +165 -166
  114. package/server/mcp/McpSearch.ts +161 -0
  115. package/server/mcp/McpShelves.ts +95 -0
  116. package/server/mcp/McpWire.ts +92 -0
  117. package/server/mcp/index.ts +2 -0
  118. package/server/metrics/metricMerge.ts +1 -1
  119. package/server/metrics/pubsubGauges.ts +27 -0
  120. package/server/metrics/slowStatementLog.ts +63 -0
  121. package/server/metrics/statementMetrics.ts +259 -0
  122. package/server/metrics/statementPlanCheck.ts +141 -0
  123. package/server/metrics/statementReport.ts +105 -0
  124. package/server/migration/migrationRunner.ts +13 -10
  125. package/server/oauth/OAuthAuthorize.ts +8 -3
  126. package/server/oauth/OAuthErrors.ts +5 -1
  127. package/server/ops/statusAccess.ts +10 -2
  128. package/server/otlp/otlpBatcher.ts +221 -0
  129. package/server/otlp/otlpConfig.ts +185 -0
  130. package/server/otlp/otlpEncode.ts +114 -0
  131. package/server/otlp/otlpExporter.ts +98 -0
  132. package/server/otlp/otlpSampler.ts +50 -0
  133. package/server/pageFailure.ts +33 -0
  134. package/server/renderBusyResponse.ts +7 -2
  135. package/server/resolver/timedQuery.ts +7 -3
  136. package/server/resolver/unmountedRoutes.ts +55 -0
  137. package/server/routeCacheTally.ts +6 -0
  138. package/server/routeElementComposer.tsx +38 -3
  139. package/server/routeLevelRuns.ts +72 -0
  140. package/server/routeState.ts +1 -1
  141. package/server/routeTreeBuilder.ts +30 -1
  142. package/server/routing/apiRouter.ts +24 -7
  143. package/server/routing/appWsData.ts +4 -1
  144. package/server/routing/builtinRoutes.ts +13 -1
  145. package/server/routing/devBuild.ts +4 -0
  146. package/server/routing/devSurfacePolicy.ts +2 -1
  147. package/server/routing/devSurfaces.ts +4 -0
  148. package/server/routing/roomReplay.ts +4 -0
  149. package/server/routing/serverListener.ts +125 -55
  150. package/server/routing/soloAppRoutes.ts +7 -1
  151. package/server/routing/webSurfaceHold.ts +117 -0
  152. package/server/routing/wsCredentialRevocation.ts +55 -0
  153. package/server/rscClient.tsx +74 -7
  154. package/server/rscClientChunks.ts +8 -1
  155. package/server/rscClientErrors.ts +28 -0
  156. package/server/rscFirstRenderMemory.ts +49 -0
  157. package/server/rscFlightRenderer.ts +21 -4
  158. package/server/rscFlightStream.ts +2 -2
  159. package/server/rscPatchPlanner.ts +35 -9
  160. package/server/rscPrefetchCache.ts +19 -5
  161. package/server/rscPressLoading.tsx +40 -0
  162. package/server/rscRenderHandler.ts +19 -3
  163. package/server/rscRenderStats.ts +3 -0
  164. package/server/rscRouteDocument.tsx +2 -2
  165. package/server/rscSegmentOutlet.tsx +21 -1
  166. package/server/rscSegmentOutletReference.ts +2 -1
  167. package/server/rscWorker.tsx +5 -1
  168. package/server/rscWorkerCache.ts +3 -1
  169. package/server/rscWorkerHost.ts +19 -2
  170. package/server/rscWorkerProcess.ts +12 -0
  171. package/server/rscWorkerRecycler.ts +3 -3
  172. package/server/scriptPolicy.ts +161 -0
  173. package/server/scriptPolicyReport.ts +147 -0
  174. package/server/selfExec.ts +13 -1
  175. package/server/serverConfig.ts +12 -0
  176. package/server/serverMetrics.ts +21 -2
  177. package/server/ssrFromRscRenderer.tsx +29 -201
  178. package/server/ssrInlineScripts.ts +202 -0
  179. package/server/ssrTypes.ts +9 -2
  180. package/server/systemPageDocument.tsx +6 -2
  181. package/server/systemPages.tsx +9 -4
  182. package/server/types.tsx +12 -0
  183. package/server/vendor/akanjs-client.ts +1 -0
  184. package/server/webArtifact.ts +16 -5
  185. package/server/webCsrSurface.ts +34 -12
  186. package/server/webDocumentRoute.ts +48 -18
  187. package/server/webRouteContext.ts +34 -7
  188. package/server/webRouter.ts +8 -0
  189. package/server/webRscRoute.ts +6 -3
  190. package/service/agent.service.ts +1 -0
  191. package/service/agentLoop/agentLoop.ts +58 -19
  192. package/service/agentLoop/agentLoopTypes.ts +45 -0
  193. package/service/agentLoop/loopCompaction.ts +14 -4
  194. package/service/agentLoop/loopContext.ts +5 -2
  195. package/service/agentLoop/loopLent.ts +80 -0
  196. package/service/agentLoop/loopRequest.ts +25 -2
  197. package/service/agentLoop/loopToolBudget.ts +37 -0
  198. package/service/agentLoop/loopToolSearch.ts +85 -0
  199. package/service/agentLoop/loopToolkits.ts +223 -32
  200. package/service/agentLoop/loopTranscript.ts +1 -1
  201. package/service/ipcTypes.ts +38 -1
  202. package/service/predefinedAdaptor/anthropicLlm.ts +336 -56
  203. package/service/predefinedAdaptor/anthropicTools.ts +59 -0
  204. package/service/predefinedAdaptor/database.adaptor.ts +41 -9
  205. package/service/predefinedAdaptor/index.ts +1 -0
  206. package/service/predefinedAdaptor/llm.adaptor.ts +34 -0
  207. package/service/predefinedAdaptor/llmOverflow.ts +19 -0
  208. package/service/predefinedAdaptor/openaiDialect.ts +27 -13
  209. package/service/predefinedAdaptor/openaiLlm.ts +1 -2
  210. package/service/predefinedAdaptor/solidPubsub.adaptor.ts +16 -0
  211. package/service/predefinedAdaptor/sql/driver/bunSqlite.ts +49 -11
  212. package/service/predefinedAdaptor/sql/driver/postgres.ts +47 -10
  213. package/service/predefinedAdaptor/sql/statementFingerprint.ts +117 -0
  214. package/service/predefinedAdaptor/sql/statementPlans.ts +71 -0
  215. package/service/predefinedAdaptor/sql/statementProbe.ts +110 -0
  216. package/service/predefinedAdaptor/sql/statementScrub.ts +149 -0
  217. package/service/predefinedAdaptor/websocket.adaptor.ts +62 -16
  218. package/service/toolNames.ts +7 -1
  219. package/signal/CrossSiteGuard.ts +5 -0
  220. package/signal/browserError.ts +28 -0
  221. package/signal/endpointInfo.ts +2 -1
  222. package/signal/errorReporting.ts +168 -0
  223. package/signal/index.ts +2 -0
  224. package/signal/internalInfo.ts +2 -2
  225. package/signal/mcp/McpDocument.ts +13 -4
  226. package/signal/mcp/mcpProtocol.ts +6 -0
  227. package/signal/requestTrace.ts +40 -3
  228. package/signal/roomKey.ts +3 -6
  229. package/signal/signalContext.ts +4 -4
  230. package/signal/spanExport.ts +137 -0
  231. package/signal/trace.ts +41 -10
  232. package/store/actionErrorMessage.ts +15 -1
  233. package/store/agent/AgentContext.ts +48 -8
  234. package/store/agent/AgentInline.ts +50 -0
  235. package/store/agent/AgentVisual.ts +3 -2
  236. package/store/agent/ScreenReader.ts +7 -1
  237. package/store/agent/ScreenSettle.ts +29 -0
  238. package/store/agent/ScreenTarget.ts +2 -2
  239. package/store/agent/StoreCatalogue.ts +1 -1
  240. package/store/agent/StoreSurfaceSource.ts +70 -17
  241. package/store/agentic/AgentNavigate.ts +20 -0
  242. package/store/agentic/fieldToolEntries.ts +374 -0
  243. package/store/agentic/fieldTools.ts +49 -0
  244. package/store/agentic/formFields.ts +7 -2
  245. package/store/agentic/formFieldsReexport.ts +2 -0
  246. package/store/agentic/index.ts +2 -1
  247. package/store/agentic/useFieldTool.ts +3 -248
  248. package/store/agentic/useFormTools.ts +3 -45
  249. package/store/agentic/useRelationFieldTool.ts +2 -60
  250. package/store/baseSt.ts +7 -6
  251. package/store/draftStore.ts +2 -2
  252. package/store/formUploadOf.ts +6 -3
  253. package/store/index.ts +2 -0
  254. package/store/shellMirror.ts +49 -0
  255. package/store/sliceLiveActions.ts +4 -3
  256. package/store/storeFacade.ts +50 -0
  257. package/store/storeInstance.ts +92 -72
  258. package/test/signalTestRuntime.ts +9 -2
  259. package/test/testServer.ts +7 -1
  260. package/types/base/utils.d.ts +1 -0
  261. package/types/client/clientRuntime.d.ts +4 -0
  262. package/types/client/cookie.d.ts +4 -3
  263. package/types/client/csrLocation.d.ts +11 -3
  264. package/types/client/csrRuntimeParams.d.ts +6 -0
  265. package/types/client/csrTypes.d.ts +21 -2
  266. package/types/client/device.d.ts +3 -1
  267. package/types/client/dictionaryAsset.d.ts +4 -1
  268. package/types/client/dictionaryGroups.d.ts +7 -0
  269. package/types/client/dictionaryModule.d.ts +10 -0
  270. package/types/client/dictionaryPart.d.ts +13 -0
  271. package/types/client/index.d.ts +8 -3
  272. package/types/client/keyboardRide.d.ts +20 -0
  273. package/types/client/makePageProto.d.ts +1 -1
  274. package/types/client/nativeErrorReport.d.ts +10 -0
  275. package/types/client/nativeHost.d.ts +1 -6
  276. package/types/client/nativeShell.d.ts +10 -0
  277. package/types/client/notFoundView.d.ts +8 -0
  278. package/types/client/pendingNavigation.d.ts +35 -0
  279. package/types/client/pressLoading.d.ts +4 -0
  280. package/types/client/redirectMove.d.ts +5 -0
  281. package/types/client/reportText.d.ts +4 -0
  282. package/types/client/route/RouteDefinition.d.ts +12 -1
  283. package/types/client/router.d.ts +9 -1
  284. package/types/client/rscClientErrorSender.d.ts +12 -0
  285. package/types/client/rscNavigation.d.ts +2 -0
  286. package/types/client/scriptPolicy.d.ts +4 -0
  287. package/types/client/sharedContextKey.d.ts +2 -0
  288. package/types/client/shellState.d.ts +54 -0
  289. package/types/client/shellStateHooks.d.ts +1 -0
  290. package/types/client/translator.d.ts +1 -0
  291. package/types/client/translatorState.d.ts +9 -1
  292. package/types/client/usePendingNavigation.d.ts +10 -0
  293. package/types/common/TraceContext.d.ts +1 -0
  294. package/types/common/index.d.ts +1 -0
  295. package/types/common/sessionTokenContract.d.ts +6 -0
  296. package/types/common/websocketContract.d.ts +1 -0
  297. package/types/constant/immerable.d.ts +1 -0
  298. package/types/constant/index.d.ts +1 -1
  299. package/types/constant/types.d.ts +6 -5
  300. package/types/dictionary/agent.dictionary.d.ts +1 -1
  301. package/types/dictionary/dictionary.d.ts +4 -4
  302. package/types/fetch/client/fetchClient.d.ts +3 -0
  303. package/types/fetch/client/httpClient.d.ts +1 -0
  304. package/types/fetch/client/modelRuntimes.d.ts +17 -0
  305. package/types/fetch/client/signalCatalog.d.ts +2 -1
  306. package/types/fetch/client/wsClient.d.ts +3 -1
  307. package/types/fetch/fetchType/appliedReturn.type.d.ts +4 -0
  308. package/types/fetch/requestStorage.d.ts +6 -0
  309. package/types/index.d.ts +58 -1
  310. package/types/server/akanOption.d.ts +16 -1
  311. package/types/server/akanServer.d.ts +15 -1
  312. package/types/server/appWorker.d.ts +40 -0
  313. package/types/server/appWorkerError.d.ts +4 -0
  314. package/types/server/appWorkerPath.d.ts +9 -0
  315. package/types/server/artifact/ipcTypes.d.ts +4 -0
  316. package/types/server/artifact/routeClientCache.d.ts +1 -0
  317. package/types/server/assetHeaders.d.ts +7 -4
  318. package/types/server/clientErrorReport.d.ts +28 -0
  319. package/types/server/clientReportId.d.ts +9 -0
  320. package/types/server/devtools/signalSerializer.d.ts +3 -1
  321. package/types/server/devtools/studio/studioDocument.d.ts +1 -0
  322. package/types/server/devtools/types.d.ts +5 -0
  323. package/types/server/di/diLifecycle.d.ts +2 -1
  324. package/types/server/di/moduleSelection.d.ts +22 -0
  325. package/types/server/forwardedError.d.ts +13 -0
  326. package/types/server/gateway/gatewayChildren.d.ts +1 -0
  327. package/types/server/gateway/gatewayConfig.d.ts +1 -0
  328. package/types/server/gateway/gatewayStatus.d.ts +1 -0
  329. package/types/server/headSplice.d.ts +11 -0
  330. package/types/server/hmr/clientReport.d.ts +2 -0
  331. package/types/server/hmr/csrDevShell.d.ts +3 -1
  332. package/types/server/hmr/devBaseArtifact.d.ts +1 -0
  333. package/types/server/hmr/wsHub.d.ts +1 -0
  334. package/types/server/htmlResultCache.d.ts +8 -1
  335. package/types/server/index.d.ts +5 -1
  336. package/types/server/lifecycle/buildEnv.d.ts +1 -0
  337. package/types/server/lifecycle/envProfile.d.ts +7 -0
  338. package/types/server/lifecycle/parentChannel.d.ts +2 -2
  339. package/types/server/lifecycle/secretEnv.d.ts +20 -0
  340. package/types/server/logging/logForwarder.d.ts +1 -0
  341. package/types/server/logging/rotatingLogWriter.d.ts +1 -1
  342. package/types/server/logging/serverLogging.d.ts +1 -0
  343. package/types/server/mcp/McpAppFrame.d.ts +9 -0
  344. package/types/server/mcp/McpAuth.d.ts +2 -0
  345. package/types/server/mcp/McpDispatcher.d.ts +7 -2
  346. package/types/server/mcp/McpFoundTools.d.ts +14 -0
  347. package/types/server/mcp/McpRouter.d.ts +6 -0
  348. package/types/server/mcp/McpSearch.d.ts +40 -0
  349. package/types/server/mcp/McpShelves.d.ts +30 -0
  350. package/types/server/mcp/McpWire.d.ts +39 -0
  351. package/types/server/mcp/index.d.ts +2 -0
  352. package/types/server/metrics/pubsubGauges.d.ts +6 -0
  353. package/types/server/metrics/slowStatementLog.d.ts +18 -0
  354. package/types/server/metrics/statementMetrics.d.ts +45 -0
  355. package/types/server/metrics/statementPlanCheck.d.ts +16 -0
  356. package/types/server/metrics/statementReport.d.ts +28 -0
  357. package/types/server/oauth/OAuthAuthorize.d.ts +5 -2
  358. package/types/server/ops/statusAccess.d.ts +1 -0
  359. package/types/server/otlp/otlpBatcher.d.ts +18 -0
  360. package/types/server/otlp/otlpConfig.d.ts +25 -0
  361. package/types/server/otlp/otlpEncode.d.ts +13 -0
  362. package/types/server/otlp/otlpExporter.d.ts +18 -0
  363. package/types/server/otlp/otlpSampler.d.ts +10 -0
  364. package/types/server/pageFailure.d.ts +14 -0
  365. package/types/server/resolver/timedQuery.d.ts +1 -0
  366. package/types/server/resolver/unmountedRoutes.d.ts +6 -0
  367. package/types/server/routeCacheTally.d.ts +1 -1
  368. package/types/server/routeElementComposer.d.ts +8 -2
  369. package/types/server/routeLevelRuns.d.ts +12 -0
  370. package/types/server/routing/apiRouter.d.ts +1 -0
  371. package/types/server/routing/appWsData.d.ts +1 -0
  372. package/types/server/routing/devBuild.d.ts +3 -0
  373. package/types/server/routing/roomReplay.d.ts +1 -0
  374. package/types/server/routing/serverListener.d.ts +6 -1
  375. package/types/server/routing/soloAppRoutes.d.ts +2 -1
  376. package/types/server/routing/webSurfaceHold.d.ts +13 -0
  377. package/types/server/routing/wsCredentialRevocation.d.ts +13 -0
  378. package/types/server/rscClient.d.ts +2 -0
  379. package/types/server/rscClientChunks.d.ts +3 -1
  380. package/types/server/rscClientErrors.d.ts +3 -0
  381. package/types/server/rscFirstRenderMemory.d.ts +16 -0
  382. package/types/server/rscFlightStream.d.ts +1 -1
  383. package/types/server/rscPatchPlanner.d.ts +1 -1
  384. package/types/server/rscPrefetchCache.d.ts +1 -0
  385. package/types/server/rscPressLoading.d.ts +5 -0
  386. package/types/server/rscRenderStats.d.ts +2 -0
  387. package/types/server/rscSegmentOutlet.d.ts +4 -1
  388. package/types/server/rscSegmentOutletReference.d.ts +2 -1
  389. package/types/server/rscWorkerCache.d.ts +3 -1
  390. package/types/server/rscWorkerProcess.d.ts +1 -0
  391. package/types/server/rscWorkerRecycler.d.ts +1 -1
  392. package/types/server/scriptPolicy.d.ts +38 -0
  393. package/types/server/scriptPolicyReport.d.ts +18 -0
  394. package/types/server/selfExec.d.ts +1 -0
  395. package/types/server/serverConfig.d.ts +1 -0
  396. package/types/server/serverMetrics.d.ts +3 -1
  397. package/types/server/ssrFromRscRenderer.d.ts +2 -6
  398. package/types/server/ssrInlineScripts.d.ts +42 -0
  399. package/types/server/ssrTypes.d.ts +9 -2
  400. package/types/server/systemPageDocument.d.ts +3 -1
  401. package/types/server/systemPages.d.ts +2 -1
  402. package/types/server/types.d.ts +25 -0
  403. package/types/server/vendor/akanjs-client.d.ts +1 -0
  404. package/types/server/webRouteContext.d.ts +5 -4
  405. package/types/server/webRouter.d.ts +1 -0
  406. package/types/service/agent.service.d.ts +1 -0
  407. package/types/service/agentLoop/agentLoop.d.ts +2 -1
  408. package/types/service/agentLoop/agentLoopTypes.d.ts +43 -0
  409. package/types/service/agentLoop/loopCompaction.d.ts +2 -2
  410. package/types/service/agentLoop/loopLent.d.ts +16 -0
  411. package/types/service/agentLoop/loopToolBudget.d.ts +8 -0
  412. package/types/service/agentLoop/loopToolSearch.d.ts +13 -0
  413. package/types/service/agentLoop/loopToolkits.d.ts +9 -2
  414. package/types/service/ipcTypes.d.ts +39 -1
  415. package/types/service/predefinedAdaptor/anthropicLlm.d.ts +85 -18
  416. package/types/service/predefinedAdaptor/anthropicTools.d.ts +32 -0
  417. package/types/service/predefinedAdaptor/database.adaptor.d.ts +2 -0
  418. package/types/service/predefinedAdaptor/index.d.ts +1 -0
  419. package/types/service/predefinedAdaptor/llm.adaptor.d.ts +33 -0
  420. package/types/service/predefinedAdaptor/llmOverflow.d.ts +7 -0
  421. package/types/service/predefinedAdaptor/solidPubsub.adaptor.d.ts +3 -1
  422. package/types/service/predefinedAdaptor/sql/driver/bunSqlite.d.ts +3 -1
  423. package/types/service/predefinedAdaptor/sql/driver/postgres.d.ts +3 -1
  424. package/types/service/predefinedAdaptor/sql/statementFingerprint.d.ts +21 -0
  425. package/types/service/predefinedAdaptor/sql/statementPlans.d.ts +17 -0
  426. package/types/service/predefinedAdaptor/sql/statementProbe.d.ts +37 -0
  427. package/types/service/predefinedAdaptor/sql/statementScrub.d.ts +5 -0
  428. package/types/service/predefinedAdaptor/websocket.adaptor.d.ts +10 -0
  429. package/types/signal/CrossSiteGuard.d.ts +1 -0
  430. package/types/signal/agent.signal.d.ts +1 -0
  431. package/types/signal/browserError.d.ts +20 -0
  432. package/types/signal/endpointInfo.d.ts +2 -2
  433. package/types/signal/errorReporting.d.ts +27 -0
  434. package/types/signal/index.d.ts +2 -0
  435. package/types/signal/internalInfo.d.ts +2 -2
  436. package/types/signal/mcp/McpDocument.d.ts +3 -0
  437. package/types/signal/mcp/mcpProtocol.d.ts +5 -0
  438. package/types/signal/requestTrace.d.ts +3 -1
  439. package/types/signal/spanExport.d.ts +47 -0
  440. package/types/signal/trace.d.ts +8 -2
  441. package/types/store/actionErrorMessage.d.ts +1 -0
  442. package/types/store/agent/AgentContext.d.ts +2 -0
  443. package/types/store/agent/AgentInline.d.ts +5 -0
  444. package/types/store/agent/ScreenReader.d.ts +2 -0
  445. package/types/store/agent/ScreenSettle.d.ts +5 -0
  446. package/types/store/agent/StoreSurfaceSource.d.ts +1 -1
  447. package/types/store/agentic/AgentNavigate.d.ts +10 -0
  448. package/types/store/agentic/fieldToolEntries.d.ts +28 -0
  449. package/types/store/agentic/fieldTools.d.ts +5 -0
  450. package/types/store/agentic/formFieldsReexport.d.ts +1 -0
  451. package/types/store/agentic/index.d.ts +2 -1
  452. package/types/store/baseSt.d.ts +1 -1
  453. package/types/store/index.d.ts +1 -1
  454. package/types/store/shellMirror.d.ts +8 -0
  455. package/types/store/storeFacade.d.ts +9 -0
  456. package/types/test/signalTestRuntime.d.ts +1 -1
  457. package/types/test/testServer.d.ts +2 -0
  458. package/types/ui/Constant/schemaDoc.d.ts +1 -0
  459. package/types/ui/Data/Dashboard.d.ts +1 -0
  460. package/types/ui/Data/ListContainer.d.ts +1 -0
  461. package/types/ui/Data/QueryMaker.d.ts +1 -0
  462. package/types/ui/Data/RefPicker.d.ts +1 -0
  463. package/types/ui/Dialog/LazyLegacyModal.d.ts +1 -0
  464. package/types/ui/DismissDragGesture.d.ts +9 -0
  465. package/types/ui/Field/Text.d.ts +2 -2
  466. package/types/ui/Field/lightRefCache.d.ts +2 -1
  467. package/types/ui/Field/useRelationWindow.d.ts +2 -1
  468. package/types/ui/Link/Anchor.d.ts +4 -2
  469. package/types/ui/Load/LoadingMark.d.ts +4 -0
  470. package/types/ui/Load/Stream.d.ts +1 -1
  471. package/types/ui/Load/StreamDeferred.d.ts +11 -0
  472. package/types/ui/Load/sliceClaim.d.ts +4 -3
  473. package/types/ui/Model/resetModels.d.ts +1 -0
  474. package/types/ui/Signal/Arg.d.ts +1 -0
  475. package/types/ui/Signal/Doc.d.ts +1 -0
  476. package/types/ui/Signal/Endpoint.d.ts +1 -0
  477. package/types/ui/Signal/RestApi.d.ts +1 -0
  478. package/types/ui/Signal/WebSocket.d.ts +1 -0
  479. package/types/ui/Signal/endpointEntries.d.ts +1 -0
  480. package/types/ui/Signal/makeExample.d.ts +1 -0
  481. package/types/ui/Signal/useApiDescriptions.d.ts +1 -0
  482. package/types/ui/System/isSamePathValue.d.ts +2 -0
  483. package/types/ui/modelRuntime.d.ts +1 -0
  484. package/types/ui/useDismissDrag.d.ts +10 -3
  485. package/types/ui/useLeave.d.ts +9 -0
  486. package/types/vendor/@akanjs/native/packages/cli/src/lib/maven.d.ts +2 -2
  487. package/types/vendor/@akanjs/native/packages/core/src/boot.d.ts +2 -2
  488. package/types/vendor/@akanjs/native/plugins/keyboard/src/index.d.ts +3 -2
  489. package/types/vendor/use-agentic/types.d.ts +2 -0
  490. package/types/webkit/CsrMoves.d.ts +7 -0
  491. package/types/webkit/CsrStack.d.ts +2 -1
  492. package/types/webkit/McpAppHost.d.ts +4 -1
  493. package/types/webkit/csrPageReadiness.d.ts +18 -0
  494. package/types/webkit/csrPendingNavigation.d.ts +7 -0
  495. package/types/webkit/csrSlide.d.ts +37 -0
  496. package/types/webkit/isDragLift.d.ts +5 -0
  497. package/types/webkit/nativeNavigation.d.ts +4 -2
  498. package/types/webkit/nativeSplash.d.ts +6 -0
  499. package/types/webkit/openSurfaces.d.ts +13 -0
  500. package/types/webkit/scrollerTakesDrag.d.ts +4 -0
  501. package/types/webkit/useCsrNavigation.d.ts +2 -2
  502. package/types/webkit/useEscapeKey.d.ts +7 -2
  503. package/types/webkit/useFrameRuntime.d.ts +5 -2
  504. package/types/webkit/useResolvedFrame.d.ts +2 -0
  505. package/ui/Agent/Chat.tsx +65 -46
  506. package/ui/Agent/agentSessionOf.ts +2 -1
  507. package/ui/Agent/fetchRunner.ts +5 -1
  508. package/ui/Agent/useKeyboardFrame.ts +4 -2
  509. package/ui/BottomSheet.tsx +3 -7
  510. package/ui/Constant/schemaDoc.ts +1 -0
  511. package/ui/Copy.tsx +5 -3
  512. package/ui/Data/Dashboard.tsx +1 -0
  513. package/ui/Data/ListContainer.tsx +1 -0
  514. package/ui/Data/QueryMaker.tsx +1 -0
  515. package/ui/Data/RefPicker.tsx +1 -0
  516. package/ui/Dialog/LazyLegacyModal.tsx +5 -0
  517. package/ui/Dialog/LegacyModal.tsx +3 -4
  518. package/ui/Dialog/Modal.tsx +40 -22
  519. package/ui/Dialog/index.tsx +2 -2
  520. package/ui/Dialog/modalSurface.ts +6 -4
  521. package/ui/DismissDragGesture.tsx +19 -0
  522. package/ui/DragAction.tsx +9 -4
  523. package/ui/Field/Label.tsx +5 -2
  524. package/ui/Field/Text.tsx +7 -4
  525. package/ui/Field/index.tsx +2 -3
  526. package/ui/Field/lightRefCache.ts +9 -8
  527. package/ui/Field/useRelationOptions.ts +2 -2
  528. package/ui/Field/useRelationWindow.ts +9 -4
  529. package/ui/Input.tsx +1 -1
  530. package/ui/Link/Anchor.tsx +34 -5
  531. package/ui/Link/activePath.ts +2 -3
  532. package/ui/Link/index.tsx +11 -1
  533. package/ui/Load/LoadingMark.tsx +8 -0
  534. package/ui/Load/PageCSR.tsx +3 -1
  535. package/ui/Load/Stream.tsx +11 -1
  536. package/ui/Load/StreamDeferred.tsx +27 -0
  537. package/ui/Load/Units.tsx +4 -3
  538. package/ui/Load/sliceClaim.ts +11 -5
  539. package/ui/Model/EditModal.tsx +6 -7
  540. package/ui/Model/EditWrapper.tsx +2 -3
  541. package/ui/Model/NewWrapper_Client.tsx +2 -3
  542. package/ui/Model/ViewEditModal.tsx +4 -5
  543. package/ui/Model/ViewModal.tsx +2 -3
  544. package/ui/Model/ViewWrapper.tsx +2 -3
  545. package/ui/Model/editSeed.ts +1 -1
  546. package/ui/Model/resetModels.ts +11 -0
  547. package/ui/Signal/Arg.tsx +4 -1
  548. package/ui/Signal/Doc.tsx +12 -3
  549. package/ui/Signal/Endpoint.tsx +4 -1
  550. package/ui/Signal/RestApi.tsx +1 -0
  551. package/ui/Signal/WebSocket.tsx +1 -0
  552. package/ui/Signal/endpointEntries.ts +1 -0
  553. package/ui/Signal/makeExample.ts +1 -0
  554. package/ui/Signal/useApiDescriptions.ts +10 -0
  555. package/ui/System/CSR.tsx +31 -12
  556. package/ui/System/Client.tsx +75 -61
  557. package/ui/System/Messages.tsx +31 -47
  558. package/ui/System/isSamePathValue.ts +13 -0
  559. package/ui/Tooltip.tsx +1 -1
  560. package/ui/agentAttrs.ts +1 -1
  561. package/ui/modelRuntime.ts +2 -0
  562. package/ui/styles.css +14 -0
  563. package/ui/useDismissDrag.ts +135 -5
  564. package/ui/useLeave.ts +42 -0
  565. package/vendor/@akanjs/native/README.ko.md +1 -1
  566. package/vendor/@akanjs/native/README.md +1 -1
  567. package/vendor/@akanjs/native/THIRD_PARTY_NOTICES.md +78 -56
  568. package/vendor/@akanjs/native/native/android/maven.lock.json +462 -1
  569. package/vendor/@akanjs/native/native/android/src/com/akanjs/runtime/AkanNativeActivity.kt +27 -14
  570. package/vendor/@akanjs/native/native/ios/Sources/AkanNativePlugin.swift +9 -0
  571. package/vendor/@akanjs/native/packages/cli/src/lib/compat.ts +1 -1
  572. package/vendor/@akanjs/native/packages/cli/src/lib/distribution.ts +1 -1
  573. package/vendor/@akanjs/native/packages/cli/src/lib/maven.ts +12 -4
  574. package/vendor/@akanjs/native/packages/cli/src/platforms/android.ts +2 -2
  575. package/vendor/@akanjs/native/packages/core/src/boot.ts +2 -2
  576. package/vendor/@akanjs/native/plugins/browser/ios/BrowserPlugin.swift +4 -3
  577. package/vendor/@akanjs/native/plugins/camera/ios/CameraPlugin.swift +3 -0
  578. package/vendor/@akanjs/native/plugins/keyboard/src/index.ts +3 -2
  579. package/vendor/use-agentic/types.ts +2 -0
  580. package/webkit/CsrMoves.ts +30 -0
  581. package/webkit/CsrRouteTable.ts +2 -1
  582. package/webkit/CsrStack.ts +17 -9
  583. package/webkit/McpAppAgent.ts +1 -1
  584. package/webkit/McpAppFetchBridge.ts +1 -1
  585. package/webkit/McpAppHost.ts +14 -2
  586. package/webkit/RenderLayer.tsx +177 -79
  587. package/webkit/bootCsr.tsx +27 -9
  588. package/webkit/csrPageReadiness.ts +43 -0
  589. package/webkit/csrPendingNavigation.ts +24 -0
  590. package/webkit/csrSlide.ts +190 -0
  591. package/webkit/isDragLift.ts +7 -0
  592. package/webkit/nativeNavigation.ts +42 -4
  593. package/webkit/nativeSplash.ts +30 -0
  594. package/webkit/openSurfaces.ts +54 -0
  595. package/webkit/scrollerTakesDrag.ts +34 -0
  596. package/webkit/useCsrNavigation.ts +109 -36
  597. package/webkit/useCsrStackLifecycle.ts +2 -1
  598. package/webkit/useCsrTransitions.ts +190 -44
  599. package/webkit/useCsrValues.ts +57 -33
  600. package/webkit/useEscapeKey.tsx +10 -23
  601. package/webkit/useFrameRuntime.ts +11 -5
  602. package/webkit/usePageLocation.ts +4 -5
  603. package/ARCHITECTURE.md +0 -199
  604. package/CHANGELOG.md +0 -5264
  605. package/CODE_OF_CONDUCT.md +0 -54
  606. package/CONTRIBUTING.md +0 -109
  607. package/vendor/@akanjs/native/CHANGELOG.md +0 -32
  608. package/vendor/use-agentic/CHANGELOG.md +0 -708
package/README.ko.md CHANGED
@@ -47,10 +47,13 @@ akan start <app-name> --open
47
47
  ### 기존 저장소 안에서 시작하기
48
48
 
49
49
  앱이 놓일 폴더와 실행 방식이 정해진 작업이라면, 예를 들어 다른 저장소의 하위 폴더, Node와 npm만 있는 호스트, 스펙이 정한
50
- URL이라면, 코딩 에이전트는 묻지 않고 아래대로 진행하면 됩니다.
50
+ URL이라면, 코딩 에이전트는 묻지 않고 아래대로 진행하면 됩니다. 스캐폴드에 필요한 것은 아래가 전부라서 다른 패키지의
51
+ README나 코드를 먼저 읽을 필요가 없습니다.
51
52
 
52
53
  - **그 폴더에 바로 만들기:** `bunx create-akan-workspace@latest . --app <app> --dir <folder> --sample false`.
53
- `<folder>` 자체에 쓰고, 이미 있는 파일은 덮어쓰지 않고 멈추며, 샘플 모듈과 페이지는 만들지 않습니다. 함께 생기는
54
+ `<folder>` 자체에 쓰고, 이미 있는 파일은 덮어쓰지 않고 멈추며, 샘플 모듈과 페이지는 만들지 않습니다. `akan` CLI는
55
+ Bun의 전역 폴더(`~/.bun`, `PATH`에는 아무것도 넣지 않음)에 설치하고 `bun install`을 실행할 뿐, 빌드도 서버 실행도
56
+ 하지 않으며, 다른 git 저장소가 추적하는 폴더에서는 `git init`도 커밋도 하지 않습니다. 함께 생기는
54
57
  `AGENTS.md`, `CLAUDE.md`, `.claude/`, `.agents/`, `.cursor/`, `.mcp.json`은 지우지 마세요. 에이전트가 따를 규칙과
55
58
  도구가 들어 있습니다.
56
59
  - **`<folder>`에서 작업하기.** `akan`은 워크스페이스 루트에서만 실행되고, 그곳에서 연 에이전트 세션이 워크스페이스의
@@ -61,9 +64,9 @@ URL이라면, 코딩 에이전트는 묻지 않고 아래대로 진행하면 됩
61
64
  (`/books/OL45804W`)로 내보내려면 `akan.config.ts`에 `i18n: { defaultLocale: "en", locales: ["en"], localePrefix:
62
65
  "as-needed" }`를 두세요. `<Link>`도 따라갑니다.
63
66
  - **Node와 npm만 있는 호스트:** `npx -y bun@1.4.4 x create-akan-workspace@latest . --app <app> --dir <folder> --sample false`를
64
- 실행한 뒤 `npm run build`, `PORT=3000 npm start`로 빌드하고 띄웁니다. 생성기가 쓰는 script와 새로 clone한 사본에
65
- 필요한 것은 [`create-akan-workspace` README](https://github.com/akan-team/akanjs/blob/main/pkgs/create-akan-workspace/README.ko.md#node와-npm만-있을-때)에
66
- 있습니다.
67
+ 실행한 뒤 `npm run build`, `PORT=3000 npm start`로 빌드하고 띄우고, 나머지는 `npx akan <command>`로 실행합니다.
68
+ 워크스페이스가 `bun`을 의존성에 넣어 둡니다. `npm i -g bun`으로 설치한 Bun으로 실행해도 같습니다. 새로 clone한 사본도 그대로 빌드됩니다. 빌드가 git이 무시하는 파일 중 없는
69
+ 것을 먼저 씁니다.
67
70
  - **실행할 곳에 맞게 빌드하기.** 셸이나 Bun이 읽는 `.env.local`에서 지정한 변수가 워크스페이스 `.env`보다 우선하고(빈
68
71
  값은 지정하지 않은 것으로 보며, 빌드는 그렇게 가져간 값을 하나씩 알려 줍니다), `AKAN_PUBLIC_ENV`는 `--env`가 둘보다
69
72
  우선합니다. 새 워크스페이스의 `.env`는 `local`이라 내 컴퓨터나 테스트 러너에서는 이대로 맞지만, 서버가
@@ -107,6 +110,7 @@ cd dist/apps/<app> && PORT=3000 bun main.js
107
110
  - `akanjs`는 npm 패키지 하나입니다. subpath(`akanjs/base`, `akanjs/client`, `akanjs/signal`, `akanjs/ui`, …)가 서버
108
111
  전용, 클라이언트 전용, UI, 툴링 코드를 나누고([패키지 레퍼런스](https://akanjs.com/references/akanjs/base)), 툴링은
109
112
  `@akanjs/cli`와 `@akanjs/devkit`으로 나옵니다.
113
+ - 버전별 변경: [`CHANGELOG.md`](https://github.com/akan-team/akanjs/blob/main/pkgs/akanjs/CHANGELOG.md).
110
114
  - 기여: [`CONTRIBUTING.md`](https://github.com/akan-team/akanjs/blob/main/pkgs/akanjs/CONTRIBUTING.md)와
111
115
  [행동 강령](https://github.com/akan-team/akanjs/blob/main/pkgs/akanjs/CODE_OF_CONDUCT.md). 라이선스: MIT
112
116
  ([`LICENSE`](https://github.com/akan-team/akanjs/blob/main/pkgs/akanjs/LICENSE)).
package/README.md CHANGED
@@ -46,11 +46,13 @@ generates a sample app. The app opens on `http://localhost:8282`.
46
46
  ### Inside an existing repository
47
47
 
48
48
  When a task fixes where the app lives and how it runs, for example a folder in another repository, a host with only
49
- Node and npm, or URLs given by a spec, a coding agent needs these, and nothing has to ask:
49
+ Node and npm, or URLs given by a spec, a coding agent needs these, and nothing has to ask. They are the whole
50
+ scaffold: no other package's README or code has to be read first.
50
51
 
51
52
  - **Create the workspace in that folder:** `bunx create-akan-workspace@latest . --app <app> --dir <folder> --sample false`.
52
53
  It writes into `<folder>` itself, refuses to overwrite a file already there, and leaves out the sample module and
53
- pages. Keep the `AGENTS.md`, `CLAUDE.md`, `.claude/`, `.agents/`, `.cursor/` and `.mcp.json` it writes: they carry
54
+ pages. It also puts the `akan` CLI in Bun's global folder (`~/.bun`, nothing on `PATH`) and runs `bun install`; it
55
+ builds and starts nothing, and in a folder another git repository tracks it neither runs `git init` nor commits. Keep the `AGENTS.md`, `CLAUDE.md`, `.claude/`, `.agents/`, `.cursor/` and `.mcp.json` it writes: they carry
54
56
  the rules and tools an agent works through.
55
57
  - **Work from `<folder>`.** `akan` runs only from the workspace root, and an agent session opened there loads the
56
58
  workspace's rules and MCP server.
@@ -60,9 +62,8 @@ Node and npm, or URLs given by a spec, a coding agent needs these, and nothing h
60
62
  set `i18n: { defaultLocale: "en", locales: ["en"], localePrefix: "as-needed" }` in `akan.config.ts`; `<Link>`
61
63
  follows.
62
64
  - **A host with only Node and npm:** `npx -y bun@1.4.4 x create-akan-workspace@latest . --app <app> --dir <folder> --sample false`,
63
- then `npm run build` and `PORT=3000 npm start`. The
64
- [`create-akan-workspace` README](https://www.npmjs.com/package/create-akan-workspace#with-only-node-and-npm) has the
65
- scripts it writes and what a fresh clone needs.
65
+ then `npm run build` and `PORT=3000 npm start`, and `npx akan <command>` for the rest: the workspace lists `bun` in
66
+ its dependencies, as it does under a Bun from `npm i -g bun`. A fresh clone builds as is, since the build writes the git-ignored files it lacks.
66
67
  - **Build for where it runs.** A variable set in the shell, or in a `.env.local` Bun loads, outranks the workspace `.env`
67
68
  (an empty one counts as unset, and the build names each one it took), and `--env` outranks both for `AKAN_PUBLIC_ENV`. A new workspace's `.env` says `local`, which suits your own machine or a test runner, but the
68
69
  server runs without endpoint rate limits and on local defaults. For a host others can reach, run
@@ -106,6 +107,7 @@ you are running on a public URL.
106
107
  - `akanjs` is one npm package. Its subpaths (`akanjs/base`, `akanjs/client`, `akanjs/signal`, `akanjs/ui`, …) keep
107
108
  server-only, client-only, UI and tooling code apart, and the [package reference](https://akanjs.com/references/akanjs/base)
108
109
  covers them; the tooling ships as `@akanjs/cli` and `@akanjs/devkit`.
110
+ - Changes by version: [`CHANGELOG.md`](https://github.com/akan-team/akanjs/blob/main/pkgs/akanjs/CHANGELOG.md).
109
111
  - Contributing: [`CONTRIBUTING.md`](https://github.com/akan-team/akanjs/blob/main/pkgs/akanjs/CONTRIBUTING.md) and
110
112
  the [code of conduct](https://github.com/akan-team/akanjs/blob/main/pkgs/akanjs/CODE_OF_CONDUCT.md). License: MIT
111
113
  ([`LICENSE`](https://github.com/akan-team/akanjs/blob/main/pkgs/akanjs/LICENSE)).
package/base/utils.ts CHANGED
@@ -25,3 +25,5 @@ export const applyFnToArrayObjects = <Input, Fn extends (arg: never) => unknown>
25
25
  if (Array.isArray(arraiedData)) return arraiedData.map((data) => applyFnToArrayObjects(data, fn)) as Result;
26
26
  return fn(arraiedData as never) as Result;
27
27
  };
28
+
29
+ export const loadedAfter = (..._modules: unknown[]): void => {};
@@ -1,5 +1,6 @@
1
1
  import { Href } from "./href";
2
- import { isNativeShell } from "./nativeHost";
2
+
3
+ import { isNativeShell } from "./nativeShell";
3
4
 
4
5
  export const closeAppOpenedTab = (): boolean => {
5
6
  const win = globalThis.window;
@@ -38,6 +38,8 @@ type RuntimeErr = {
38
38
 
39
39
  type RuntimeWs = {
40
40
  connected: boolean;
41
+ state?: "connecting" | "open" | "closed" | "gaveUp";
42
+ connect?: (option?: { fresh?: boolean }) => void;
41
43
  on: (event: string, handler: (...args: unknown[]) => void) => void;
42
44
  off: (event: string, handler: (...args: unknown[]) => void) => void;
43
45
  };
package/client/cookie.ts CHANGED
@@ -153,25 +153,34 @@ export interface GetOption {
153
153
  unauthorize: string;
154
154
  }
155
155
  interface SetAuthOption {
156
- jwt: string;
156
+ jwt?: string | null;
157
157
  }
158
158
  const announceAuth = () => {
159
159
  if (typeof window !== "undefined") window.dispatchEvent(new Event("akan:auth"));
160
160
  };
161
+
162
+ const reopenSocket = () => {
163
+ const { ws } = fetch;
164
+ if (ws?.state === "open" || ws?.state === "connecting") ws.connect?.({ fresh: true });
165
+ };
161
166
  /** Sets the active auth token on fetch, then keeps it where the next launch finds it: client storage on a CSR client,
162
- * the session cookie elsewhere unless the server already holds it there (`SessionCookie.issue`). */
163
- export const setAuth = ({ jwt }: SetAuthOption) => {
164
- fetch.setJwt(jwt);
167
+ * the session cookie elsewhere unless the server already holds it there (`SessionCookie.issue`). An answer with no
168
+ * token beside a session the server holds is a cookie-only session: fetch sends no token and the socket reconnects. */
169
+ export const setAuth = ({ jwt }: SetAuthOption = {}) => {
170
+ const token = jwt ?? "";
171
+ const cookieOnly = !token && serverHoldsSession();
172
+ fetch.setJwt(cookieOnly ? null : token);
165
173
 
166
- if (isCsrClient()) void secretStorage.setItem(storedAuthTokenKey(), jwt);
174
+ if (isCsrClient()) void secretStorage.setItem(storedAuthTokenKey(), token);
167
175
  else {
168
176
 
169
177
  void secretStorage.removeItem(storedAuthTokenKey());
170
- if (!serverHoldsSession()) setCookie(authTokenKey(), jwt);
178
+ if (!serverHoldsSession()) setCookie(authTokenKey(), token);
171
179
  }
172
180
 
173
181
  for (const key of retiredAuthTokenKeys()) removeCookie(key);
174
182
  void secretStorage.removeItem(legacyAuthTokenKey);
183
+ if (cookieOnly) reopenSocket();
175
184
  announceAuth();
176
185
  };
177
186
 
@@ -4,12 +4,16 @@ declare global {
4
4
  var __AKAN_EMBED__: { kind: "mcp-app"; origin?: string; account?: Record<string, unknown> | null } | undefined;
5
5
  }
6
6
 
7
+ const popWaitMs = 1000;
8
+
7
9
  /** The document's location and history, as the routers read and move them. */
8
10
  export class CsrLocation {
9
11
 
10
12
  #view: URL | null = null;
11
- #entry: { idx: number | undefined; href: string } | null = null;
13
+ #entry: { idx: number | undefined; href: string; from: string | undefined } | null = null;
12
14
  #onBack: ((idx: number) => void) | null = null;
15
+ #backAsked: object | null = null;
16
+ #backSent: object | null = null;
13
17
 
14
18
  /** Reads `href`, a path on the app's origin, as this document's location from now on; a view never moves. */
15
19
  view(href: string) {
@@ -44,25 +48,28 @@ export class CsrLocation {
44
48
  }
45
49
 
46
50
  /**
47
- * The entry on screen as of the last write or traversal, and its index; during a `popstate` it is still the entry
48
- * left, which `state` no longer reads.
51
+ * The entry on screen as of the last write or traversal, its index, and `from`, the address a push stacked it on
52
+ * (none for an entry a document load or a fragment link made); during a `popstate` it is still the entry left,
53
+ * which `state` no longer reads.
49
54
  */
50
55
  entry() {
51
56
  return this.#entry ?? this.observe();
52
57
  }
53
58
 
54
59
  observe() {
55
- this.#entry = { idx: CsrLocation.idxOf(window.history?.state), href: this.href };
60
+ const state = window.history?.state;
61
+ this.#entry = { idx: CsrLocation.idxOf(state), href: this.href, from: CsrLocation.#fromOf(state) };
56
62
  return this.#entry;
57
63
  }
58
64
 
59
65
  push(state: unknown, href: string) {
60
- window.history.pushState(CsrLocation.#indexed(state, (this.entry().idx ?? 0) + 1), "", href);
66
+ const stacked = CsrLocation.#indexed(state, (this.entry().idx ?? 0) + 1) as { __akanRouter?: object };
67
+ window.history.pushState({ ...stacked, __akanRouter: { ...stacked.__akanRouter, from: this.href } }, "", href);
61
68
  this.observe();
62
69
  }
63
70
 
64
71
  replace(state: unknown, href?: string) {
65
- const indexed = CsrLocation.#indexed(state, this.entry().idx ?? 0);
72
+ const indexed = CsrLocation.#rewritten(CsrLocation.#indexed(state, this.entry().idx ?? 0), window.history.state);
66
73
  if (href === undefined) window.history.replaceState(indexed, "");
67
74
  else window.history.replaceState(indexed, "", href);
68
75
  this.observe();
@@ -73,6 +80,18 @@ export class CsrLocation {
73
80
  return Number.isInteger(idx) ? (idx as number) : undefined;
74
81
  }
75
82
 
83
+ static #fromOf(state: unknown) {
84
+ const from = (state as { __akanRouter?: { from?: unknown } } | null)?.__akanRouter?.from;
85
+ return typeof from === "string" ? from : undefined;
86
+ }
87
+
88
+ static #rewritten(state: unknown, live: unknown) {
89
+ const from = CsrLocation.#fromOf(live);
90
+ if (from === undefined || CsrLocation.#fromOf(state) !== undefined) return state;
91
+ const record = (state ?? {}) as { __akanRouter?: object };
92
+ return { ...record, __akanRouter: { ...record.__akanRouter, from } };
93
+ }
94
+
76
95
  static #indexed(state: unknown, idx: number) {
77
96
  if (CsrLocation.idxOf(state) !== undefined) return state;
78
97
  const record = (state ?? {}) as { __akanRouter?: object };
@@ -84,10 +103,43 @@ export class CsrLocation {
84
103
  this.#onBack = listener;
85
104
  }
86
105
 
87
- back() {
88
- const idx = this.entry().idx;
89
- if (idx !== undefined) this.#onBack?.(idx - 1);
106
+ /** Holds the entry on screen as left until `moving`, a shell's back, settles; `back()` holds it until the pop lands. */
107
+ leaving(moving: unknown) {
108
+ const entry = this.entry();
109
+ this.#backAsked = entry;
110
+ const release = () => {
111
+ if (this.#backAsked === entry) this.#backAsked = null;
112
+ };
113
+ void Promise.resolve(moving).then(release, release);
114
+ }
115
+
116
+ /** Whether a back has left the entry on screen and not landed yet. */
117
+ isLeaving() {
118
+ const entry = this.entry();
119
+ return entry === this.#backAsked || entry === this.#backSent;
120
+ }
121
+
122
+ /** Settles once the back's pop has moved the address, or at once when no entry of this document is under it. */
123
+ back(): Promise<void> {
124
+ const entry = this.entry();
125
+ if (entry.idx !== undefined) this.#onBack?.(entry.idx - 1);
126
+
127
+ const pops = entry.idx !== undefined && entry.idx > 0;
128
+ if (pops) this.#backSent = entry;
129
+ const landed = pops ? CsrLocation.#nextPop() : Promise.resolve();
90
130
  window.history.back();
131
+ return landed;
132
+ }
133
+
134
+ static #nextPop() {
135
+ return new Promise<void>((resolve) => {
136
+ const land = () => {
137
+ clearTimeout(cap);
138
+ resolve();
139
+ };
140
+ const cap = setTimeout(land, popWaitMs);
141
+ window.addEventListener("popstate", land, { once: true });
142
+ });
91
143
  }
92
144
 
93
145
  assign(href: string) {
@@ -0,0 +1,33 @@
1
+ import { csrLocation } from "./csrLocation";
2
+ import { Href } from "./href";
3
+
4
+ /** The params a CSR boot reads off its address (`?csr=true`), which every address it moves to carries along. */
5
+ export class CsrRuntimeParams {
6
+ static readonly #names = ["csr", "akanMobileTarget", "akanMobileBasePath", "akanMobileIndexPath"] as const;
7
+
8
+ static carry(href: string) {
9
+ const currentSearch = new URLSearchParams(csrLocation.search);
10
+ if (currentSearch.get("csr") !== "true" || Href.hasWebScheme(href)) return href;
11
+
12
+ const [hrefWithoutHash, hash = ""] = href.split("#");
13
+ const [pathname, search = ""] = hrefWithoutHash.split("?");
14
+ const nextSearch = new URLSearchParams(search);
15
+ for (const param of CsrRuntimeParams.#names) {
16
+ if (nextSearch.has(param)) continue;
17
+ const value = currentSearch.get(param);
18
+ if (value !== null) nextSearch.set(param, value);
19
+ }
20
+ const query = nextSearch.toString();
21
+ return `${pathname}${query ? `?${query}` : ""}${hash ? `#${hash}` : ""}`;
22
+ }
23
+
24
+ static sameRoute(a: string, b: string) {
25
+ const [left, right] = [a, b].map((href) => {
26
+ const url = new URL(href, "http://route.invalid");
27
+ for (const param of CsrRuntimeParams.#names) url.searchParams.delete(param);
28
+ url.searchParams.sort();
29
+ return `${url.pathname}?${url.searchParams.toString()}${url.hash}`;
30
+ });
31
+ return left === right;
32
+ }
33
+ }
@@ -21,6 +21,9 @@ export type PageSafeAreaConfig =
21
21
  };
22
22
  /** The sides whose chrome the page runs under instead of below. */
23
23
  export type PageOverlayConfig = boolean | "top" | "bottom";
24
+
25
+ /** How a page's navbar moves when it transitions; see `PageConfig.navbarMotion`. */
26
+ export type NavbarMotion = "crossfade" | "page";
24
27
  /** `"stream"` flushes the shell (`Loading` included) then streams; a redirect in suspended content becomes a client one.
25
28
  * `"block"` buffers the whole document, so an error in slow content can still render a clean error page. */
26
29
  export type SsrRenderMode = "stream" | "block";
@@ -42,14 +45,23 @@ export interface PageConfig {
42
45
  * and an overlaid side's safe area defaults to transparent.
43
46
  */
44
47
  overlay?: PageOverlayConfig;
48
+ /**
49
+ * How the navbar (`Layout.Navbar`'s top inset and its back button) moves when this page transitions.
50
+ * `"crossfade"`, the default, keeps one bar in place and crossfades the two pages' bars, as UIKit's does; between a
51
+ * page with a bar and one without, the bar's height folds away. `"page"` moves each bar with its page, as a part of
52
+ * the page, for a bar that is the page's own surface (translucent, or with no fill of its own).
53
+ */
54
+ navbarMotion?: NavbarMotion;
45
55
  gesture?: boolean;
46
56
  cache?: boolean;
47
57
  /** Initial full-document SSR strategy. Defaults to `"stream"`. */
48
58
  ssr?: SsrRenderMode;
49
59
  /**
50
60
  * Opt-in suffix-only RSC commits under `AKAN_PUBLIC_RSC_PARTIAL_COMMIT=1`: the page's `.head()` is plain `title`,
51
- * `meta` and `link` tags, and the layouts above it render the same for each sibling page, apart from what they
52
- * read through `usePathCtx()`.
61
+ * `meta` and `link` tags, and the layouts above it draw on the server only from the args they declare. A move to a
62
+ * sibling page, or to another param or query of this page that no layout above declares with `.param()` or
63
+ * `.search()`, then renders the page alone and keeps those layouts as drawn; what follows the path in them is read
64
+ * on the client (`usePathCtx()`, `Link`'s `activeClassName`).
53
65
  */
54
66
  rscPatchHeadSafe?: boolean;
55
67
  /** `false` answers a `Link` prefetch of the page (on a layout, of every page under it) without rendering it, for a
@@ -77,6 +89,8 @@ export interface CsrState {
77
89
  /** Web only: the sides whose safe area `env(safe-area-inset-*)` measures, since a browser tells script nothing. */
78
90
  safeAreaEnv?: { top: boolean; bottom: boolean };
79
91
  overlay?: { top: boolean; bottom: boolean };
92
+ /** Set when the page declares one; left out, the navbar crossfades. */
93
+ navbarMotion?: NavbarMotion;
80
94
  gesture: boolean;
81
95
  cache: boolean;
82
96
  ssr: SsrRenderMode;
@@ -168,6 +182,8 @@ export interface RouteRender {
168
182
  getRouteDefinition?: () => PromiseOrObject<RouteDefinition | undefined>;
169
183
  /** The query names the level reads; `undefined` for a legacy module, which receives every one. */
170
184
  getSearchNames?: () => PromiseOrObject<string[] | undefined>;
185
+ /** The params the level reads beyond `lang`; `undefined` for a legacy module, which receives every one. */
186
+ getParamNames?: () => PromiseOrObject<string[] | undefined>;
171
187
  }
172
188
  export interface RouteViewport {
173
189
  /** `viewport-fit=cover`: the page runs under the notch and home indicator, and `env(safe-area-inset-*)` measures them. */
@@ -416,6 +432,10 @@ export const pageActivityContext = sharedContext<PageActivityState>("pageActivit
416
432
  export interface PathRoute {
417
433
  path: string;
418
434
  pathSegments: string[];
435
+ /** The not-found view a path no page matches draws, under the layouts it reached. */
436
+ notFound?: true;
437
+ /** The pages matched ahead of this one that take some of its paths, as `/:lang/chat/new` does of `/:lang/chat/:id`. */
438
+ shadowedBy?: string[];
419
439
  renderPage: RouteRender;
420
440
  pageState: PageState;
421
441
  pageConfigChain?: PageConfig[];
package/client/device.ts CHANGED
@@ -1,22 +1,30 @@
1
1
  "use client";
2
+ import { parseAkanI18nEnv } from "akanjs/common";
2
3
  import type { RefObject } from "react";
3
4
  import { csrLocation } from "./csrLocation";
4
5
  import { readCssSafeAreaInsets } from "./frameConfig";
5
6
  import type { DeviceInfo } from "./native";
6
7
 
7
8
  type NativeModule = typeof import("./native");
9
+ type KeyboardRideClass = typeof import("./keyboardRide").KeyboardRide;
8
10
  type NativeControls = Pick<NativeModule, "haptics" | "keyboard">;
9
11
  type ProcessEnvLike = { env?: Record<string, string | undefined> };
10
12
  type DebugPayload = Record<string, unknown>;
11
13
 
12
14
  const globalWithProcess = globalThis as typeof globalThis & { process?: ProcessEnvLike };
13
15
 
14
- /** Whether the iOS shell left the keyboard to the page; an older shell still pans to the field, so the page must not. */
16
+ /** Whether the shell left the keyboard to the page; an older shell still pans to the field, so the page must not. */
15
17
  export const isPageKeyboardAvoidance = () =>
16
18
  (globalThis as { __AKAN_NATIVE__?: { keyboardAvoidance?: string } }).__AKAN_NATIVE__?.keyboardAvoidance === "page";
17
19
 
18
20
  export const IOS_KEYBOARD_ANIMATION_EASING = "cubic-bezier(0.38, 0.7, 0.125, 1)";
19
21
 
22
+ export const ANDROID_KEYBOARD_ANIMATION_EASING = "cubic-bezier(0.2, 0, 0, 1)";
23
+ export const nativeKeyboardEasing = () =>
24
+ (globalThis as { __AKAN_NATIVE__?: { platform?: string } }).__AKAN_NATIVE__?.platform === "android"
25
+ ? ANDROID_KEYBOARD_ANIMATION_EASING
26
+ : IOS_KEYBOARD_ANIMATION_EASING;
27
+
20
28
  const debugSessionId = crypto.getRandomValues(new Uint32Array(1))[0].toString(36);
21
29
  let debugSeq = 0;
22
30
 
@@ -98,6 +106,12 @@ const langInPath = (pathname: string, supportLanguages: string[] | readonly stri
98
106
  return supportLanguages.find((language) => language === predefinedLangPath);
99
107
  };
100
108
 
109
+ const supportedLang = (code: string, supportLanguages: string[] | readonly string[]) => {
110
+ if (supportLanguages.length === 0 || supportLanguages.includes(code)) return code;
111
+ const { defaultLocale } = parseAkanI18nEnv();
112
+ return supportLanguages.includes(defaultLocale) ? defaultLocale : (supportLanguages[0] ?? code);
113
+ };
114
+
101
115
  const createWebDevice = ({
102
116
  lang,
103
117
  supportLanguages,
@@ -107,7 +121,7 @@ const createWebDevice = ({
107
121
  }) => {
108
122
  const pathname = typeof window === "undefined" ? "" : csrLocation.pathname;
109
123
  return new Device({
110
- lang: lang ?? langInPath(pathname, supportLanguages) ?? getBrowserLanguage(),
124
+ lang: lang ?? langInPath(pathname, supportLanguages) ?? supportedLang(getBrowserLanguage(), supportLanguages),
111
125
  info: webDeviceInfo,
112
126
  topSafeArea: 0,
113
127
  bottomSafeArea: 0,
@@ -139,7 +153,8 @@ export class Device {
139
153
 
140
154
  const { top: topSafeArea, bottom: bottomSafeArea } = readCssSafeAreaInsets();
141
155
  Device.instance = new Device({
142
- lang: lang ?? langInPath(window.location.pathname, supportLanguages) ?? languageCode,
156
+ lang:
157
+ lang ?? langInPath(window.location.pathname, supportLanguages) ?? supportedLang(languageCode, supportLanguages),
143
158
  info,
144
159
  topSafeArea,
145
160
  bottomSafeArea,
@@ -177,9 +192,16 @@ export class Device {
177
192
  async hideKeyboard() {
178
193
  await this.#native?.keyboard.hide();
179
194
  }
195
+
196
+ static #keyboardRide: KeyboardRideClass | null = null;
180
197
  listenKeyboardChanged(onKeyboardChanged: (height: number) => void) {
181
198
  const keyboard = this.#native?.keyboard;
182
199
  if (!keyboard) return;
200
+ if (isPageKeyboardAvoidance())
201
+ void import("./keyboardRide").then(({ KeyboardRide }) => {
202
+ Device.#keyboardRide = KeyboardRide;
203
+ KeyboardRide.watchFocus();
204
+ });
183
205
  let currentHeight = 0;
184
206
  const emitKeyboardHeight = (event: string, height: number) => {
185
207
  debugFrame("keyboard.event", { event, height, previousHeight: currentHeight });
@@ -193,22 +215,12 @@ export class Device {
193
215
  ...(["willShow", "didShow", "willHide", "didHide"] as const).map((event) =>
194
216
  keyboard.listen(event, ({ height, duration }) => {
195
217
  if (duration > 0) this.keyboardAnimationMs = duration;
196
- if (isPageKeyboardAvoidance()) this.#moveRootWithKeyboard(height);
218
+ Device.#keyboardRide?.move(height, this.keyboardAnimationMs);
197
219
  emitKeyboardHeight(event, height);
198
220
  }),
199
221
  ),
200
222
  );
201
223
  }
202
-
203
- #moveRootWithKeyboard(height: number) {
204
- const root = document.documentElement;
205
- if (this.keyboardAnimationMs > 0) {
206
- root.style.setProperty("--akan-keyboard-duration", `${this.keyboardAnimationMs}ms`);
207
- root.style.setProperty("--akan-keyboard-easing", IOS_KEYBOARD_ANIMATION_EASING);
208
- }
209
- root.style.setProperty("--akan-keyboard-cover", `${height}px`);
210
- root.toggleAttribute("data-akan-keyboard", height > 0);
211
- }
212
224
  subscribeKeyboard(onKeyboardChanged: (height: number) => void) {
213
225
  this.#keyboardSubscribers.add(onKeyboardChanged);
214
226
  return () => {
@@ -1,32 +1,110 @@
1
- import { type Dictionary, TranslatorState } from "./translatorState";
1
+ import { type DictionaryModule, importDictionaryModule } from "./dictionaryModule";
2
+ import { DictionaryPart } from "./dictionaryPart";
3
+ import { TranslatorState } from "./translatorState";
2
4
 
3
- interface DictionaryModule {
4
- lang: string;
5
- default: Dictionary;
5
+ interface DictionaryAssetState {
6
+ loads: Map<string, Promise<DictionaryModule>>;
7
+ appliedSeqByLang: Map<string, number>;
8
+ seq: number;
9
+
10
+ wholes: WeakSet<object>;
11
+
12
+ groupsBySnapshot: WeakMap<object, Set<string>>;
6
13
  }
7
14
 
15
+ const dictionaryAssetStateKey = "__AKAN_DICTIONARY_ASSET__";
16
+
8
17
  export class DictionaryAsset {
9
- static readonly #loads = new Map<string, Promise<DictionaryModule>>();
10
- static #retrySeq = 0;
11
-
12
- static async load(url: string | null | undefined): Promise<void> {
13
- if (!url) return;
14
- const loading = DictionaryAsset.#loads.get(url) ?? DictionaryAsset.#import(url);
15
- DictionaryAsset.#loads.set(url, loading);
16
- const { lang, default: dictionary } = await loading;
17
- TranslatorState.replace(lang, dictionary);
18
- }
19
-
20
- static async #import(url: string): Promise<DictionaryModule> {
21
- try {
22
- return (await import(url)) as DictionaryModule;
23
- } catch {
24
- try {
25
- return (await import(`${url}?retry=${++DictionaryAsset.#retrySeq}`)) as DictionaryModule;
26
- } catch (error) {
27
- DictionaryAsset.#loads.delete(url);
28
- throw error;
29
- }
18
+ static #state(): DictionaryAssetState {
19
+ const globalScope = globalThis as typeof globalThis & { [dictionaryAssetStateKey]?: DictionaryAssetState };
20
+ globalScope[dictionaryAssetStateKey] ??= {
21
+ loads: new Map(),
22
+ appliedSeqByLang: new Map(),
23
+ seq: 0,
24
+ wholes: new WeakSet(),
25
+ groupsBySnapshot: new WeakMap(),
26
+ };
27
+ return globalScope[dictionaryAssetStateKey];
28
+ }
29
+
30
+ static async load(urls: string | readonly string[] | null | undefined): Promise<void> {
31
+ const list = (typeof urls === "string" ? urls.split(",") : (urls ?? [])).filter(Boolean);
32
+ if (!list.length) return;
33
+ const state = DictionaryAsset.#state();
34
+ const seq = ++state.seq;
35
+ TranslatorState.get().loadSeq = seq;
36
+ const loaded = await Promise.allSettled(list.map((url) => DictionaryAsset.#loading(url)));
37
+ loaded.forEach((result, idx) => {
38
+ const url = list[idx];
39
+ if (result.status === "fulfilled" && url) DictionaryAsset.#apply(url, result.value, seq);
40
+ });
41
+ const failed = loaded.find((result) => result.status === "rejected");
42
+ if (failed) throw failed.reason;
43
+ }
44
+
45
+ static async add(url: string): Promise<boolean> {
46
+ const dictionaryModule = await DictionaryAsset.#loading(url);
47
+ return DictionaryAsset.#apply(url, dictionaryModule, null);
48
+ }
49
+
50
+ static holdsEveryGroup(lang: string): boolean {
51
+ const replaced = TranslatorState.get().replacedByLang.get(lang);
52
+ return !!replaced && DictionaryAsset.#state().wholes.has(replaced);
53
+ }
54
+
55
+ static holdsGroup(lang: string, group: string): boolean {
56
+ const replaced = TranslatorState.get().replacedByLang.get(lang);
57
+ return !!replaced && !!DictionaryAsset.#state().groupsBySnapshot.get(replaced)?.has(group);
58
+ }
59
+
60
+ static #markGroups(snapshot: object, groups: readonly string[]) {
61
+ const { groupsBySnapshot } = DictionaryAsset.#state();
62
+ const marked = groupsBySnapshot.get(snapshot) ?? new Set<string>();
63
+ for (const group of groups) marked.add(group);
64
+ groupsBySnapshot.set(snapshot, marked);
65
+ }
66
+
67
+ static #apply(
68
+ url: string,
69
+ { lang, default: dictionary, parts, table, groups, part }: DictionaryModule,
70
+ seq: number | null,
71
+ ) {
72
+ const state = DictionaryAsset.#state();
73
+ const translator = TranslatorState.get();
74
+ const replaced = translator.replacedByLang.get(lang);
75
+ if (part)
76
+ return (
77
+ !!replaced && DictionaryPart.urlOf(lang, part) === url && DictionaryPart.merge(lang, url, dictionary, replaced)
78
+ );
79
+ const sameBuild = !!table && !!replaced && translator.tableByLang.get(lang) === table;
80
+ if (groups && sameBuild) {
81
+ if (!state.wholes.has(replaced) && DictionaryPart.merge(lang, url, dictionary, replaced))
82
+ DictionaryAsset.#markGroups(replaced, groups);
83
+ return true;
84
+ }
85
+ if (seq === null || (state.appliedSeqByLang.get(lang) ?? 0) > seq) return false;
86
+ state.appliedSeqByLang.set(lang, seq);
87
+ if (!groups) {
88
+ state.wholes.add(dictionary);
89
+ TranslatorState.replace(lang, dictionary, parts, table);
90
+ return true;
30
91
  }
92
+ const base = {};
93
+ TranslatorState.replace(lang, base, parts, table);
94
+ const merged = DictionaryPart.merge(lang, url, dictionary, base);
95
+ if (merged) DictionaryAsset.#markGroups(base, groups);
96
+ return merged;
97
+ }
98
+
99
+ static #loading(url: string): Promise<DictionaryModule> {
100
+ const { loads } = DictionaryAsset.#state();
101
+ const known = loads.get(url);
102
+ if (known) return known;
103
+ const loading = importDictionaryModule(url).catch((error: unknown) => {
104
+ loads.delete(url);
105
+ throw error;
106
+ });
107
+ loads.set(url, loading);
108
+ return loading;
31
109
  }
32
110
  }