akanjs 3.3.0-rc.2 → 3.3.0-rc.21

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 (433) hide show
  1. package/ARCHITECTURE.md +3 -2
  2. package/CHANGELOG.md +391 -23
  3. package/CONTRIBUTING.md +2 -2
  4. package/README.ko.md +40 -296
  5. package/README.md +41 -297
  6. package/client/appOpenedTab.ts +12 -0
  7. package/client/clientRuntime.ts +3 -10
  8. package/client/cn.ts +4 -4
  9. package/client/cookie.ts +15 -6
  10. package/client/csrTypes.ts +17 -0
  11. package/client/device.ts +43 -3
  12. package/client/frameConfig.ts +27 -6
  13. package/client/index.ts +12 -6
  14. package/client/keyboardRide.ts +124 -0
  15. package/client/router.ts +6 -3
  16. package/client/rscNavigation.ts +0 -7
  17. package/client/scriptPolicy.ts +14 -0
  18. package/common/CodeTranscript.ts +4 -2
  19. package/common/Logger.ts +4 -1
  20. package/common/TraceContext.ts +97 -0
  21. package/common/TrustedProxy.ts +10 -0
  22. package/common/codeAgentProfile.ts +1 -1
  23. package/common/codeAgentWire.ts +7 -2
  24. package/common/index.ts +1 -0
  25. package/common/inlineToken.ts +26 -0
  26. package/common/logContext.ts +1 -0
  27. package/common/sessionTokenContract.ts +7 -0
  28. package/constant/index.ts +0 -1
  29. package/constant/types.ts +0 -2
  30. package/document/documentSchema.ts +0 -3
  31. package/document/filterMeta.ts +3 -16
  32. package/fetch/client/fetchClient.ts +8 -17
  33. package/fetch/client/httpClient.ts +22 -12
  34. package/fetch/client/wsClient.ts +10 -6
  35. package/fetch/requestStorage.ts +30 -0
  36. package/index.ts +8 -0
  37. package/package.json +263 -57
  38. package/server/SSR_MEMORY_DIAGNOSIS.md +88 -1
  39. package/server/admissionQueue.ts +107 -0
  40. package/server/akanApp.ts +39 -14
  41. package/server/akanAppHeaders.ts +20 -6
  42. package/server/akanOption.ts +28 -0
  43. package/server/akanServer.ts +13 -1
  44. package/server/assetHeaders.ts +8 -3
  45. package/server/cachePolicy.ts +2 -1
  46. package/server/clientErrorReport.ts +191 -0
  47. package/server/clientReportId.ts +54 -0
  48. package/server/console.ts +5 -12
  49. package/server/devtools/README.md +15 -3
  50. package/server/devtools/devtoolsAccess.ts +119 -0
  51. package/server/devtools/devtoolsRouter.ts +30 -26
  52. package/server/devtools/devtoolsUnlockPage.ts +38 -0
  53. package/server/devtools/signalSerializer.ts +18 -1
  54. package/server/devtools/studio/studioDocument.tsx +3 -1
  55. package/server/devtools/studio/studioRoute.ts +4 -1
  56. package/server/devtools/types.ts +6 -0
  57. package/server/flightSanitizeRecorded.fixture.json +36 -34
  58. package/server/forwardedError.ts +43 -0
  59. package/server/gateway/gatewayChildren.ts +3 -0
  60. package/server/gateway/gatewayConfig.ts +5 -0
  61. package/server/gateway/gatewayHttpProxy.ts +10 -2
  62. package/server/gateway/gatewayStatus.ts +21 -1
  63. package/server/gateway/gatewayStatusPage.ts +18 -11
  64. package/server/headSplice.ts +73 -0
  65. package/server/hmr/clientReport.ts +9 -9
  66. package/server/hmr/csrDevShell.ts +7 -4
  67. package/server/htmlResultCache.ts +81 -14
  68. package/server/imageOptimizer.ts +44 -12
  69. package/server/index.ts +2 -4
  70. package/server/lifecycle/secretEnv.ts +98 -0
  71. package/server/lifecycle/shutdownManager.ts +6 -0
  72. package/server/logging/logForwarder.ts +2 -2
  73. package/server/logging/logQuery.ts +9 -1
  74. package/server/mcp/McpDispatcher.ts +13 -10
  75. package/server/metrics/metricAggregate.ts +27 -0
  76. package/server/metrics/metricExposition.ts +92 -0
  77. package/server/metrics/metricMerge.ts +81 -0
  78. package/server/metrics/metricRegistry.ts +271 -0
  79. package/server/metrics/pubsubGauges.ts +20 -0
  80. package/server/metrics/requestMetrics.ts +110 -0
  81. package/server/metrics/runtimeFamilies.ts +61 -0
  82. package/server/metrics/slowStatementLog.ts +63 -0
  83. package/server/metrics/statementMetrics.ts +259 -0
  84. package/server/metrics/statementPlanCheck.ts +141 -0
  85. package/server/metrics/statementReport.ts +105 -0
  86. package/server/migration/migrationRunner.ts +13 -10
  87. package/server/oauth/OAuthErrors.ts +5 -1
  88. package/server/ops/statusAccess.ts +23 -3
  89. package/server/otlp/otlpBatcher.ts +221 -0
  90. package/server/otlp/otlpConfig.ts +185 -0
  91. package/server/otlp/otlpEncode.ts +114 -0
  92. package/server/otlp/otlpExporter.ts +98 -0
  93. package/server/otlp/otlpSampler.ts +50 -0
  94. package/server/pageFailure.ts +33 -0
  95. package/server/processMetricsCollector.ts +1 -0
  96. package/server/renderBusyResponse.ts +97 -0
  97. package/server/reportText.ts +27 -0
  98. package/server/resolver/databaseModelInstance.ts +21 -19
  99. package/server/resolver/httpEndpointHandler.ts +43 -0
  100. package/server/resolver/jobTrace.ts +18 -0
  101. package/server/resolver/modelFacade.ts +24 -18
  102. package/server/resolver/modelLoaders.ts +10 -3
  103. package/server/resolver/signal.resolver.ts +28 -31
  104. package/server/resolver/timedQuery.ts +8 -4
  105. package/server/routeCacheQuery.ts +58 -0
  106. package/server/routeCacheTally.ts +65 -0
  107. package/server/routeElementComposer.tsx +16 -0
  108. package/server/routeTreeBuilder.ts +6 -0
  109. package/server/routing/apiRouter.ts +34 -11
  110. package/server/routing/appWsData.ts +4 -0
  111. package/server/routing/builtinRoutes.ts +4 -1
  112. package/server/routing/devRoutes.ts +50 -0
  113. package/server/routing/devSurfacePolicy.ts +40 -0
  114. package/server/routing/devSurfaces.ts +101 -0
  115. package/server/routing/hostAllowlist.ts +2 -0
  116. package/server/routing/roomReplay.ts +4 -0
  117. package/server/routing/serverListener.ts +13 -0
  118. package/server/routing/soloAppRoutes.ts +14 -1
  119. package/server/rscClient.tsx +6 -1
  120. package/server/rscClientChunks.ts +8 -1
  121. package/server/rscClientErrorSender.ts +77 -0
  122. package/server/rscClientErrors.ts +26 -0
  123. package/server/rscFirstRenderMemory.ts +49 -0
  124. package/server/rscFlightRenderer.ts +21 -4
  125. package/server/rscFlightStream.ts +2 -2
  126. package/server/rscHostRenderStream.ts +5 -3
  127. package/server/rscHostRequests.ts +17 -3
  128. package/server/rscRenderAdmission.ts +130 -0
  129. package/server/rscRenderControl.ts +2 -1
  130. package/server/rscRenderHandler.ts +112 -31
  131. package/server/rscRenderLevels.ts +40 -0
  132. package/server/rscRenderRefusal.ts +23 -0
  133. package/server/rscRenderStats.ts +3 -0
  134. package/server/rscResultCaches.ts +20 -2
  135. package/server/rscWorker.tsx +25 -5
  136. package/server/rscWorkerCache.ts +2 -0
  137. package/server/rscWorkerHost.ts +35 -4
  138. package/server/rscWorkerProcess.ts +12 -0
  139. package/server/rscWorkerRecycler.ts +3 -3
  140. package/server/scriptPolicy.ts +128 -0
  141. package/server/serverConfig.ts +11 -0
  142. package/server/serverMetrics.ts +34 -1
  143. package/server/sitemap.ts +0 -5
  144. package/server/ssrFromRscRenderer.tsx +32 -204
  145. package/server/ssrInlineScripts.ts +195 -0
  146. package/server/ssrTypes.ts +15 -2
  147. package/server/systemPageDocument.tsx +6 -2
  148. package/server/systemPages.tsx +9 -4
  149. package/server/webCsrSurface.ts +55 -21
  150. package/server/webDocumentRoute.ts +47 -21
  151. package/server/webRouteContext.ts +25 -8
  152. package/server/webRouter.ts +15 -12
  153. package/server/webRscRoute.ts +18 -14
  154. package/service/agent.service.ts +34 -8
  155. package/service/agentLoop/agentLoop.ts +35 -24
  156. package/service/agentLoop/agentLoopTypes.ts +16 -7
  157. package/service/agentLoop/loopCompaction.ts +1 -1
  158. package/service/agentLoop/loopContext.ts +33 -0
  159. package/service/agentLoop/loopToolkits.ts +17 -8
  160. package/service/index.ts +0 -1
  161. package/service/ipcTypes.ts +56 -0
  162. package/service/mentionToken.ts +44 -0
  163. package/service/predefinedAdaptor/anthropicLlm.ts +18 -17
  164. package/service/predefinedAdaptor/database.adaptor.ts +43 -9
  165. package/service/predefinedAdaptor/directoryNotWritableError.ts +30 -0
  166. package/service/predefinedAdaptor/index.ts +1 -0
  167. package/service/predefinedAdaptor/llm.adaptor.ts +9 -3
  168. package/service/predefinedAdaptor/llmContext.ts +26 -0
  169. package/service/predefinedAdaptor/llmFence.ts +55 -0
  170. package/service/predefinedAdaptor/openaiDialect.ts +45 -18
  171. package/service/predefinedAdaptor/solidSqlite.ts +2 -0
  172. package/service/predefinedAdaptor/sql/driver/bunSqlite.ts +49 -11
  173. package/service/predefinedAdaptor/sql/driver/postgres.ts +47 -10
  174. package/service/predefinedAdaptor/sql/statementFingerprint.ts +117 -0
  175. package/service/predefinedAdaptor/sql/statementPlans.ts +71 -0
  176. package/service/predefinedAdaptor/sql/statementProbe.ts +110 -0
  177. package/service/predefinedAdaptor/sql/statementScrub.ts +149 -0
  178. package/service/predefinedAdaptor/storage.adaptor.ts +5 -0
  179. package/service/predefinedAdaptor/websocket.adaptor.ts +6 -0
  180. package/signal/CrossSiteGuard.ts +5 -0
  181. package/signal/SignalFailure.ts +24 -2
  182. package/signal/browserError.ts +24 -0
  183. package/signal/errorReporting.ts +168 -0
  184. package/signal/httpPeer.ts +9 -0
  185. package/signal/index.ts +2 -3
  186. package/signal/openapi/openapi.ts +4 -0
  187. package/signal/requestTrace.ts +124 -0
  188. package/signal/signalContext.ts +15 -22
  189. package/signal/spanExport.ts +137 -0
  190. package/signal/trace.ts +168 -37
  191. package/store/agent/AgentBridge.ts +6 -2
  192. package/store/agent/AgentContext.ts +81 -14
  193. package/store/agent/AgentInline.ts +72 -0
  194. package/store/agent/StoreSurfaceSource.ts +2 -1
  195. package/store/baseSt.ts +0 -6
  196. package/store/index.ts +1 -3
  197. package/store/stateBuilder.ts +1 -6
  198. package/types/client/appOpenedTab.d.ts +1 -0
  199. package/types/client/clientRuntime.d.ts +4 -2
  200. package/types/client/cn.d.ts +0 -4
  201. package/types/client/cookie.d.ts +4 -3
  202. package/types/client/csrTypes.d.ts +20 -0
  203. package/types/client/device.d.ts +8 -0
  204. package/types/client/frameConfig.d.ts +1 -3
  205. package/types/client/index.d.ts +7 -7
  206. package/types/client/keyboardRide.d.ts +16 -0
  207. package/types/client/rscNavigation.d.ts +0 -10
  208. package/types/client/scriptPolicy.d.ts +4 -0
  209. package/types/common/CodeTranscript.d.ts +1 -0
  210. package/types/common/Logger.d.ts +2 -0
  211. package/types/common/TraceContext.d.ts +28 -0
  212. package/types/common/TrustedProxy.d.ts +1 -0
  213. package/types/common/codeAgentWire.d.ts +10 -2
  214. package/types/common/index.d.ts +1 -0
  215. package/types/common/inlineToken.d.ts +5 -0
  216. package/types/common/logContext.d.ts +1 -0
  217. package/types/common/sessionTokenContract.d.ts +6 -0
  218. package/types/constant/index.d.ts +1 -1
  219. package/types/constant/types.d.ts +0 -2
  220. package/types/document/documentSchema.d.ts +0 -2
  221. package/types/document/filterMeta.d.ts +0 -13
  222. package/types/fetch/client/fetchClient.d.ts +1 -4
  223. package/types/fetch/client/httpClient.d.ts +2 -5
  224. package/types/fetch/client/wsClient.d.ts +3 -3
  225. package/types/fetch/requestStorage.d.ts +9 -0
  226. package/types/index.d.ts +12 -0
  227. package/types/server/admissionQueue.d.ts +26 -0
  228. package/types/server/akanAppHeaders.d.ts +3 -1
  229. package/types/server/akanOption.d.ts +16 -1
  230. package/types/server/assetHeaders.d.ts +5 -3
  231. package/types/server/cachePolicy.d.ts +2 -0
  232. package/types/server/clientErrorReport.d.ts +27 -0
  233. package/types/server/clientReportId.d.ts +9 -0
  234. package/types/server/console.d.ts +0 -7
  235. package/types/server/devtools/devtoolsAccess.d.ts +12 -0
  236. package/types/server/devtools/devtoolsRouter.d.ts +0 -1
  237. package/types/server/devtools/devtoolsUnlockPage.d.ts +11 -0
  238. package/types/server/devtools/signalSerializer.d.ts +3 -1
  239. package/types/server/devtools/studio/studioDocument.d.ts +1 -0
  240. package/types/server/devtools/types.d.ts +5 -0
  241. package/types/server/forwardedError.d.ts +13 -0
  242. package/types/server/gateway/gatewayChildren.d.ts +2 -0
  243. package/types/server/gateway/gatewayConfig.d.ts +1 -0
  244. package/types/server/gateway/gatewayHttpProxy.d.ts +1 -0
  245. package/types/server/gateway/gatewayStatus.d.ts +2 -0
  246. package/types/server/headSplice.d.ts +11 -0
  247. package/types/server/hmr/clientReport.d.ts +2 -0
  248. package/types/server/hmr/csrDevShell.d.ts +3 -1
  249. package/types/server/htmlResultCache.d.ts +13 -3
  250. package/types/server/index.d.ts +4 -3
  251. package/types/server/lifecycle/secretEnv.d.ts +23 -0
  252. package/types/server/logging/logForwarder.d.ts +1 -0
  253. package/types/server/logging/logStdoutWriter.d.ts +1 -0
  254. package/types/server/logging/rotatingLogWriter.d.ts +1 -1
  255. package/types/server/metrics/metricAggregate.d.ts +6 -0
  256. package/types/server/metrics/metricExposition.d.ts +8 -0
  257. package/types/server/metrics/metricMerge.d.ts +9 -0
  258. package/types/server/metrics/metricRegistry.d.ts +76 -0
  259. package/types/server/metrics/pubsubGauges.d.ts +5 -0
  260. package/types/server/metrics/requestMetrics.d.ts +22 -0
  261. package/types/server/metrics/runtimeFamilies.d.ts +9 -0
  262. package/types/server/metrics/slowStatementLog.d.ts +18 -0
  263. package/types/server/metrics/statementMetrics.d.ts +45 -0
  264. package/types/server/metrics/statementPlanCheck.d.ts +16 -0
  265. package/types/server/metrics/statementReport.d.ts +28 -0
  266. package/types/server/ops/statusAccess.d.ts +7 -1
  267. package/types/server/otlp/otlpBatcher.d.ts +18 -0
  268. package/types/server/otlp/otlpConfig.d.ts +25 -0
  269. package/types/server/otlp/otlpEncode.d.ts +13 -0
  270. package/types/server/otlp/otlpExporter.d.ts +18 -0
  271. package/types/server/otlp/otlpSampler.d.ts +10 -0
  272. package/types/server/pageFailure.d.ts +14 -0
  273. package/types/server/renderBusyResponse.d.ts +9 -0
  274. package/types/server/reportText.d.ts +4 -0
  275. package/types/server/resolver/httpEndpointHandler.d.ts +14 -0
  276. package/types/server/resolver/jobTrace.d.ts +5 -0
  277. package/types/server/resolver/modelLoaders.d.ts +3 -0
  278. package/types/server/resolver/timedQuery.d.ts +2 -1
  279. package/types/server/routeCacheQuery.d.ts +11 -0
  280. package/types/server/routeCacheTally.d.ts +23 -0
  281. package/types/server/routeElementComposer.d.ts +2 -0
  282. package/types/server/routing/appWsData.d.ts +3 -0
  283. package/types/server/routing/devRoutes.d.ts +9 -0
  284. package/types/server/routing/devSurfacePolicy.d.ts +12 -0
  285. package/types/server/routing/devSurfaces.d.ts +18 -0
  286. package/types/server/routing/hostAllowlist.d.ts +1 -0
  287. package/types/server/routing/roomReplay.d.ts +1 -0
  288. package/types/server/routing/serverListener.d.ts +2 -0
  289. package/types/server/routing/soloAppRoutes.d.ts +3 -1
  290. package/types/server/rscClient.d.ts +1 -0
  291. package/types/server/rscClientChunks.d.ts +3 -1
  292. package/types/server/rscClientErrorSender.d.ts +8 -0
  293. package/types/server/rscClientErrors.d.ts +3 -0
  294. package/types/server/rscFirstRenderMemory.d.ts +16 -0
  295. package/types/server/rscFlightStream.d.ts +1 -1
  296. package/types/server/rscHostRenderStream.d.ts +2 -1
  297. package/types/server/rscRenderAdmission.d.ts +14 -0
  298. package/types/server/rscRenderControl.d.ts +2 -1
  299. package/types/server/rscRenderHandler.d.ts +5 -2
  300. package/types/server/rscRenderLevels.d.ts +8 -0
  301. package/types/server/rscRenderRefusal.d.ts +9 -0
  302. package/types/server/rscRenderStats.d.ts +2 -0
  303. package/types/server/rscResultCaches.d.ts +8 -1
  304. package/types/server/rscWorkerCache.d.ts +2 -0
  305. package/types/server/rscWorkerHost.d.ts +2 -1
  306. package/types/server/rscWorkerProcess.d.ts +1 -0
  307. package/types/server/rscWorkerRecycler.d.ts +1 -1
  308. package/types/server/scriptPolicy.d.ts +31 -0
  309. package/types/server/serverConfig.d.ts +1 -0
  310. package/types/server/serverMetrics.d.ts +4 -1
  311. package/types/server/sitemap.d.ts +0 -2
  312. package/types/server/ssrFromRscRenderer.d.ts +2 -6
  313. package/types/server/ssrInlineScripts.d.ts +39 -0
  314. package/types/server/ssrTypes.d.ts +14 -2
  315. package/types/server/systemPageDocument.d.ts +3 -1
  316. package/types/server/systemPages.d.ts +2 -1
  317. package/types/server/webRouteContext.d.ts +7 -4
  318. package/types/server/webRouter.d.ts +2 -1
  319. package/types/service/agent.service.d.ts +3 -0
  320. package/types/service/agentLoop/agentLoopTypes.d.ts +16 -7
  321. package/types/service/agentLoop/loopContext.d.ts +13 -0
  322. package/types/service/agentLoop/loopToolkits.d.ts +1 -0
  323. package/types/service/index.d.ts +0 -1
  324. package/types/service/ipcTypes.d.ts +60 -0
  325. package/types/service/mentionToken.d.ts +13 -0
  326. package/types/service/predefinedAdaptor/anthropicLlm.d.ts +3 -3
  327. package/types/service/predefinedAdaptor/database.adaptor.d.ts +2 -0
  328. package/types/service/predefinedAdaptor/directoryNotWritableError.d.ts +6 -0
  329. package/types/service/predefinedAdaptor/index.d.ts +1 -0
  330. package/types/service/predefinedAdaptor/llm.adaptor.d.ts +9 -3
  331. package/types/service/predefinedAdaptor/llmContext.d.ts +11 -0
  332. package/types/service/predefinedAdaptor/llmFence.d.ts +15 -0
  333. package/types/service/predefinedAdaptor/openaiDialect.d.ts +3 -3
  334. package/types/service/predefinedAdaptor/sql/driver/bunSqlite.d.ts +3 -1
  335. package/types/service/predefinedAdaptor/sql/driver/postgres.d.ts +3 -1
  336. package/types/service/predefinedAdaptor/sql/statementFingerprint.d.ts +21 -0
  337. package/types/service/predefinedAdaptor/sql/statementPlans.d.ts +17 -0
  338. package/types/service/predefinedAdaptor/sql/statementProbe.d.ts +37 -0
  339. package/types/service/predefinedAdaptor/sql/statementScrub.d.ts +5 -0
  340. package/types/service/predefinedAdaptor/storage.adaptor.d.ts +1 -0
  341. package/types/service/predefinedAdaptor/websocket.adaptor.d.ts +3 -0
  342. package/types/signal/CrossSiteGuard.d.ts +1 -0
  343. package/types/signal/SignalFailure.d.ts +2 -0
  344. package/types/signal/browserError.d.ts +17 -0
  345. package/types/signal/errorReporting.d.ts +27 -0
  346. package/types/signal/httpPeer.d.ts +5 -0
  347. package/types/signal/index.d.ts +3 -1
  348. package/types/signal/requestTrace.d.ts +33 -0
  349. package/types/signal/signalContext.d.ts +2 -1
  350. package/types/signal/spanExport.d.ts +47 -0
  351. package/types/signal/trace.d.ts +33 -12
  352. package/types/store/agent/AgentBridge.d.ts +1 -0
  353. package/types/store/agent/AgentContext.d.ts +6 -2
  354. package/types/store/agent/AgentInline.d.ts +16 -0
  355. package/types/store/baseSt.d.ts +0 -2
  356. package/types/store/index.d.ts +2 -2
  357. package/types/store/stateBuilder.d.ts +0 -4
  358. package/types/ui/Link/Action.d.ts +2 -1
  359. package/types/ui/Reference/origin.d.ts +0 -2
  360. package/types/ui/System/Common.d.ts +1 -1
  361. package/types/vendor/@akanjs/native/packages/cli/src/lib/project.d.ts +5 -0
  362. package/types/vendor/@akanjs/native/packages/core/src/boot.d.ts +5 -0
  363. package/types/vendor/@akanjs/native/plugins/external-view/src/index.d.ts +20 -8
  364. package/types/vendor/@akanjs/native/plugins/keyboard/src/index.d.ts +3 -2
  365. package/types/vendor/use-agentic/ToolRunner.d.ts +2 -1
  366. package/types/vendor/use-agentic/types.d.ts +8 -0
  367. package/types/webkit/CsrStack.d.ts +2 -1
  368. package/types/webkit/csrPageReadiness.d.ts +18 -0
  369. package/types/webkit/csrSlide.d.ts +30 -0
  370. package/types/webkit/index.d.ts +1 -1
  371. package/types/webkit/nativeNavigation.d.ts +2 -2
  372. package/types/webkit/nativeSplash.d.ts +6 -0
  373. package/types/webkit/openSurfaces.d.ts +13 -0
  374. package/types/webkit/useCsrKeyboard.d.ts +2 -1
  375. package/types/webkit/useCsrNavigation.d.ts +1 -1
  376. package/types/webkit/useEscapeKey.d.ts +7 -2
  377. package/types/webkit/useFrameRuntime.d.ts +6 -2
  378. package/types/webkit/usePageLocation.d.ts +3 -1
  379. package/types/webkit/useVisualViewportFrame.d.ts +2 -0
  380. package/ui/Dialog/Modal.tsx +16 -2
  381. package/ui/KeyboardAvoiding.tsx +2 -1
  382. package/ui/Layout/FrameSlotPortal.tsx +10 -3
  383. package/ui/Link/Action.tsx +2 -1
  384. package/ui/Reference/origin.ts +0 -10
  385. package/ui/System/CSR.tsx +33 -13
  386. package/ui/System/Common.tsx +8 -2
  387. package/ui/System/SSR.tsx +7 -4
  388. package/ui/Tooltip.tsx +1 -1
  389. package/ui/styles.css +14 -0
  390. package/vendor/@akanjs/native/CHANGELOG.md +20 -52
  391. package/vendor/@akanjs/native/native/android/src/com/akanjs/runtime/AkanNativeActivity.kt +27 -14
  392. package/vendor/@akanjs/native/native/desktop/Cargo.lock +1 -0
  393. package/vendor/@akanjs/native/native/desktop/Cargo.toml +2 -0
  394. package/vendor/@akanjs/native/native/desktop/src/acl.rs +27 -7
  395. package/vendor/@akanjs/native/native/desktop/src/external.rs +240 -29
  396. package/vendor/@akanjs/native/native/desktop/src/lib.rs +3 -3
  397. package/vendor/@akanjs/native/native/desktop/src/navigation.rs +4 -0
  398. package/vendor/@akanjs/native/native/ios/Sources/AkanNativeViewController.swift +21 -2
  399. package/vendor/@akanjs/native/packages/cli/src/lib/acl.ts +10 -2
  400. package/vendor/@akanjs/native/packages/cli/src/lib/project.ts +11 -1
  401. package/vendor/@akanjs/native/packages/core/src/boot.ts +6 -0
  402. package/vendor/@akanjs/native/plugins/external-view/native-plugin.json +26 -0
  403. package/vendor/@akanjs/native/plugins/external-view/src/desktop.ts +9 -1
  404. package/vendor/@akanjs/native/plugins/external-view/src/index.ts +20 -8
  405. package/vendor/@akanjs/native/plugins/keyboard/src/index.ts +3 -2
  406. package/vendor/use-agentic/AgentSession.ts +1 -1
  407. package/vendor/use-agentic/CHANGELOG.md +9 -59
  408. package/vendor/use-agentic/Compaction.ts +1 -1
  409. package/vendor/use-agentic/ToolRunner.ts +12 -0
  410. package/vendor/use-agentic/WIRE.md +8 -2
  411. package/vendor/use-agentic/types.ts +8 -0
  412. package/webkit/CsrStack.ts +17 -9
  413. package/webkit/McpAppAgent.ts +3 -1
  414. package/webkit/RenderLayer.tsx +22 -13
  415. package/webkit/bootCsr.tsx +19 -1
  416. package/webkit/csrPageReadiness.ts +43 -0
  417. package/webkit/csrSlide.ts +130 -0
  418. package/webkit/index.ts +1 -1
  419. package/webkit/nativeNavigation.ts +12 -3
  420. package/webkit/nativeSplash.ts +30 -0
  421. package/webkit/openSurfaces.ts +54 -0
  422. package/webkit/useCsrKeyboard.ts +33 -1
  423. package/webkit/useCsrNavigation.ts +69 -21
  424. package/webkit/useCsrTransitions.ts +130 -29
  425. package/webkit/useCsrValues.ts +17 -5
  426. package/webkit/useEscapeKey.tsx +10 -23
  427. package/webkit/useFrameRuntime.ts +55 -6
  428. package/webkit/usePageLocation.ts +8 -2
  429. package/webkit/useVisualViewportFrame.tsx +24 -0
  430. package/client/locale.ts +0 -5
  431. package/service/serviceRegistry.ts +0 -27
  432. package/types/client/locale.d.ts +0 -6
  433. package/types/service/serviceRegistry.d.ts +0 -10
@@ -4,62 +4,30 @@
4
4
 
5
5
  ### Minor Changes
6
6
 
7
- - 038d918: Akan.js 3.2.0. Read **Upgrade notes** before deploying an app that runs 3.1.1: unguarded endpoints, log levels, the `Err` class, loaders, SQLite transactions, exit codes and a CLI version check change behaviour.
7
+ - aff1ba2: An external view opens only origins the app's config lists, in `native.desktop.externalView.allowOrigins`: a view's own `allowOrigins` narrow within them, and an origin outside them is `NOT_ALLOWED`, naming that key. `evaluate` and `initScript` need their own permission, granted by `desktop.externalView.evaluate: true`, and `sendKey` its own, granted by `desktop.externalView.sendKey: true`; both are off by default. While a view is open, opening its id again keeps its origins or narrows them, and refuses one it was not opened for; once closed, the id opens again for any origins the config lists, with the same browser profile, which belongs to the id. Origins compare exactly as the URL parser reads them: scheme, host and port, the host in punycode without a trailing dot, the default port left out, and an origin with user info refused; there are no wildcards. A view loads a URL as the URL parser writes it, so the engine never reads the page's text another way. A page opens a view only over its own window. The desktop shell checks all of this itself on macOS, Windows and Linux, and grants nothing when the build carries no permission list; on Windows a view now takes only the two DevTools calls `sendKey` and `capture` make. A top-level navigation or redirect off a view's origins stays refused, as before.
8
8
 
9
- **Highlights**
9
+ A plugin manifest's `scope` can say `required: true`: then every grant of the plugin, not only `<plugin>:default`, is within its `defaultScope` unless the grant gives its own `allow`, and a scope entry naming no field is a build error. `external-view` says so.
10
10
 
11
- - **`agentService.loop`.** A server-side agent run over the `/mcp` tool catalogue, in-process, with `toolkits`, `remotes` (other MCP servers), `clientTools` (a screen the member has open), `ask` (a question parked between runs), `answer`, overflow retry, and a read rule that counts what a run reads as untrusted. `plug(AgentToolsRole)` runs the catalogue as a given account; `mcp: "agent"` keeps an entry off `/mcp` for the in-process agent only.
12
- - **Akan Graph and Akan Studio.** `get_graph` (MCP) returns the Akan Graph, read from source with no dev server: models, scalars, slices, endpoints with guards, services, jobs, adaptors, routes, layouts, the framework itself, and the Change Map for `since: <revision>`. `akan start` serves Studio at `/_akan/studio`, and it opens from the CLI and the editor.
13
- - **Editor support.** `@akanjs/language` resolves names Akan.js derives (`fetch.initMemoInPublic`, `st.do.setNameOnMemo`, `this.memoService.listByName`) and ships `akan-language-server`. The VS Code / Cursor extension opens a module side by side, runs `akan verify` and workflows, and publishes from CI to the VS Marketplace and Open VSX.
14
- - **Secure defaults.** Signals, websocket rooms, MCP, OAuth, the agent relay, the server edge, the ops channel, native builds, `akan code`, the CLI's tunnels and workflows, and the in-page agent each take the narrower default. Every change names how to get the old behaviour back.
15
- - **Faster pages.** Every SSR page loads 72K less framework JS (22K less Brotli); client modules preload from `<head>`; Link prefetch; Flight rows share inline scripts; one preloaded font face per family; faster RSC decoding and store writes; a route JS budget (`akan build --check-budget`).
16
- - **Realtime.** Per-socket, per-caller and per-model room limits, subscribe budgets, gateway subscribe acks, per-model live-sync routing, Redis room sharding, resync after a Redis outage, and an outbox limit for a down socket.
17
- - **Native.** `external-view` on Linux (Wayland and X11) with `sendKey`; Android 12 launch crash fixed; AppImage relaunch; tighter CSP, external-link, temp-folder and update defaults.
11
+ **Upgrading.** An app that lists `external-view` opens no view until its `akan.config.ts` names the origins, and needs `evaluate` and `sendKey` only for the calls it makes:
18
12
 
19
- **Upgrade notes**
13
+ ```ts
14
+ native: {
15
+ plugins: ["external-view"],
16
+ desktop: {
17
+ externalView: {
18
+ allowOrigins: ["https://board.example"], // every origin a view's allowOrigins names
19
+ evaluate: true, // when it calls evaluate or opens with initScript
20
+ sendKey: true, // when it calls sendKey
21
+ },
22
+ },
23
+ },
24
+ ```
20
25
 
21
- - **Guards.** An endpoint, slice query or pubsub room that declares no guards is refused with 403; open it with `[Public]`. Outside local operation a server whose signals declare a guardless endpoint stops at boot and names each one. `AKAN_UNGUARDED_ENDPOINTS=open` answers them as before. A slice whose `guards` leaves out `root` mounts no root list or insight. `guard(name)` refuses until `canPass` is overridden.
22
- - **`Err`.** Every `Err` is one class, `Err` from `akanjs/common`, and an `AkanError`. `err.code` is always set (a generalized failure's code, else its status's code), so `{ ...err }` now holds it. `Err.NotFound.is(error)` also requires status 404. Check across a page bundle and the framework with `Err.is`, not `instanceof`. `setErrorConstructor`, `HttpClientOptions.ErrorCls` and `FetchClient.build`'s `Err` option are deprecated.
23
- - **Coded failures.** The signal, service, server, route-tree, RSC and client facets throw coded `AkanError`s instead of a bare `Error`; messages and statuses are unchanged. A production 500 shows the status reason and code only. `bun run error:codes` lists the codes. A failed tool call and a failed agent turn carry a `code`.
24
- - **Log levels.** A failure under 500 logs at `warn`, a 5xx is one `error` record with `type` and `stack`, a declared error, a 429 and a by-id read of a missing id log at `debug`, and a crashed RSC worker logs at `warn`. Alerts and `--level error` filters see fewer lines. A page `redirect()` is `ok` at `info` with its 3xx status, and `notFound()` is `warn` with 404. Every log record reaches ndjson stdout, and a request line is never folded.
25
- - **Loaders.** A loader no longer shares a batch between a transaction and the requests outside it, and each caller gets its own document. A loader that keeps its keys forgets them when the model is written; a write by query clears every kept key of the model, and `cache: true` keeps the 10,000 most recent keys. A custom `DatabaseAdaptor` can implement `transactionKey()`; a `batchScheduleFn` must run its callback in the caller's async context.
26
- - **SQLite.** Work outside an open `this.transaction()` no longer sees its uncommitted rows, on `:memory:` or a non-WAL file either. `SqliteDatabase.getMeta` and `listMeta` return promises, so await them. A reader pays one database copy per transaction on `:memory:`; past a few tens of megabytes, put the database in a file.
27
- - **Indexes.** A boot keeps an index the release no longer declares and warns about it. After every instance runs this release, run `akan migrate <app> prune-indexes` once. `migrationActions` gains `indexes` and `prune-indexes`, so code that switches over every action needs the two cases.
28
- - **Websockets.** A socket holds at most 256 rooms, a caller 2,000 per process, a model 50,000 evaluated live rooms; a subscribe past a limit gets a 429 frame coded `liveRoomLimit`. Subscribes are budgeted at 1,000 a minute per socket and 10,000 per caller. A `pubsub` room's `onResync` also runs after Redis returns; a custom `WebsocketAdaptor.onRecovered` handler now takes the held rooms. A down socket keeps at most 100 emits.
29
- - **Gateway.** `/_akan/app/ready` answers 503 while no replica's RSC worker can render. A subscribe is acknowledged once the gateway routes the room.
30
- - **CLI.** A CLI whose major.minor differs from the workspace's `akanjs` refuses every command that writes, with exit 2; run `akan update`, or set `AKAN_ALLOW_VERSION_MISMATCH=1`. Exit codes: 2 for usage and unknown targets, 3 for failed checks (`verify`, `typecheck`), 130 for an interrupted prompt; a script that tested for exit 1 tests for non-zero. With `--json`, a failure ends stdout with `{"ok":false,"error":"<message>","code":"<code>"}`. `akan doctor` exits 1 on `"status": "failed"`; `akan workflow plan`, `apply` and `validate` exit non-zero on failure. A shell `AKAN_PUBLIC_ENV` now outranks the workspace `.env`, and `akan build --env <env>` builds another environment.
31
- - **Package budget.** `akan lint` and `akan verify` hold each package under `pkgs/` to the file, function and class budget. Run `akan quality baseline` once in a workspace whose packages are over it. `akan verify` also typechecks every app and lib that uses a changed lib.
32
- - **Secure defaults.**
33
- - Write tools in the in-page agent confirm by default (`submit`, `create`, `update`, `send`, `export` and the rest, not only `remove`); opt out with `{ confirm: false }`. Page text reaches the model fenced as data, and a transcript belongs to one account.
34
- - A `FetchClient` sends its session token only to its own origin; pass `clone({ origin, jwt })` to send one elsewhere.
35
- - A connection idle for 120 s closes (`AKAN_IDLE_TIMEOUT`), a body is capped at 128 MiB (`AKAN_MAX_UPLOAD_BODY`) and 16 MiB for a non-multipart one (`AKAN_MAX_REQUEST_BODY`), `akan start` binds 127.0.0.1 (`AKAN_LISTEN_HOST=*` restores it), and HTML carries `Cache-Control`, HSTS and a `frame-ancestors` policy.
36
- - The dev server answers only `localhost`, `*.localhost` and IP hosts unless `AKAN_ALLOWED_HOSTS` is set.
37
- - A 500 shows its message and stack only under `akan start`, `NODE_ENV` `development` or `test`, or `AKAN_ERROR_DETAIL=1`.
38
- - `ops snapshot` outside local operation needs `AKAN_BACKUP_RECIPIENT` or `--allow-plaintext`; the ops key must differ from `AKAN_MACHINE_PUBLIC_KEY`.
39
- - `/__rsc/manifest` is dev-only (`AKAN_EXPOSE_RSC_MANIFEST=1`), and health detail, metrics and devtools need a local dev runtime.
40
- - Filter arguments are parsed against their declared type and an `Any` filter argument throws at declaration; `q.search()` text is capped at 32 terms and 1000 characters.
41
- - The image optimizer refuses non-public remote hosts (`images.dangerouslyAllowLocalIP`).
42
- - The CLI's tunnels listen on loopback and check the SSH host key, workflow commands run without a shell, `akan download-env` copies only env and secret files, a Dockerfile built with `AKAN_PUBLIC_ENV=local` needs `--build-arg AKAN_ALLOW_LOCAL_IMAGE=1`, and `akan code` asks before network access and trusts a repository's MCP servers and extensions only after one terminal approval.
43
- - MCP rate-limits an unverified bearer by address, checks the browser Origin, and bounds client registration; the agent relay refuses a request past fixed limits with `agent.error.requestRefused` (413) unless a policy sets its own.
44
- - Native builds ship a Content-Security-Policy, open only `https:`, `mailto:` and `tel:` links, and recheck a downloaded desktop update before installing it; `updates.windowsSigners` and `updates.expiresIn` are new.
45
- - **UI.** `Field.Switch`'s on position is `primary` (pass `variant="accent"` for the old look), and two `Data.Item` status tags change color. `useCamera` and `useGeoLocation` no longer send the user to Settings after a denial. A page `.head()` can set `theme-color`, and a level that writes an image no longer inherits the image tags above it. `--akan-theme-color` drives the browser's `theme-color`.
46
- - **Libraries.** The `shared` and `util` libraries `akan install-library` copies are refreshed; compare your copy. In `util`, `security` and `security.jwtSecret` are optional in `ModulesOptions`. `libs/shared` keeps its SSO and refresh cookies on `__Host-` names outside local.
47
- - **Other.** `LLM` stream endings are read more completely: a cut tool call ends as `length`, and unparseable arguments in a finished answer get `argsError` and the code `invalidArgument`. `ConformanceEnv.has` fails instead of skipping when `AKAN_TEST_REQUIRE_BACKENDS=1`. A new workspace has no `patches/` folder, no `agent:sample:*` scripts and one `setup:agent` script; `create-akan-workspace` no longer hangs when `akan` is not on PATH.
26
+ An app built with the akan-native CLI's own config grants the same in its capabilities: `{ identifier: "external-view:default", allow: [{ origin: "https://board.example" }] }`, `"external-view:allow-evaluate"` and `"external-view:allow-sendKey"`. A grant of `external-view:all` or `external-view:allow-open` opens no origin unless its own `allow` lists them. A page that passed `window` to `open` passes its own window or leaves it out.
48
27
 
49
- **Features**
28
+ ### Patch Changes
50
29
 
51
- - **Agent.** `Agent.Chat` modals and toasts stack above the panel and its header takes a node; the tool row is the `AgentToolRow` override slot; a restored transcript that ends on an unanswered `askUser` reopens on it; a turn its caller stops is billed at what the provider plausibly charged, and every turn the quota passes is billed.
52
- - **Rendering and navigation.** `{ static: true }` page apps answer a host that asks for script-less HTML; `i18n.localePrefix: "as-needed"` serves the default locale unprefixed; a route guard receives `{ path }` and `signedIn({ path })` adds `?redirect=`; a failed route level or `Load.Stream` draws a notice with "Try again" in its own place; `router.refresh()` in CSR no longer reloads the document; a lazy chunk the server no longer serves reloads the page once; `forwardVisitor: false` keeps a render cacheable; a query takes `signal` and identical in-flight queries share one request.
53
- - **Data.** `create<Model>Many(rows)` runs every row through `_preCreate`, `_postCreate` and the document hooks; `bulkWrite` runs in one transaction; a cascade removes a long array's documents 200 ids at a time; `Binary` arguments are typed `Uint8Array<ArrayBuffer>`; a hidden `.optional()` field is optional in create inputs; store form setters and writes cost about one copy of the state; `onError` on store writes receives the failed request's dictionary error.
54
- - **Server and ops.** `/_akan/app/ready`; `RestartSchedule` shared by every child-restart loop; a single-flight `cache` endpoint; stopped or failed starts tear down what they brought up; the Redis WebSocket adaptor shards channels per room and model and flushes publishes on shutdown; a log stream stops growing for a client that stops reading; missing assets answer `no-store`.
55
- - **CLI.** `akan test --parallel=<n>`, `--junit <path>` and `--coverage`; `akan build --env`; a `rename-key` workflow; `akan remove-module pokedex:_billing` removes a service module; `akan create-workspace` works in an existing folder, without sample code, and without a git identity; `akan preview` opens `/_akan/studio`, `/openapi.json` and `/mcp` as written and restarts a dead browser; `akan verify` reports step durations and gives a dictionary hint for a missing key; commands without a terminal take the workspace's only app, lib or package, and remove commands never pick a target themselves; release candidates publish from CI with npm provenance.
56
- - **Native.** `external-view` and `sendKey` on Linux; Android 12 and 12L launch fix; AppImage relaunch; a `single-instance` pipe that another account cannot own on Windows.
57
- - **Types and styling.** A new app's default style is Pretendard with -3% letter spacing, even sizes from 12px, 150% line height for wrapping text and `leading-auto` for one line.
30
+ - 43b44ca: An Android app's page now meets the keyboard the way the iOS app's does: the keys rise over the page and only what the page moves rides up with them. In keyboard mode "none" (what akan apps ship) the Android WebView still heard of the keyboard through the window insets, shrank its visual viewport to the space above the keys and panned the whole page so the focused field showed, which lifted a chat composer far above the keys, dragged whatever sat under it (a tab bar's room) up too, and slid the top of the page under the status bar. The Android shell now hands the WebView its insets with the keyboard taken out in "none" (and its animation callbacks too), keeps the bottom safe area while the keys are up, reports the keys' whole overlap with the screen as the iOS shell does, and tells the page through `__AKAN_NATIVE__.keyboardAvoidance = "page"`. Under such a shell the frame ends the content at the keys and `KeyboardRide` carries what is marked `data-akan-keyboard-ride` with them, on the duration the shell reports and Android's IME curve (`ANDROID_KEYBOARD_ANIMATION_EASING`, added to `akanjs/client`). A page under an older shell, which still pans, keeps today's behavior; an Android app gets the new behavior once it is built with this shell.
31
+ - 3032627: An iOS app's page now meets the keyboard the way a native screen does: its content ends at the keys and moves with them, and a header stays where it is. In keyboard mode "none" (what akan apps ship) WKWebView still met the keyboard on its own, insetting its scroll view and panning the whole page until the focused field cleared the keys, so the header went off screen, the page showed under the status bar, and whatever the frame did for the keyboard came on top of the pan. The iOS shell now takes the keyboard notifications away from WKWebView in "none", as Capacitor's Keyboard plugin does, and tells the page through `__AKAN_NATIVE__.keyboardAvoidance = "page"`. Under such a shell the frame ends every page's content at the keys (not only a page with a keyboard accessory), drops the bottom safe area and inset the keys cover, animates on the duration the shell reports with UIKit's keyboard curve (`IOS_KEYBOARD_ANIMATION_EASING`), and scrolls a field the keys cover back into view; a dialog ends at the keys too, `useVisualViewportFrame` reports the keys from the shell, `KeyboardAvoiding` steps aside, and `--akan-keyboard-duration` / `--akan-keyboard-easing` plus `data-akan-keyboard` (while the keys are up) on the root let a page move its own parts with the keys. A page under an older shell, which still pans, keeps today's behavior.
58
32
 
59
- **Fixes**
60
-
61
- - A dev page keeps its styles after a stylesheet change arrives with a pages rebuild; idle-suspended dev servers apply every save, stay awake when work arrives, and stop cleanly; `[BarrelAnalyzer] ERROR scan failed` is gone; a backend replica's builder answer no longer reaches its replacement.
62
- - A page that renders a string of 1024 characters or more renders and hydrates whatever its lines say; a page cut off by a disconnected client, or one that streamed an error, is no longer cached; partial RSC commit (`AKAN_PUBLIC_RSC_PARTIAL_COMMIT=1`) patches real pages, replays patches from cache and cancels overtaken navigations.
63
- - In production, a render error no longer reaches the browser as its message; reading the client address from a crafted forwarded header no longer stalls the server; `happy-dom` peers ask for `^21.0.4`; the pi agent packages move to 1.5.2, dropping undici and minimatch advisories.
64
- - The build lock records its host and survives a dead remover, a Windows antivirus hold and a devcontainer; `akan` no longer rebuilds the dev CLI from a command it runs; the typecheck behind `akan verify` and `akan build` uses its incremental cache.
65
- - Internal: the largest classes and methods in `akanjs`, `@akanjs/devkit` and `@akanjs/cli` are split by concern with unchanged public members, and the `akanjs` facets import sibling files instead of their own barrel and list every export by name.
33
+ The api report lists additions only: `Device.keyboardAnimationMs`, `Device.keyboardHeight` and `Device.subscribeKeyboard`, the optional `KeyboardFrameState.avoidsContent` and `isPageKeyboardAvoidance` from `akanjs/webkit`; no upgrade step is needed. An iOS app gets the new behavior once it is built with this shell; a page that lifted its own composer by the keyboard's height under the old pan should drop that lift.
@@ -358,8 +358,9 @@ class AkanNativeActivity : Activity(), AkanNativePluginContext.Host {
358
358
  // The shell's origin and engine: one value every origin comparison uses (`__AKAN_NATIVE__.origin`).
359
359
  val version = JSONObject.quote(WebView.getCurrentWebViewPackage()?.versionName ?: "")
360
360
  val engine = "window.__AKAN_NATIVE__.origin=\"${AkanNativeAssetServer.ORIGIN}\";window.__AKAN_NATIVE__.engine=\"android-webview\";window.__AKAN_NATIVE__.engineVersion=$version;\n"
361
+ val keyboard = if (imeResize) "" else "window.__AKAN_NATIVE__.keyboardAvoidance=\"page\";\n"
361
362
  // A new document starts with the current safe area (N14); later changes are pushed.
362
- return INIT_PREFIX + AkanNativeBridge.jsSafe(bootJson) + "," + AkanNativeBridge.jsSafe(env) + INIT_SUFFIX + engine + cssInsets(currentInsets)
363
+ return INIT_PREFIX + AkanNativeBridge.jsSafe(bootJson) + "," + AkanNativeBridge.jsSafe(env) + INIT_SUFFIX + engine + keyboard + cssInsets(currentInsets)
363
364
  }
364
365
 
365
366
  private fun readAsset(path: String): String = assets.open(path).bufferedReader().use { it.readText() }
@@ -605,8 +606,9 @@ class AkanNativeActivity : Activity(), AkanNativePluginContext.Host {
605
606
  val m = if (Build.VERSION.SDK_INT >= 30) Api30.measure(insets) else legacyMeasure(insets)
606
607
  val sys = m.bars
607
608
  val density = resources.displayMetrics.density
608
- // Keyboard height above the navigation bar, like react-native ReactRootView.
609
- val keyboard = if (m.imeVisible) maxOf(0, m.imeBottom - sys.bottom) else 0
609
+ // Keyboard height above the navigation bar, like react-native ReactRootView; a page that meets the keyboard
610
+ // itself spans the screen, so it gets the whole overlap, as on iOS.
611
+ val keyboard = if (!m.imeVisible) 0 else if (imeResize) maxOf(0, m.imeBottom - sys.bottom) else m.imeBottom
610
612
  val next = AkanNativeInsets(sys.top / density, sys.right / density, sys.bottom / density, sys.left / density, m.imeVisible, keyboard / density)
611
613
  if (next != currentInsets) {
612
614
  val wasVisible = currentInsets.imeVisible
@@ -625,11 +627,13 @@ class AkanNativeActivity : Activity(), AkanNativePluginContext.Host {
625
627
  // "Resize" keyboard mode: shrink the WebView container by the IME so fixed bottom UI stays
626
628
  // visible (WebView ignores interactive-widget). Do not consume the insets (crbug 461332423).
627
629
  view.setPadding(0, 0, 0, if (m.imeVisible && imeResize) m.imeBottom else 0)
628
- val bars = Insets.of(sys.left, sys.top, sys.right, if (m.imeVisible) 0 else sys.bottom)
629
- if (Build.VERSION.SDK_INT >= 30) Api30.withBars(insets, bars)
630
+ // Keyboard mode "none": the WebView never hears of the keyboard, or it shrinks its visual viewport and pans the
631
+ // page to the focused field on top of what the page does (`keyboardAvoidance`).
632
+ val bars = Insets.of(sys.left, sys.top, sys.right, if (m.imeVisible && imeResize) 0 else sys.bottom)
633
+ if (Build.VERSION.SDK_INT >= 30) Api30.withBars(insets, bars, hidesIme = !imeResize)
630
634
  else @Suppress("DEPRECATION") WindowInsets.Builder(insets).setSystemWindowInsets(bars).build()
631
635
  }
632
- if (Build.VERSION.SDK_INT >= 30) Api30.watchImeAnimation(root) { show, heightPx, duration, done ->
636
+ if (Build.VERSION.SDK_INT >= 30) Api30.watchImeAnimation(root, { !imeResize }) { show, heightPx, duration, done ->
633
637
  val phase = if (done) (if (show) "didShow" else "didHide") else (if (show) "willShow" else "willHide")
634
638
  keyboardTransition(phase, if (show) heightPx / resources.displayMetrics.density else 0f, duration)
635
639
  }
@@ -658,9 +662,9 @@ class AkanNativeActivity : Activity(), AkanNativePluginContext.Host {
658
662
  return Measured(bars, if (imeVisible) sw.bottom else 0, imeVisible)
659
663
  }
660
664
 
661
- /** The CSS variables for these insets, in CSS px; bottom is 0 while the keyboard shows (as WebView's env() does). */
665
+ /** The CSS variables for these insets, in CSS px; bottom is 0 while the keyboard shows over a resized WebView (as WebView's env() does). */
662
666
  private fun cssInsets(i: AkanNativeInsets): String {
663
- val bottom = if (i.imeVisible) 0f else i.bottom
667
+ val bottom = if (i.imeVisible && imeResize) 0f else i.bottom
664
668
  return "document.documentElement&&(function(s){s.setProperty('--akan-native-safe-area-top','${i.top}px');" +
665
669
  "s.setProperty('--akan-native-safe-area-right','${i.right}px');s.setProperty('--akan-native-safe-area-bottom','${bottom}px');" +
666
670
  "s.setProperty('--akan-native-safe-area-left','${i.left}px')})(document.documentElement.style);\n"
@@ -947,19 +951,27 @@ class AkanNativeActivity : Activity(), AkanNativePluginContext.Host {
947
951
  return Measured(insets.getInsets(bars), if (visible) insets.getInsets(ime).bottom else 0, visible)
948
952
  }
949
953
 
950
- fun withBars(insets: WindowInsets, value: Insets): WindowInsets = WindowInsets.Builder(insets).setInsets(bars, value).build()
954
+ fun withBars(insets: WindowInsets, value: Insets, hidesIme: Boolean): WindowInsets =
955
+ WindowInsets.Builder(insets).setInsets(bars, value).build().let { if (hidesIme) withoutIme(it) else it }
956
+
957
+ fun withoutIme(insets: WindowInsets): WindowInsets {
958
+ val ime = WindowInsets.Type.ime()
959
+ return WindowInsets.Builder(insets).setInsets(ime, Insets.NONE).setVisible(ime, false).build()
960
+ }
951
961
 
952
962
  /**
953
963
  * The IME's show and hide animations: [report] (show, height px above the bars once it ends,
954
- * duration ms, ended) at the start and at the end. At the start the view's root insets are
955
- * already the end state.
964
+ * or the whole overlap when [isPage], duration ms, ended) at the start and at the end. At the
965
+ * start the view's root insets are already the end state. With [isPage] the WebView's own
966
+ * animation callbacks see no IME either.
956
967
  */
957
- fun watchImeAnimation(view: View, report: (Boolean, Float, Long, Boolean) -> Unit) {
968
+ fun watchImeAnimation(view: View, isPage: () -> Boolean, report: (Boolean, Float, Long, Boolean) -> Unit) {
958
969
  val ime = WindowInsets.Type.ime()
959
970
  fun target(): Pair<Boolean, Float> {
960
971
  val insets = view.rootWindowInsets ?: return false to 0f
961
972
  val show = insets.isVisible(ime)
962
- val height = maxOf(0, insets.getInsets(ime).bottom - insets.getInsets(WindowInsets.Type.systemBars()).bottom)
973
+ val bottom = insets.getInsets(ime).bottom
974
+ val height = if (isPage()) bottom else maxOf(0, bottom - insets.getInsets(WindowInsets.Type.systemBars()).bottom)
963
975
  return show to height.toFloat()
964
976
  }
965
977
  view.setWindowInsetsAnimationCallback(object : android.view.WindowInsetsAnimation.Callback(DISPATCH_MODE_CONTINUE_ON_SUBTREE) {
@@ -968,7 +980,8 @@ class AkanNativeActivity : Activity(), AkanNativePluginContext.Host {
968
980
  return bounds
969
981
  }
970
982
 
971
- override fun onProgress(insets: WindowInsets, running: MutableList<android.view.WindowInsetsAnimation>): WindowInsets = insets
983
+ override fun onProgress(insets: WindowInsets, running: MutableList<android.view.WindowInsetsAnimation>): WindowInsets =
984
+ if (isPage()) withoutIme(insets) else insets
972
985
 
973
986
  override fun onEnd(animation: android.view.WindowInsetsAnimation) {
974
987
  if (animation.typeMask and ime != 0) target().let { (show, height) -> report(show, height, animation.durationMillis, true) }
@@ -13,6 +13,7 @@ dependencies = [
13
13
  "objc2-app-kit",
14
14
  "objc2-foundation",
15
15
  "tao",
16
+ "url",
16
17
  "webkit2gtk",
17
18
  "webview2-com",
18
19
  "windows",
@@ -14,6 +14,8 @@ crate-type = ["cdylib"]
14
14
  wry = { version = "=0.57.0", default-features = false, features = ["devtools"] }
15
15
  # tao defaults = rwh_06 + x11 + dbus. macOS needs only rwh_06 (wry uses raw-window-handle 0.6).
16
16
  tao = { version = "=0.37.0", default-features = false, features = ["rwh_06"] }
17
+ # The WHATWG URL parser, already in the tao tree: an external view's origins compared as a browser reads them.
18
+ url = "2.5"
17
19
 
18
20
  [target.'cfg(target_os = "macos")'.dependencies]
19
21
  # Already in the wry/tao dependency tree; we only enable more features (menu, appearance, workspace,
@@ -1,4 +1,5 @@
1
- //! core/src/acl.ts as far as the links the shell hands to the OS need it; vectors.rs runs the shared vectors on it.
1
+ //! core/src/acl.ts as far as the shell needs it: the links it hands to the OS (vectors.rs runs the shared vectors on
2
+ //! them) and what an external view may be opened for and sent.
2
3
 
3
4
  use crate::json::V;
4
5
 
@@ -65,24 +66,43 @@ impl Acl {
65
66
  parsed().unwrap_or(Acl { grants: Vec::new(), denied: Vec::new() })
66
67
  }
67
68
 
68
- pub fn opener_permits(&self, url: &str, window: u32) -> bool {
69
- let (plugin, item) = ("opener", "openUrl");
69
+ /// aclCheck: the grants that allow `item` of `plugin` in `window`, None when it is not allowed.
70
+ fn granted(&self, plugin: &str, item: &str, window: u32) -> Option<Vec<&Grant>> {
70
71
  if self.denied.iter().any(|(p, items)| p == plugin && items.iter().any(|i| i == item)) {
71
- return false;
72
+ return None;
72
73
  }
73
74
  let matching: Vec<&Grant> = self
74
75
  .grants
75
76
  .iter()
76
77
  .filter(|g| g.plugin == plugin && g.items.as_ref().is_none_or(|i| i.iter().any(|x| x == item)) && g.windows.as_ref().is_none_or(|w| w.contains(&window)))
77
78
  .collect();
78
- if matching.is_empty() {
79
+ (!matching.is_empty()).then_some(matching)
80
+ }
81
+
82
+ pub fn permits(&self, plugin: &str, item: &str, window: u32) -> bool {
83
+ self.granted(plugin, item, window).is_some()
84
+ }
85
+
86
+ /// aclCheck, then scopePermits: no deny entry matches, and the grants have no allow list or one of its entries matches.
87
+ pub fn scope_permits(&self, plugin: &str, item: &str, window: u32, matches: impl Fn(&[(String, String)], bool) -> bool) -> bool {
88
+ let Some(matching) = self.granted(plugin, item, window) else { return false };
89
+ if matching.iter().any(|g| g.deny.iter().any(|e| matches(e, true))) {
79
90
  return false;
80
91
  }
81
- let matches = |e: &Entry, deny: bool| e.iter().all(|(field, pattern)| field == "url" && url_match(pattern, url, deny));
92
+ matching.iter().any(|g| g.allow.is_none()) || matching.iter().flat_map(|g| g.allow.iter().flatten()).any(|e| matches(e, false))
93
+ }
94
+
95
+ /// scope_permits for a scope the app must list: a grant without an allow list, and an entry naming no field, give nothing.
96
+ pub fn scope_lists(&self, plugin: &str, item: &str, window: u32, matches: impl Fn(&[(String, String)], bool) -> bool) -> bool {
97
+ let Some(matching) = self.granted(plugin, item, window) else { return false };
82
98
  if matching.iter().any(|g| g.deny.iter().any(|e| matches(e, true))) {
83
99
  return false;
84
100
  }
85
- matching.iter().any(|g| g.allow.is_none()) || matching.iter().flat_map(|g| g.allow.iter().flatten()).any(|e| matches(e, false))
101
+ matching.iter().flat_map(|g| g.allow.iter().flatten()).any(|e| !e.is_empty() && matches(e, false))
102
+ }
103
+
104
+ pub fn opener_permits(&self, url: &str, window: u32) -> bool {
105
+ self.scope_permits("opener", "openUrl", window, |e, deny| e.iter().all(|(field, pattern)| field == "url" && url_match(pattern, url, deny)))
86
106
  }
87
107
  }
88
108