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.
- package/ARCHITECTURE.md +3 -2
- package/CHANGELOG.md +391 -23
- package/CONTRIBUTING.md +2 -2
- package/README.ko.md +40 -296
- package/README.md +41 -297
- package/client/appOpenedTab.ts +12 -0
- package/client/clientRuntime.ts +3 -10
- package/client/cn.ts +4 -4
- package/client/cookie.ts +15 -6
- package/client/csrTypes.ts +17 -0
- package/client/device.ts +43 -3
- package/client/frameConfig.ts +27 -6
- package/client/index.ts +12 -6
- package/client/keyboardRide.ts +124 -0
- package/client/router.ts +6 -3
- package/client/rscNavigation.ts +0 -7
- package/client/scriptPolicy.ts +14 -0
- package/common/CodeTranscript.ts +4 -2
- package/common/Logger.ts +4 -1
- package/common/TraceContext.ts +97 -0
- package/common/TrustedProxy.ts +10 -0
- package/common/codeAgentProfile.ts +1 -1
- package/common/codeAgentWire.ts +7 -2
- package/common/index.ts +1 -0
- package/common/inlineToken.ts +26 -0
- package/common/logContext.ts +1 -0
- package/common/sessionTokenContract.ts +7 -0
- package/constant/index.ts +0 -1
- package/constant/types.ts +0 -2
- package/document/documentSchema.ts +0 -3
- package/document/filterMeta.ts +3 -16
- package/fetch/client/fetchClient.ts +8 -17
- package/fetch/client/httpClient.ts +22 -12
- package/fetch/client/wsClient.ts +10 -6
- package/fetch/requestStorage.ts +30 -0
- package/index.ts +8 -0
- package/package.json +263 -57
- package/server/SSR_MEMORY_DIAGNOSIS.md +88 -1
- package/server/admissionQueue.ts +107 -0
- package/server/akanApp.ts +39 -14
- package/server/akanAppHeaders.ts +20 -6
- package/server/akanOption.ts +28 -0
- package/server/akanServer.ts +13 -1
- package/server/assetHeaders.ts +8 -3
- package/server/cachePolicy.ts +2 -1
- package/server/clientErrorReport.ts +191 -0
- package/server/clientReportId.ts +54 -0
- package/server/console.ts +5 -12
- package/server/devtools/README.md +15 -3
- package/server/devtools/devtoolsAccess.ts +119 -0
- package/server/devtools/devtoolsRouter.ts +30 -26
- package/server/devtools/devtoolsUnlockPage.ts +38 -0
- package/server/devtools/signalSerializer.ts +18 -1
- package/server/devtools/studio/studioDocument.tsx +3 -1
- package/server/devtools/studio/studioRoute.ts +4 -1
- package/server/devtools/types.ts +6 -0
- package/server/flightSanitizeRecorded.fixture.json +36 -34
- package/server/forwardedError.ts +43 -0
- package/server/gateway/gatewayChildren.ts +3 -0
- package/server/gateway/gatewayConfig.ts +5 -0
- package/server/gateway/gatewayHttpProxy.ts +10 -2
- package/server/gateway/gatewayStatus.ts +21 -1
- package/server/gateway/gatewayStatusPage.ts +18 -11
- package/server/headSplice.ts +73 -0
- package/server/hmr/clientReport.ts +9 -9
- package/server/hmr/csrDevShell.ts +7 -4
- package/server/htmlResultCache.ts +81 -14
- package/server/imageOptimizer.ts +44 -12
- package/server/index.ts +2 -4
- package/server/lifecycle/secretEnv.ts +98 -0
- package/server/lifecycle/shutdownManager.ts +6 -0
- package/server/logging/logForwarder.ts +2 -2
- package/server/logging/logQuery.ts +9 -1
- package/server/mcp/McpDispatcher.ts +13 -10
- package/server/metrics/metricAggregate.ts +27 -0
- package/server/metrics/metricExposition.ts +92 -0
- package/server/metrics/metricMerge.ts +81 -0
- package/server/metrics/metricRegistry.ts +271 -0
- package/server/metrics/pubsubGauges.ts +20 -0
- package/server/metrics/requestMetrics.ts +110 -0
- package/server/metrics/runtimeFamilies.ts +61 -0
- package/server/metrics/slowStatementLog.ts +63 -0
- package/server/metrics/statementMetrics.ts +259 -0
- package/server/metrics/statementPlanCheck.ts +141 -0
- package/server/metrics/statementReport.ts +105 -0
- package/server/migration/migrationRunner.ts +13 -10
- package/server/oauth/OAuthErrors.ts +5 -1
- package/server/ops/statusAccess.ts +23 -3
- package/server/otlp/otlpBatcher.ts +221 -0
- package/server/otlp/otlpConfig.ts +185 -0
- package/server/otlp/otlpEncode.ts +114 -0
- package/server/otlp/otlpExporter.ts +98 -0
- package/server/otlp/otlpSampler.ts +50 -0
- package/server/pageFailure.ts +33 -0
- package/server/processMetricsCollector.ts +1 -0
- package/server/renderBusyResponse.ts +97 -0
- package/server/reportText.ts +27 -0
- package/server/resolver/databaseModelInstance.ts +21 -19
- package/server/resolver/httpEndpointHandler.ts +43 -0
- package/server/resolver/jobTrace.ts +18 -0
- package/server/resolver/modelFacade.ts +24 -18
- package/server/resolver/modelLoaders.ts +10 -3
- package/server/resolver/signal.resolver.ts +28 -31
- package/server/resolver/timedQuery.ts +8 -4
- package/server/routeCacheQuery.ts +58 -0
- package/server/routeCacheTally.ts +65 -0
- package/server/routeElementComposer.tsx +16 -0
- package/server/routeTreeBuilder.ts +6 -0
- package/server/routing/apiRouter.ts +34 -11
- package/server/routing/appWsData.ts +4 -0
- package/server/routing/builtinRoutes.ts +4 -1
- package/server/routing/devRoutes.ts +50 -0
- package/server/routing/devSurfacePolicy.ts +40 -0
- package/server/routing/devSurfaces.ts +101 -0
- package/server/routing/hostAllowlist.ts +2 -0
- package/server/routing/roomReplay.ts +4 -0
- package/server/routing/serverListener.ts +13 -0
- package/server/routing/soloAppRoutes.ts +14 -1
- package/server/rscClient.tsx +6 -1
- package/server/rscClientChunks.ts +8 -1
- package/server/rscClientErrorSender.ts +77 -0
- package/server/rscClientErrors.ts +26 -0
- package/server/rscFirstRenderMemory.ts +49 -0
- package/server/rscFlightRenderer.ts +21 -4
- package/server/rscFlightStream.ts +2 -2
- package/server/rscHostRenderStream.ts +5 -3
- package/server/rscHostRequests.ts +17 -3
- package/server/rscRenderAdmission.ts +130 -0
- package/server/rscRenderControl.ts +2 -1
- package/server/rscRenderHandler.ts +112 -31
- package/server/rscRenderLevels.ts +40 -0
- package/server/rscRenderRefusal.ts +23 -0
- package/server/rscRenderStats.ts +3 -0
- package/server/rscResultCaches.ts +20 -2
- package/server/rscWorker.tsx +25 -5
- package/server/rscWorkerCache.ts +2 -0
- package/server/rscWorkerHost.ts +35 -4
- package/server/rscWorkerProcess.ts +12 -0
- package/server/rscWorkerRecycler.ts +3 -3
- package/server/scriptPolicy.ts +128 -0
- package/server/serverConfig.ts +11 -0
- package/server/serverMetrics.ts +34 -1
- package/server/sitemap.ts +0 -5
- package/server/ssrFromRscRenderer.tsx +32 -204
- package/server/ssrInlineScripts.ts +195 -0
- package/server/ssrTypes.ts +15 -2
- package/server/systemPageDocument.tsx +6 -2
- package/server/systemPages.tsx +9 -4
- package/server/webCsrSurface.ts +55 -21
- package/server/webDocumentRoute.ts +47 -21
- package/server/webRouteContext.ts +25 -8
- package/server/webRouter.ts +15 -12
- package/server/webRscRoute.ts +18 -14
- package/service/agent.service.ts +34 -8
- package/service/agentLoop/agentLoop.ts +35 -24
- package/service/agentLoop/agentLoopTypes.ts +16 -7
- package/service/agentLoop/loopCompaction.ts +1 -1
- package/service/agentLoop/loopContext.ts +33 -0
- package/service/agentLoop/loopToolkits.ts +17 -8
- package/service/index.ts +0 -1
- package/service/ipcTypes.ts +56 -0
- package/service/mentionToken.ts +44 -0
- package/service/predefinedAdaptor/anthropicLlm.ts +18 -17
- package/service/predefinedAdaptor/database.adaptor.ts +43 -9
- package/service/predefinedAdaptor/directoryNotWritableError.ts +30 -0
- package/service/predefinedAdaptor/index.ts +1 -0
- package/service/predefinedAdaptor/llm.adaptor.ts +9 -3
- package/service/predefinedAdaptor/llmContext.ts +26 -0
- package/service/predefinedAdaptor/llmFence.ts +55 -0
- package/service/predefinedAdaptor/openaiDialect.ts +45 -18
- package/service/predefinedAdaptor/solidSqlite.ts +2 -0
- package/service/predefinedAdaptor/sql/driver/bunSqlite.ts +49 -11
- package/service/predefinedAdaptor/sql/driver/postgres.ts +47 -10
- package/service/predefinedAdaptor/sql/statementFingerprint.ts +117 -0
- package/service/predefinedAdaptor/sql/statementPlans.ts +71 -0
- package/service/predefinedAdaptor/sql/statementProbe.ts +110 -0
- package/service/predefinedAdaptor/sql/statementScrub.ts +149 -0
- package/service/predefinedAdaptor/storage.adaptor.ts +5 -0
- package/service/predefinedAdaptor/websocket.adaptor.ts +6 -0
- package/signal/CrossSiteGuard.ts +5 -0
- package/signal/SignalFailure.ts +24 -2
- package/signal/browserError.ts +24 -0
- package/signal/errorReporting.ts +168 -0
- package/signal/httpPeer.ts +9 -0
- package/signal/index.ts +2 -3
- package/signal/openapi/openapi.ts +4 -0
- package/signal/requestTrace.ts +124 -0
- package/signal/signalContext.ts +15 -22
- package/signal/spanExport.ts +137 -0
- package/signal/trace.ts +168 -37
- package/store/agent/AgentBridge.ts +6 -2
- package/store/agent/AgentContext.ts +81 -14
- package/store/agent/AgentInline.ts +72 -0
- package/store/agent/StoreSurfaceSource.ts +2 -1
- package/store/baseSt.ts +0 -6
- package/store/index.ts +1 -3
- package/store/stateBuilder.ts +1 -6
- package/types/client/appOpenedTab.d.ts +1 -0
- package/types/client/clientRuntime.d.ts +4 -2
- package/types/client/cn.d.ts +0 -4
- package/types/client/cookie.d.ts +4 -3
- package/types/client/csrTypes.d.ts +20 -0
- package/types/client/device.d.ts +8 -0
- package/types/client/frameConfig.d.ts +1 -3
- package/types/client/index.d.ts +7 -7
- package/types/client/keyboardRide.d.ts +16 -0
- package/types/client/rscNavigation.d.ts +0 -10
- package/types/client/scriptPolicy.d.ts +4 -0
- package/types/common/CodeTranscript.d.ts +1 -0
- package/types/common/Logger.d.ts +2 -0
- package/types/common/TraceContext.d.ts +28 -0
- package/types/common/TrustedProxy.d.ts +1 -0
- package/types/common/codeAgentWire.d.ts +10 -2
- package/types/common/index.d.ts +1 -0
- package/types/common/inlineToken.d.ts +5 -0
- package/types/common/logContext.d.ts +1 -0
- package/types/common/sessionTokenContract.d.ts +6 -0
- package/types/constant/index.d.ts +1 -1
- package/types/constant/types.d.ts +0 -2
- package/types/document/documentSchema.d.ts +0 -2
- package/types/document/filterMeta.d.ts +0 -13
- package/types/fetch/client/fetchClient.d.ts +1 -4
- package/types/fetch/client/httpClient.d.ts +2 -5
- package/types/fetch/client/wsClient.d.ts +3 -3
- package/types/fetch/requestStorage.d.ts +9 -0
- package/types/index.d.ts +12 -0
- package/types/server/admissionQueue.d.ts +26 -0
- package/types/server/akanAppHeaders.d.ts +3 -1
- package/types/server/akanOption.d.ts +16 -1
- package/types/server/assetHeaders.d.ts +5 -3
- package/types/server/cachePolicy.d.ts +2 -0
- package/types/server/clientErrorReport.d.ts +27 -0
- package/types/server/clientReportId.d.ts +9 -0
- package/types/server/console.d.ts +0 -7
- package/types/server/devtools/devtoolsAccess.d.ts +12 -0
- package/types/server/devtools/devtoolsRouter.d.ts +0 -1
- package/types/server/devtools/devtoolsUnlockPage.d.ts +11 -0
- package/types/server/devtools/signalSerializer.d.ts +3 -1
- package/types/server/devtools/studio/studioDocument.d.ts +1 -0
- package/types/server/devtools/types.d.ts +5 -0
- package/types/server/forwardedError.d.ts +13 -0
- package/types/server/gateway/gatewayChildren.d.ts +2 -0
- package/types/server/gateway/gatewayConfig.d.ts +1 -0
- package/types/server/gateway/gatewayHttpProxy.d.ts +1 -0
- package/types/server/gateway/gatewayStatus.d.ts +2 -0
- package/types/server/headSplice.d.ts +11 -0
- package/types/server/hmr/clientReport.d.ts +2 -0
- package/types/server/hmr/csrDevShell.d.ts +3 -1
- package/types/server/htmlResultCache.d.ts +13 -3
- package/types/server/index.d.ts +4 -3
- package/types/server/lifecycle/secretEnv.d.ts +23 -0
- package/types/server/logging/logForwarder.d.ts +1 -0
- package/types/server/logging/logStdoutWriter.d.ts +1 -0
- package/types/server/logging/rotatingLogWriter.d.ts +1 -1
- package/types/server/metrics/metricAggregate.d.ts +6 -0
- package/types/server/metrics/metricExposition.d.ts +8 -0
- package/types/server/metrics/metricMerge.d.ts +9 -0
- package/types/server/metrics/metricRegistry.d.ts +76 -0
- package/types/server/metrics/pubsubGauges.d.ts +5 -0
- package/types/server/metrics/requestMetrics.d.ts +22 -0
- package/types/server/metrics/runtimeFamilies.d.ts +9 -0
- package/types/server/metrics/slowStatementLog.d.ts +18 -0
- package/types/server/metrics/statementMetrics.d.ts +45 -0
- package/types/server/metrics/statementPlanCheck.d.ts +16 -0
- package/types/server/metrics/statementReport.d.ts +28 -0
- package/types/server/ops/statusAccess.d.ts +7 -1
- package/types/server/otlp/otlpBatcher.d.ts +18 -0
- package/types/server/otlp/otlpConfig.d.ts +25 -0
- package/types/server/otlp/otlpEncode.d.ts +13 -0
- package/types/server/otlp/otlpExporter.d.ts +18 -0
- package/types/server/otlp/otlpSampler.d.ts +10 -0
- package/types/server/pageFailure.d.ts +14 -0
- package/types/server/renderBusyResponse.d.ts +9 -0
- package/types/server/reportText.d.ts +4 -0
- package/types/server/resolver/httpEndpointHandler.d.ts +14 -0
- package/types/server/resolver/jobTrace.d.ts +5 -0
- package/types/server/resolver/modelLoaders.d.ts +3 -0
- package/types/server/resolver/timedQuery.d.ts +2 -1
- package/types/server/routeCacheQuery.d.ts +11 -0
- package/types/server/routeCacheTally.d.ts +23 -0
- package/types/server/routeElementComposer.d.ts +2 -0
- package/types/server/routing/appWsData.d.ts +3 -0
- package/types/server/routing/devRoutes.d.ts +9 -0
- package/types/server/routing/devSurfacePolicy.d.ts +12 -0
- package/types/server/routing/devSurfaces.d.ts +18 -0
- package/types/server/routing/hostAllowlist.d.ts +1 -0
- package/types/server/routing/roomReplay.d.ts +1 -0
- package/types/server/routing/serverListener.d.ts +2 -0
- package/types/server/routing/soloAppRoutes.d.ts +3 -1
- package/types/server/rscClient.d.ts +1 -0
- package/types/server/rscClientChunks.d.ts +3 -1
- package/types/server/rscClientErrorSender.d.ts +8 -0
- package/types/server/rscClientErrors.d.ts +3 -0
- package/types/server/rscFirstRenderMemory.d.ts +16 -0
- package/types/server/rscFlightStream.d.ts +1 -1
- package/types/server/rscHostRenderStream.d.ts +2 -1
- package/types/server/rscRenderAdmission.d.ts +14 -0
- package/types/server/rscRenderControl.d.ts +2 -1
- package/types/server/rscRenderHandler.d.ts +5 -2
- package/types/server/rscRenderLevels.d.ts +8 -0
- package/types/server/rscRenderRefusal.d.ts +9 -0
- package/types/server/rscRenderStats.d.ts +2 -0
- package/types/server/rscResultCaches.d.ts +8 -1
- package/types/server/rscWorkerCache.d.ts +2 -0
- package/types/server/rscWorkerHost.d.ts +2 -1
- package/types/server/rscWorkerProcess.d.ts +1 -0
- package/types/server/rscWorkerRecycler.d.ts +1 -1
- package/types/server/scriptPolicy.d.ts +31 -0
- package/types/server/serverConfig.d.ts +1 -0
- package/types/server/serverMetrics.d.ts +4 -1
- package/types/server/sitemap.d.ts +0 -2
- package/types/server/ssrFromRscRenderer.d.ts +2 -6
- package/types/server/ssrInlineScripts.d.ts +39 -0
- package/types/server/ssrTypes.d.ts +14 -2
- package/types/server/systemPageDocument.d.ts +3 -1
- package/types/server/systemPages.d.ts +2 -1
- package/types/server/webRouteContext.d.ts +7 -4
- package/types/server/webRouter.d.ts +2 -1
- package/types/service/agent.service.d.ts +3 -0
- package/types/service/agentLoop/agentLoopTypes.d.ts +16 -7
- package/types/service/agentLoop/loopContext.d.ts +13 -0
- package/types/service/agentLoop/loopToolkits.d.ts +1 -0
- package/types/service/index.d.ts +0 -1
- package/types/service/ipcTypes.d.ts +60 -0
- package/types/service/mentionToken.d.ts +13 -0
- package/types/service/predefinedAdaptor/anthropicLlm.d.ts +3 -3
- package/types/service/predefinedAdaptor/database.adaptor.d.ts +2 -0
- package/types/service/predefinedAdaptor/directoryNotWritableError.d.ts +6 -0
- package/types/service/predefinedAdaptor/index.d.ts +1 -0
- package/types/service/predefinedAdaptor/llm.adaptor.d.ts +9 -3
- package/types/service/predefinedAdaptor/llmContext.d.ts +11 -0
- package/types/service/predefinedAdaptor/llmFence.d.ts +15 -0
- package/types/service/predefinedAdaptor/openaiDialect.d.ts +3 -3
- package/types/service/predefinedAdaptor/sql/driver/bunSqlite.d.ts +3 -1
- package/types/service/predefinedAdaptor/sql/driver/postgres.d.ts +3 -1
- package/types/service/predefinedAdaptor/sql/statementFingerprint.d.ts +21 -0
- package/types/service/predefinedAdaptor/sql/statementPlans.d.ts +17 -0
- package/types/service/predefinedAdaptor/sql/statementProbe.d.ts +37 -0
- package/types/service/predefinedAdaptor/sql/statementScrub.d.ts +5 -0
- package/types/service/predefinedAdaptor/storage.adaptor.d.ts +1 -0
- package/types/service/predefinedAdaptor/websocket.adaptor.d.ts +3 -0
- package/types/signal/CrossSiteGuard.d.ts +1 -0
- package/types/signal/SignalFailure.d.ts +2 -0
- package/types/signal/browserError.d.ts +17 -0
- package/types/signal/errorReporting.d.ts +27 -0
- package/types/signal/httpPeer.d.ts +5 -0
- package/types/signal/index.d.ts +3 -1
- package/types/signal/requestTrace.d.ts +33 -0
- package/types/signal/signalContext.d.ts +2 -1
- package/types/signal/spanExport.d.ts +47 -0
- package/types/signal/trace.d.ts +33 -12
- package/types/store/agent/AgentBridge.d.ts +1 -0
- package/types/store/agent/AgentContext.d.ts +6 -2
- package/types/store/agent/AgentInline.d.ts +16 -0
- package/types/store/baseSt.d.ts +0 -2
- package/types/store/index.d.ts +2 -2
- package/types/store/stateBuilder.d.ts +0 -4
- package/types/ui/Link/Action.d.ts +2 -1
- package/types/ui/Reference/origin.d.ts +0 -2
- package/types/ui/System/Common.d.ts +1 -1
- package/types/vendor/@akanjs/native/packages/cli/src/lib/project.d.ts +5 -0
- package/types/vendor/@akanjs/native/packages/core/src/boot.d.ts +5 -0
- package/types/vendor/@akanjs/native/plugins/external-view/src/index.d.ts +20 -8
- package/types/vendor/@akanjs/native/plugins/keyboard/src/index.d.ts +3 -2
- package/types/vendor/use-agentic/ToolRunner.d.ts +2 -1
- package/types/vendor/use-agentic/types.d.ts +8 -0
- package/types/webkit/CsrStack.d.ts +2 -1
- package/types/webkit/csrPageReadiness.d.ts +18 -0
- package/types/webkit/csrSlide.d.ts +30 -0
- package/types/webkit/index.d.ts +1 -1
- package/types/webkit/nativeNavigation.d.ts +2 -2
- package/types/webkit/nativeSplash.d.ts +6 -0
- package/types/webkit/openSurfaces.d.ts +13 -0
- package/types/webkit/useCsrKeyboard.d.ts +2 -1
- package/types/webkit/useCsrNavigation.d.ts +1 -1
- package/types/webkit/useEscapeKey.d.ts +7 -2
- package/types/webkit/useFrameRuntime.d.ts +6 -2
- package/types/webkit/usePageLocation.d.ts +3 -1
- package/types/webkit/useVisualViewportFrame.d.ts +2 -0
- package/ui/Dialog/Modal.tsx +16 -2
- package/ui/KeyboardAvoiding.tsx +2 -1
- package/ui/Layout/FrameSlotPortal.tsx +10 -3
- package/ui/Link/Action.tsx +2 -1
- package/ui/Reference/origin.ts +0 -10
- package/ui/System/CSR.tsx +33 -13
- package/ui/System/Common.tsx +8 -2
- package/ui/System/SSR.tsx +7 -4
- package/ui/Tooltip.tsx +1 -1
- package/ui/styles.css +14 -0
- package/vendor/@akanjs/native/CHANGELOG.md +20 -52
- package/vendor/@akanjs/native/native/android/src/com/akanjs/runtime/AkanNativeActivity.kt +27 -14
- package/vendor/@akanjs/native/native/desktop/Cargo.lock +1 -0
- package/vendor/@akanjs/native/native/desktop/Cargo.toml +2 -0
- package/vendor/@akanjs/native/native/desktop/src/acl.rs +27 -7
- package/vendor/@akanjs/native/native/desktop/src/external.rs +240 -29
- package/vendor/@akanjs/native/native/desktop/src/lib.rs +3 -3
- package/vendor/@akanjs/native/native/desktop/src/navigation.rs +4 -0
- package/vendor/@akanjs/native/native/ios/Sources/AkanNativeViewController.swift +21 -2
- package/vendor/@akanjs/native/packages/cli/src/lib/acl.ts +10 -2
- package/vendor/@akanjs/native/packages/cli/src/lib/project.ts +11 -1
- package/vendor/@akanjs/native/packages/core/src/boot.ts +6 -0
- package/vendor/@akanjs/native/plugins/external-view/native-plugin.json +26 -0
- package/vendor/@akanjs/native/plugins/external-view/src/desktop.ts +9 -1
- package/vendor/@akanjs/native/plugins/external-view/src/index.ts +20 -8
- package/vendor/@akanjs/native/plugins/keyboard/src/index.ts +3 -2
- package/vendor/use-agentic/AgentSession.ts +1 -1
- package/vendor/use-agentic/CHANGELOG.md +9 -59
- package/vendor/use-agentic/Compaction.ts +1 -1
- package/vendor/use-agentic/ToolRunner.ts +12 -0
- package/vendor/use-agentic/WIRE.md +8 -2
- package/vendor/use-agentic/types.ts +8 -0
- package/webkit/CsrStack.ts +17 -9
- package/webkit/McpAppAgent.ts +3 -1
- package/webkit/RenderLayer.tsx +22 -13
- package/webkit/bootCsr.tsx +19 -1
- package/webkit/csrPageReadiness.ts +43 -0
- package/webkit/csrSlide.ts +130 -0
- package/webkit/index.ts +1 -1
- package/webkit/nativeNavigation.ts +12 -3
- package/webkit/nativeSplash.ts +30 -0
- package/webkit/openSurfaces.ts +54 -0
- package/webkit/useCsrKeyboard.ts +33 -1
- package/webkit/useCsrNavigation.ts +69 -21
- package/webkit/useCsrTransitions.ts +130 -29
- package/webkit/useCsrValues.ts +17 -5
- package/webkit/useEscapeKey.tsx +10 -23
- package/webkit/useFrameRuntime.ts +55 -6
- package/webkit/usePageLocation.ts +8 -2
- package/webkit/useVisualViewportFrame.tsx +24 -0
- package/client/locale.ts +0 -5
- package/service/serviceRegistry.ts +0 -27
- package/types/client/locale.d.ts +0 -6
- package/types/service/serviceRegistry.d.ts +0 -10
package/README.md
CHANGED
|
@@ -6,11 +6,9 @@
|
|
|
6
6
|
|
|
7
7
|
**The TypeScript framework, agents included.** Powered by Bun.
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
one AI can use, on the model you choose. One line of business code runs through every layer, ships to six platforms,
|
|
13
|
-
and reaches everyone who uses it — people and agents.
|
|
9
|
+
Akan.js is a full-stack TypeScript framework. One field declaration runs through the schema, service, API, client
|
|
10
|
+
state and UI, and the same code ships as a web app, iOS and Android apps, and desktop apps. Every guarded endpoint is
|
|
11
|
+
also an MCP tool and every control on screen an in-page agent tool, behind the guards people pass.
|
|
14
12
|
|
|
15
13
|
## Quick Start
|
|
16
14
|
|
|
@@ -61,307 +59,53 @@ Node and npm, or URLs given by a spec, a coding agent needs these, and nothing h
|
|
|
61
59
|
- **Exact URLs:** pages live under `/<locale>/…`. To serve the default locale at the bare path (`/books/OL45804W`),
|
|
62
60
|
set `i18n: { defaultLocale: "en", locales: ["en"], localePrefix: "as-needed" }` in `akan.config.ts`; `<Link>`
|
|
63
61
|
follows.
|
|
64
|
-
- **A host with only Node and npm:**
|
|
65
|
-
`
|
|
66
|
-
`
|
|
67
|
-
|
|
68
|
-
- **Build and run without Docker** through these package scripts; `npm run build`, then `PORT=3000 npm start`:
|
|
69
|
-
|
|
70
|
-
```json
|
|
71
|
-
"build": "akan build <app>",
|
|
72
|
-
"start": "cd dist/apps/<app> && bun main.js"
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
A fresh clone builds as is: the env files stay gitignored and `akan` writes the ones it lacks, so commit none. The
|
|
76
|
-
build carries the env it needs, and a variable set at start overrides it.
|
|
62
|
+
- **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.
|
|
77
66
|
- **Build for where it runs.** A variable set in the shell, or in a `.env.local` Bun loads, outranks the workspace `.env`
|
|
78
67
|
(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
|
|
79
68
|
server runs without endpoint rate limits and on local defaults. For a host others can reach, run
|
|
80
69
|
`akan build <app> --env main` with `AKAN_PUBLIC_REPO_NAME` and `AKAN_PUBLIC_SERVE_DOMAIN` (the domain it serves) set
|
|
81
70
|
in the shell or the workspace `.env`.
|
|
82
71
|
|
|
83
|
-
##
|
|
84
|
-
|
|
85
|
-
```ts
|
|
86
|
-
export class ProductInput extends via((field) => ({
|
|
87
|
-
name: field(String),
|
|
88
|
-
})) {}
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
**1 line × 8 layers × 6 platforms × people & agents.**
|
|
92
|
-
|
|
93
|
-
- **1 line.** Adding a field is one declaration: a name and a type.
|
|
94
|
-
- **× 8 layers.** That line runs through the schema, query, service, API, fetch, client type, state and UI prop. In a
|
|
95
|
-
usual stack those are eight places to change by hand, and missing one breaks a type or fails at runtime. Here they
|
|
96
|
-
change together.
|
|
97
|
-
- **× 6 platforms.** The same code ships as SEO-ready web, iOS and Android apps, and macOS, Windows and Linux desktop
|
|
98
|
-
apps, with native-level screen transitions rather than a wrapped website.
|
|
99
|
-
- **× people & agents.** Every guarded endpoint becomes an MCP tool and every control on screen an in-page agent
|
|
100
|
-
tool, behind the same guards people pass.
|
|
101
|
-
|
|
102
|
-
## The Screen You Build Is The Agent's Interface
|
|
103
|
-
|
|
104
|
-
```tsx
|
|
105
|
-
export const Order = () => {
|
|
106
|
-
const { l } = usePage();
|
|
107
|
-
const icecreamOrderForm = st.use.icecreamOrderForm();
|
|
108
|
-
const order = st.tool("createIcecreamOrder", { confirm: true })
|
|
109
|
-
.desc("Place the order in the form.")
|
|
110
|
-
.exec(() => st.do.createIcecreamOrder());
|
|
111
|
-
return (
|
|
112
|
-
<>
|
|
113
|
-
<Field.MultiToggleSelect
|
|
114
|
-
label={l("icecreamOrder.toppings")}
|
|
115
|
-
items={cnst.Topping}
|
|
116
|
-
value={icecreamOrderForm.toppings}
|
|
117
|
-
onChange={st.do.setToppingsOnIcecreamOrder}
|
|
118
|
-
/>
|
|
119
|
-
<Button onClick={order}>{l("icecreamOrder.createIcecreamOrder")}</Button>
|
|
120
|
-
</>
|
|
121
|
-
);
|
|
122
|
-
};
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
- **Write the screen you were going to write.** A field handed its setter publishes it. A button's handler becomes a
|
|
126
|
-
tool with one `st.tool` line — the same function the button calls.
|
|
127
|
-
- **An agent sees tools, not pixels.** Every control you wired is published under its own name, with the arguments it
|
|
128
|
-
takes. What isn't on the screen isn't on the list.
|
|
129
|
-
- **It works the screen in the user's own tab**, with their session, exactly like a click.
|
|
130
|
-
- **What matters waits for a yes.** A tool declared with `confirm` stops on an approval card.
|
|
131
|
-
|
|
132
|
-
Setup is one `<Agent.Chat />` in a layout and your model's key in `option.ts`. OpenAI-compatible hosts and Anthropic
|
|
133
|
-
both work.
|
|
134
|
-
|
|
135
|
-
## Your Server Is Already An MCP Server
|
|
136
|
-
|
|
137
|
-
```ts
|
|
138
|
-
serveIcecreamOrder: mutation(cnst.IcecreamOrder, {
|
|
139
|
-
guards: [Admin],
|
|
140
|
-
})
|
|
141
|
-
.param("icecreamOrderId", ID)
|
|
142
|
-
.exec(async function (icecreamOrderId) {
|
|
143
|
-
return await this.icecreamOrderService.serve(icecreamOrderId);
|
|
144
|
-
}),
|
|
145
|
-
refundIcecreamOrder: mutation(cnst.IcecreamOrder, {
|
|
146
|
-
guards: [Every, Person],
|
|
147
|
-
})
|
|
148
|
-
.param("icecreamOrderId", ID)
|
|
149
|
-
.with(Self)
|
|
150
|
-
.exec(async function (icecreamOrderId, self) {
|
|
151
|
-
return await this.icecreamOrderService.refund(icecreamOrderId, self.id);
|
|
152
|
-
}),
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
- **Point any MCP client at your app.** `POST /mcp` is on by default. Every endpoint whose guards admit the caller is
|
|
156
|
-
a tool, described by the dictionary you already write.
|
|
157
|
-
- **Sign-in and consent happen on your app.** OAuth 2.1 ships with `libs/shared`. The AI gets a token for one user —
|
|
158
|
-
exactly their rights, revocable at any time.
|
|
159
|
-
- **It can't do what it shouldn't.** `refundIcecreamOrder` is guarded by `Person`, so it never reaches the shelf. To
|
|
160
|
-
the AI it looks exactly like a tool that doesn't exist.
|
|
161
|
-
- **Pages become prompts.** `page().prompt(name, description)` publishes a screen as an MCP prompt: its fetches run
|
|
162
|
-
under the caller's token and the agent receives the data, with no second implementation to keep in sync.
|
|
163
|
-
|
|
164
|
-
## One Rule, Three Kinds Of Users
|
|
165
|
-
|
|
166
|
-
You write a guard once per endpoint. It decides for a person on the screen, for the agent in their tab, and for an AI
|
|
167
|
-
calling over MCP.
|
|
168
|
-
|
|
169
|
-
- **Refusals give nothing away.** A tool an agent may not use answers exactly like one that doesn't exist.
|
|
170
|
-
- **Rate-limited per caller.** MCP calls are capped at 120 a minute and 8 at once for each caller.
|
|
171
|
-
- **Secrets stay home.** Hidden and secret fields are stripped before anything reaches a model.
|
|
172
|
-
- **Connections end when you say.** Revoke a connection and its next call is refused. The chat relay keeps no
|
|
173
|
-
session and no transcript.
|
|
174
|
-
|
|
175
|
-
## Agents Build It, Too
|
|
176
|
-
|
|
177
|
-
AI coding turns to spaghetti past a certain size: the faster an agent writes, the more file paths, names, structures
|
|
178
|
-
and declaration styles drift apart. Akan stops this at the source with strict rules.
|
|
179
|
-
|
|
180
|
-
- **Config hell ends.** Everything is configured in `akan.config.ts`, and an empty one still runs.
|
|
181
|
-
- **Strict rules, unified style.** File paths, names, structures and declarations stay consistent, and lint enforces
|
|
182
|
-
them, so code reads like one person wrote it.
|
|
183
|
-
- **Rules agents can't route around.** Every workspace ships a generated `AGENTS.md`, bundled guidelines, a
|
|
184
|
-
plan-then-apply workflow MCP, and `akan code`, a terminal coding agent that works through them.
|
|
185
|
-
- **Fixed blocks.** Upload, login, admin, chat, boards and alerts are ready-made blocks, so agents produce
|
|
186
|
-
consistent code on top of them.
|
|
187
|
-
|
|
188
|
-
## The Domain Module
|
|
189
|
-
|
|
190
|
-
Code is organized around business domains such as `user`, `product`, `ticket` or `project`, not by technical layer
|
|
191
|
-
first.
|
|
192
|
-
|
|
193
|
-
```text
|
|
194
|
-
lib/product/
|
|
195
|
-
├── product.constant.ts # model, scalar, enum, schema definition
|
|
196
|
-
├── product.dictionary.ts # i18n labels, descriptions, errors
|
|
197
|
-
├── product.signal.ts # typed endpoint contract, guards
|
|
198
|
-
├── product.document.ts # persistence and document queries
|
|
199
|
-
├── product.service.ts # business logic
|
|
200
|
-
├── product.store.ts # domain state and actions
|
|
201
|
-
├── Product.Template.tsx # form UI
|
|
202
|
-
├── Product.Unit.tsx # list item UI
|
|
203
|
-
├── Product.View.tsx # detail UI
|
|
204
|
-
└── Product.Zone.tsx # page section UI
|
|
205
|
-
```
|
|
206
|
-
|
|
207
|
-
```mermaid
|
|
208
|
-
flowchart LR
|
|
209
|
-
ConstantDictionarySignal["constant + dictionary + signal"] --> DocumentService["document + service"]
|
|
210
|
-
ConstantDictionarySignal --> StoreComponents["store + UI components"]
|
|
211
|
-
DocumentService --> ServerRuntime["server runtime + MCP"]
|
|
212
|
-
StoreComponents --> ClientRuntime["client runtime + in-page agent"]
|
|
213
|
-
ServerRuntime --> DeployArtifacts["deploy artifacts"]
|
|
214
|
-
ClientRuntime --> DeployArtifacts
|
|
215
|
-
```
|
|
216
|
-
|
|
217
|
-
## Faster Than v2
|
|
218
|
-
|
|
219
|
-
v3 adds agents, MCP and a new UI system, and it is still faster than v2 on every number we measured.
|
|
220
|
-
|
|
221
|
-
| Metric | v2 | v3 | Change |
|
|
222
|
-
| --- | --- | --- | --- |
|
|
223
|
-
| Requests per second | 112K | 123K | +10% |
|
|
224
|
-
| Response time (p99) | 1.30 ms | 1.04 ms | −20% |
|
|
225
|
-
| Startup time | 204 ms | 102 ms | −50% |
|
|
226
|
-
| Memory at rest | 84 MB | 57 MB | −32% |
|
|
227
|
-
| Memory under load | 105 MB | 85 MB | −19% |
|
|
72
|
+
## Your First App
|
|
228
73
|
|
|
229
|
-
-
|
|
230
|
-
|
|
231
|
-
- A
|
|
74
|
+
- **A screen** is a file under `apps/<app>/page/`: `<route>.tsx` or `_index.tsx`, `_layout.tsx` around it, `[id]/`
|
|
75
|
+
for a segment. It exports one `page()` chain from `akanjs/client`. [Routing](https://akanjs.com/docs/core/routing)
|
|
76
|
+
- **A stored model** is a module under `lib/<model>/`, made by `akan create-module <model> <app>`. A service with no
|
|
77
|
+
stored model, such as an outside API, goes under `lib/_<service>/` with `akan create-service <service> <app>`.
|
|
78
|
+
[File rules](https://akanjs.com/docs/core/file-rule)
|
|
79
|
+
- **The rules** a coding agent follows are in the workspace: `AGENTS.md`, `.claude/rules/akan/`, and the skills in
|
|
80
|
+
`.claude/skills/` and `.agents/skills/`. `akan guideline show <name>` prints any bundled guideline.
|
|
81
|
+
- **`akan.config.ts`** may stay empty. It grows only for routes, domains, locales, database modes or native apps.
|
|
82
|
+
[Configuration](https://akanjs.com/docs/core/config)
|
|
232
83
|
|
|
233
|
-
|
|
234
|
-
in [`benchmarks/api-benchmark`](https://github.com/akan-team/akanjs/tree/main/benchmarks/api-benchmark).
|
|
235
|
-
|
|
236
|
-
## From Build To A Live URL
|
|
237
|
-
|
|
238
|
-
[Akan Cloud](https://cloud.akanjs.com) is the deploy platform built for Akan apps.
|
|
239
|
-
|
|
240
|
-
```bash
|
|
241
|
-
akan login # sign in to Akan Cloud from your machine
|
|
242
|
-
akan tunnel <app> # share the app you are running on a public URL
|
|
243
|
-
akan build <app> # build the production artifact Akan Cloud runs
|
|
244
|
-
```
|
|
245
|
-
|
|
246
|
-
## Docs For You And Your Agent
|
|
247
|
-
|
|
248
|
-
- Read the docs at [akanjs.com/docs](https://akanjs.com/docs). Every docs page carries the in-page agent, so you can
|
|
249
|
-
ask it about a topic and it opens the page.
|
|
250
|
-
- Connect Claude Code or Cursor to `https://akanjs.com/mcp`, and your AI reads the docs (`listDocPages`,
|
|
251
|
-
`searchDocPages`, `readDocPage`) while it writes your code.
|
|
252
|
-
- [`llms.txt`](https://akanjs.com/llms.txt) indexes the docs for any model.
|
|
253
|
-
|
|
254
|
-
## One Package, Many Boundaries
|
|
255
|
-
|
|
256
|
-
Akan is published as a single npm package, `akanjs`. The root import is intentionally small; subpath imports keep
|
|
257
|
-
server-only, client-only, UI and tooling surfaces apart.
|
|
258
|
-
|
|
259
|
-
```ts
|
|
260
|
-
import { Int, dayjs } from "akanjs/base";
|
|
261
|
-
import { via } from "akanjs/constant";
|
|
262
|
-
import { endpoint } from "akanjs/signal";
|
|
263
|
-
import { Button, Layout } from "akanjs/ui";
|
|
264
|
-
import { page } from "akanjs/client";
|
|
265
|
-
import { AkanApp } from "akanjs/server/akanApp";
|
|
266
|
-
```
|
|
267
|
-
|
|
268
|
-
```css
|
|
269
|
-
@import "akanjs/ui/styles.css";
|
|
270
|
-
```
|
|
271
|
-
|
|
272
|
-
| Subpath | Purpose |
|
|
273
|
-
| --- | --- |
|
|
274
|
-
| `akanjs/base` | Core primitives, scalars (`Int`, `Float`, `ID`, `Binary`, `enumOf`), `dayjs`, environment helpers. |
|
|
275
|
-
| `akanjs/common` | Shared cross-runtime helpers. |
|
|
276
|
-
| `akanjs/constant` | Model declarations, schema shaping, serialization, defaults, and the `via` builder. |
|
|
277
|
-
| `akanjs/dictionary` | Locale, translation, and dictionary helpers for labels, descriptions and errors. |
|
|
278
|
-
| `akanjs/document` | Database documents, filters, query builders, full-text search, and persistence utilities. |
|
|
279
|
-
| `akanjs/signal` | Endpoints, slices, guards, middleware, and typed signal contracts. |
|
|
280
|
-
| `akanjs/service` | Services, adaptors, dependency injection, and the business logic runtime. |
|
|
281
|
-
| `akanjs/fetch` | Typed fetch, HTTP and WebSocket clients. |
|
|
282
|
-
| `akanjs/store` | Domain state, actions, and the in-page agent's `st.tool` / `st.use` surface. |
|
|
283
|
-
| `akanjs/ui` | React components, recipes, and `_overrides.tsx` slots: layout, form, modal, table, loading, agent chat. |
|
|
284
|
-
| `akanjs/client` | The route chain (`page()`, `layout()`), routing, cookies, storage, locale, and `cn`. |
|
|
285
|
-
| `akanjs/client/native` | The native bridge and builtin plugins for iOS, Android and desktop apps. |
|
|
286
|
-
| `akanjs/webkit` | Browser-side helpers such as `lazy` and SEO pages. |
|
|
287
|
-
| `akanjs/server` | Server runtime, SSR/RSC, MCP, logging, and server types. `akanjs/server/akanApp` is the entrypoint. |
|
|
288
|
-
| `akanjs/native/desktop` | Desktop parts of native plugins. |
|
|
289
|
-
| `akanjs/test` | Test helpers and sample generation. |
|
|
290
|
-
|
|
291
|
-
Tooling ships as separate packages: `@akanjs/cli` (the `akan` command), `@akanjs/devkit` (build runners, code
|
|
292
|
-
generation, lint rules) and `create-akan-workspace`.
|
|
293
|
-
|
|
294
|
-
## CLI Overview
|
|
84
|
+
## Build And Run
|
|
295
85
|
|
|
296
86
|
```bash
|
|
297
|
-
akan
|
|
298
|
-
akan
|
|
299
|
-
akan
|
|
300
|
-
|
|
301
|
-
akan build <app>
|
|
302
|
-
akan build-ios <app> # also build-android, build-desktop
|
|
303
|
-
akan lint <app>
|
|
304
|
-
akan typecheck <app>
|
|
305
|
-
akan test <app>
|
|
306
|
-
akan logs <app>
|
|
307
|
-
akan code
|
|
308
|
-
akan update
|
|
87
|
+
akan start <app> # dev server, http://localhost:8282
|
|
88
|
+
akan verify <app> # sync, lint, typecheck, build and SSR check
|
|
89
|
+
akan build <app> # production build in dist/apps/<app>
|
|
90
|
+
cd dist/apps/<app> && PORT=3000 bun main.js
|
|
309
91
|
```
|
|
310
92
|
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
],
|
|
331
|
-
database: { modes: ["single", "cluster"] },
|
|
332
|
-
native: {
|
|
333
|
-
basePath: "app",
|
|
334
|
-
appName: "Example",
|
|
335
|
-
appId: "com.example.app",
|
|
336
|
-
version: "1.0.0",
|
|
337
|
-
buildNum: 1,
|
|
338
|
-
},
|
|
339
|
-
};
|
|
340
|
-
|
|
341
|
-
export default config;
|
|
342
|
-
```
|
|
343
|
-
|
|
344
|
-
## Contributor Notes
|
|
345
|
-
|
|
346
|
-
This repository is a Bun-first monorepo. Framework code lives under `pkgs/akanjs`, tooling under `pkgs/@akanjs`,
|
|
347
|
-
applications under `apps`, shared libraries under `libs`, and deployment assets under `infra`. `apps/akan` is
|
|
348
|
-
[akanjs.com](https://akanjs.com) itself.
|
|
349
|
-
|
|
350
|
-
Inside this repository, `bun run akan` builds the CLI from source and runs it:
|
|
351
|
-
|
|
352
|
-
```bash
|
|
353
|
-
bun run akan start <app>
|
|
354
|
-
bun run akan lint <app>
|
|
355
|
-
bun run akan typecheck <app>
|
|
356
|
-
bun run akan test <app-or-lib-or-pkg>
|
|
357
|
-
```
|
|
358
|
-
|
|
359
|
-
`AGENTS.md` is the guide for coding agents and contributors alike. When editing framework code, prefer established
|
|
360
|
-
subpaths and keep the root `akanjs` entrypoint small. The package boundary is part of the runtime design.
|
|
361
|
-
|
|
362
|
-
## Open Source Notes
|
|
363
|
-
|
|
364
|
-
- License: MIT. See [`pkgs/akanjs/LICENSE`](https://github.com/akan-team/akanjs/blob/main/pkgs/akanjs/LICENSE).
|
|
365
|
-
- Repository: [akan-team/akanjs](https://github.com/akan-team/akanjs).
|
|
366
|
-
- Contribution guide: [`pkgs/akanjs/CONTRIBUTING.md`](https://github.com/akan-team/akanjs/blob/main/pkgs/akanjs/CONTRIBUTING.md).
|
|
367
|
-
- Code of conduct: [`pkgs/akanjs/CODE_OF_CONDUCT.md`](https://github.com/akan-team/akanjs/blob/main/pkgs/akanjs/CODE_OF_CONDUCT.md).
|
|
93
|
+
[Akan Cloud](https://cloud.akanjs.com) runs Akan apps: `akan login` signs in, and `akan tunnel <app>` shares the app
|
|
94
|
+
you are running on a public URL.
|
|
95
|
+
|
|
96
|
+
## Learn More
|
|
97
|
+
|
|
98
|
+
- [akanjs.com](https://akanjs.com): what one line of code reaches, the screen as an agent's interface, and your server
|
|
99
|
+
as an MCP server.
|
|
100
|
+
- [Docs](https://akanjs.com/docs), the [CLI reference](https://akanjs.com/references/cli/overview), and
|
|
101
|
+
[`llms.txt`](https://akanjs.com/llms.txt). Connect a coding agent to `https://akanjs.com/mcp` to read the docs while
|
|
102
|
+
it writes code.
|
|
103
|
+
- [MCP](https://akanjs.com/cheatsheet/interface/mcp) and the [in-page agent](https://akanjs.com/cheatsheet/interface/agent-chat):
|
|
104
|
+
guards, refusals, rate limits and model setup.
|
|
105
|
+
- [v3 performance](https://akanjs.com/blog/v3release#v3-performance): the numbers against v2 and how they were measured.
|
|
106
|
+
- `akanjs` is one npm package. Its subpaths (`akanjs/base`, `akanjs/client`, `akanjs/signal`, `akanjs/ui`, …) keep
|
|
107
|
+
server-only, client-only, UI and tooling code apart, and the [package reference](https://akanjs.com/references/akanjs/base)
|
|
108
|
+
covers them; the tooling ships as `@akanjs/cli` and `@akanjs/devkit`.
|
|
109
|
+
- Contributing: [`CONTRIBUTING.md`](https://github.com/akan-team/akanjs/blob/main/pkgs/akanjs/CONTRIBUTING.md) and
|
|
110
|
+
the [code of conduct](https://github.com/akan-team/akanjs/blob/main/pkgs/akanjs/CODE_OF_CONDUCT.md). License: MIT
|
|
111
|
+
([`LICENSE`](https://github.com/akan-team/akanjs/blob/main/pkgs/akanjs/LICENSE)).
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Href } from "./href";
|
|
2
|
+
import { isNativeShell } from "./nativeHost";
|
|
3
|
+
|
|
4
|
+
export const closeAppOpenedTab = (): boolean => {
|
|
5
|
+
const win = globalThis.window;
|
|
6
|
+
if (!win || isNativeShell() || win.history?.length !== 1 || typeof win.close !== "function") return false;
|
|
7
|
+
|
|
8
|
+
const referrer = globalThis.document?.referrer ?? "";
|
|
9
|
+
if (!win.opener && (!referrer || Href.leavesOrigin(referrer, win.location.href))) return false;
|
|
10
|
+
win.close();
|
|
11
|
+
return win.closed === true;
|
|
12
|
+
};
|
package/client/clientRuntime.ts
CHANGED
|
@@ -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
|
};
|
|
@@ -80,13 +82,6 @@ globalWithRuntime[CLIENT_RUNTIME_KEY] = state;
|
|
|
80
82
|
const missingRuntimeError = () =>
|
|
81
83
|
new Error("Akan client runtime is not registered. Import the generated app client first.");
|
|
82
84
|
|
|
83
|
-
const applyRuntimeErrorConstructor = (runtime: ClientRuntime) => {
|
|
84
|
-
const instance = (runtime.fetch as RuntimeFetch | undefined)?.instance as
|
|
85
|
-
| { setErrorConstructor?: (Err: unknown) => void }
|
|
86
|
-
| undefined;
|
|
87
|
-
if (typeof instance?.setErrorConstructor === "function") instance.setErrorConstructor(runtime.Err);
|
|
88
|
-
};
|
|
89
|
-
|
|
90
85
|
export const registerClientRuntime = <Runtime>(
|
|
91
86
|
runtime: Runtime,
|
|
92
87
|
{ scope = "app" }: { scope?: RuntimeScope } = {},
|
|
@@ -94,12 +89,10 @@ export const registerClientRuntime = <Runtime>(
|
|
|
94
89
|
if (state.scope === "app" && scope === "lib") return runtime;
|
|
95
90
|
state.runtime = runtime as ClientRuntime;
|
|
96
91
|
state.scope = scope;
|
|
97
|
-
applyRuntimeErrorConstructor(state.runtime);
|
|
98
92
|
return runtime;
|
|
99
93
|
};
|
|
100
94
|
|
|
101
|
-
|
|
102
|
-
export const getClientRuntime = () => {
|
|
95
|
+
const getClientRuntime = () => {
|
|
103
96
|
if (!state.runtime) throw missingRuntimeError();
|
|
104
97
|
return state.runtime;
|
|
105
98
|
};
|
package/client/cn.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type ClassNameValue, extendTailwindMerge } from "tailwind-merge";
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
|
|
3
|
+
/** Registered with tailwind-merge so `cn("bg-primary", "bg-open")` resolves to `"bg-open"` instead of keeping both. */
|
|
4
|
+
const colorTokens = [
|
|
5
5
|
"background",
|
|
6
6
|
"foreground",
|
|
7
7
|
"primary",
|
|
@@ -33,8 +33,8 @@ export const colorTokens = [
|
|
|
33
33
|
"ring",
|
|
34
34
|
];
|
|
35
35
|
|
|
36
|
-
/**
|
|
37
|
-
|
|
36
|
+
/** `--radius-box` / `--radius-field`; unregistered, `cn("rounded-field", "rounded-full")` would keep both. */
|
|
37
|
+
const radiusTokens = ["box", "field"];
|
|
38
38
|
|
|
39
39
|
const twMerge = extendTailwindMerge({
|
|
40
40
|
extend: {
|
package/client/cookie.ts
CHANGED
|
@@ -153,25 +153,34 @@ export interface GetOption {
|
|
|
153
153
|
unauthorize: string;
|
|
154
154
|
}
|
|
155
155
|
interface SetAuthOption {
|
|
156
|
-
jwt
|
|
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
|
-
|
|
164
|
-
|
|
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(),
|
|
174
|
+
if (isCsrClient()) void secretStorage.setItem(storedAuthTokenKey(), token);
|
|
167
175
|
else {
|
|
168
176
|
|
|
169
177
|
void secretStorage.removeItem(storedAuthTokenKey());
|
|
170
|
-
if (!serverHoldsSession()) setCookie(authTokenKey(),
|
|
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
|
|
package/client/csrTypes.ts
CHANGED
|
@@ -19,6 +19,8 @@ export type PageSafeAreaConfig =
|
|
|
19
19
|
bottom?: boolean;
|
|
20
20
|
android?: "auto" | "edge-to-edge" | "none";
|
|
21
21
|
};
|
|
22
|
+
/** The sides whose chrome the page runs under instead of below. */
|
|
23
|
+
export type PageOverlayConfig = boolean | "top" | "bottom";
|
|
22
24
|
/** `"stream"` flushes the shell (`Loading` included) then streams; a redirect in suspended content becomes a client one.
|
|
23
25
|
* `"block"` buffers the whole document, so an error in slow content can still render a clean error page. */
|
|
24
26
|
export type SsrRenderMode = "stream" | "block";
|
|
@@ -34,6 +36,12 @@ export interface PageConfig {
|
|
|
34
36
|
topInset?: number | boolean | ResponsiveInset;
|
|
35
37
|
/** Bottom chrome reservation in px, or px per breakpoint. Use true for the default 48px reservation. */
|
|
36
38
|
bottomInset?: number | boolean | ResponsiveInset;
|
|
39
|
+
/**
|
|
40
|
+
* Lays the page under its top or bottom chrome (safe area and inset) instead of below it, so a translucent bar has
|
|
41
|
+
* content scrolling beneath it. The page pads its own scrollers by `--akan-overlay-top` / `--akan-overlay-bottom`,
|
|
42
|
+
* and an overlaid side's safe area defaults to transparent.
|
|
43
|
+
*/
|
|
44
|
+
overlay?: PageOverlayConfig;
|
|
37
45
|
gesture?: boolean;
|
|
38
46
|
cache?: boolean;
|
|
39
47
|
/** Initial full-document SSR strategy. Defaults to `"stream"`. */
|
|
@@ -47,6 +55,10 @@ export interface PageConfig {
|
|
|
47
55
|
/** `false` answers a `Link` prefetch of the page (on a layout, of every page under it) without rendering it, for a
|
|
48
56
|
* render with a side effect such as counting a view; the click renders it as usual. */
|
|
49
57
|
prefetch?: boolean;
|
|
58
|
+
/** `false` keys the page in the RSC and HTML result caches on its query exactly as requested (on a layout, every
|
|
59
|
+
* page under it), for a page whose output follows parameter order or a tracking parameter it reads without declaring
|
|
60
|
+
* it with `.search()`. By default the key sorts the query and leaves out `AKAN_ROUTE_CACHE_TRACKING_PARAMS`. */
|
|
61
|
+
canonicalQuery?: boolean;
|
|
50
62
|
topSafeAreaColor?: string;
|
|
51
63
|
bottomSafeAreaColor?: string;
|
|
52
64
|
/** Keeps the route (on a `_layout`, its whole directory) out of `akan build` while `akan start` serves it. Write a
|
|
@@ -64,6 +76,7 @@ export interface CsrState {
|
|
|
64
76
|
responsiveInset?: { top: ResponsiveInset; bottom: ResponsiveInset };
|
|
65
77
|
/** Web only: the sides whose safe area `env(safe-area-inset-*)` measures, since a browser tells script nothing. */
|
|
66
78
|
safeAreaEnv?: { top: boolean; bottom: boolean };
|
|
79
|
+
overlay?: { top: boolean; bottom: boolean };
|
|
67
80
|
gesture: boolean;
|
|
68
81
|
cache: boolean;
|
|
69
82
|
ssr: SsrRenderMode;
|
|
@@ -153,6 +166,8 @@ export interface RouteRender {
|
|
|
153
166
|
getLayoutManifest?: () => PromiseOrObject<WebAppManifest | undefined>;
|
|
154
167
|
/** The `page()` chain behind a page render, when it was declared as one — what a page prompt is read off. */
|
|
155
168
|
getRouteDefinition?: () => PromiseOrObject<RouteDefinition | undefined>;
|
|
169
|
+
/** The query names the level reads; `undefined` for a legacy module, which receives every one. */
|
|
170
|
+
getSearchNames?: () => PromiseOrObject<string[] | undefined>;
|
|
156
171
|
}
|
|
157
172
|
export interface RouteViewport {
|
|
158
173
|
/** `viewport-fit=cover`: the page runs under the notch and home indicator, and `env(safe-area-inset-*)` measures them. */
|
|
@@ -437,6 +452,8 @@ export interface KeyboardFrameState {
|
|
|
437
452
|
source?: "native" | "visualViewport" | "fallback";
|
|
438
453
|
animationDuration?: number;
|
|
439
454
|
animationEasing?: string;
|
|
455
|
+
/** The page's content ends at the keyboard, as UIKit's keyboard layout guide does: an iOS shell no longer pans. */
|
|
456
|
+
avoidsContent?: boolean;
|
|
440
457
|
}
|
|
441
458
|
export interface FrameContentViewportState {
|
|
442
459
|
top: number;
|
package/client/device.ts
CHANGED
|
@@ -1,16 +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
|
|
|
16
|
+
/** Whether the shell left the keyboard to the page; an older shell still pans to the field, so the page must not. */
|
|
17
|
+
export const isPageKeyboardAvoidance = () =>
|
|
18
|
+
(globalThis as { __AKAN_NATIVE__?: { keyboardAvoidance?: string } }).__AKAN_NATIVE__?.keyboardAvoidance === "page";
|
|
19
|
+
|
|
20
|
+
export const IOS_KEYBOARD_ANIMATION_EASING = "cubic-bezier(0.38, 0.7, 0.125, 1)";
|
|
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
|
+
|
|
14
28
|
const debugSessionId = crypto.getRandomValues(new Uint32Array(1))[0].toString(36);
|
|
15
29
|
let debugSeq = 0;
|
|
16
30
|
|
|
@@ -92,6 +106,12 @@ const langInPath = (pathname: string, supportLanguages: string[] | readonly stri
|
|
|
92
106
|
return supportLanguages.find((language) => language === predefinedLangPath);
|
|
93
107
|
};
|
|
94
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
|
+
|
|
95
115
|
const createWebDevice = ({
|
|
96
116
|
lang,
|
|
97
117
|
supportLanguages,
|
|
@@ -101,7 +121,7 @@ const createWebDevice = ({
|
|
|
101
121
|
}) => {
|
|
102
122
|
const pathname = typeof window === "undefined" ? "" : csrLocation.pathname;
|
|
103
123
|
return new Device({
|
|
104
|
-
lang: lang ?? langInPath(pathname, supportLanguages) ?? getBrowserLanguage(),
|
|
124
|
+
lang: lang ?? langInPath(pathname, supportLanguages) ?? supportedLang(getBrowserLanguage(), supportLanguages),
|
|
105
125
|
info: webDeviceInfo,
|
|
106
126
|
topSafeArea: 0,
|
|
107
127
|
bottomSafeArea: 0,
|
|
@@ -133,7 +153,8 @@ export class Device {
|
|
|
133
153
|
|
|
134
154
|
const { top: topSafeArea, bottom: bottomSafeArea } = readCssSafeAreaInsets();
|
|
135
155
|
Device.instance = new Device({
|
|
136
|
-
lang:
|
|
156
|
+
lang:
|
|
157
|
+
lang ?? langInPath(window.location.pathname, supportLanguages) ?? supportedLang(languageCode, supportLanguages),
|
|
137
158
|
info,
|
|
138
159
|
topSafeArea,
|
|
139
160
|
bottomSafeArea,
|
|
@@ -151,6 +172,9 @@ export class Device {
|
|
|
151
172
|
topSafeArea: number;
|
|
152
173
|
bottomSafeArea: number;
|
|
153
174
|
isMobile = isMobileDevice();
|
|
175
|
+
keyboardAnimationMs = 0;
|
|
176
|
+
keyboardHeight = 0;
|
|
177
|
+
#keyboardSubscribers = new Set<(height: number) => void>();
|
|
154
178
|
#native: NativeControls | null;
|
|
155
179
|
#stopKeyboardListeners: (() => void)[] = [];
|
|
156
180
|
#pageContentRef: RefObject<HTMLDivElement | null> | null = null;
|
|
@@ -168,24 +192,40 @@ export class Device {
|
|
|
168
192
|
async hideKeyboard() {
|
|
169
193
|
await this.#native?.keyboard.hide();
|
|
170
194
|
}
|
|
195
|
+
|
|
196
|
+
static #keyboardRide: KeyboardRideClass | null = null;
|
|
171
197
|
listenKeyboardChanged(onKeyboardChanged: (height: number) => void) {
|
|
172
198
|
const keyboard = this.#native?.keyboard;
|
|
173
199
|
if (!keyboard) return;
|
|
200
|
+
if (isPageKeyboardAvoidance())
|
|
201
|
+
void import("./keyboardRide").then(({ KeyboardRide }) => {
|
|
202
|
+
Device.#keyboardRide = KeyboardRide;
|
|
203
|
+
});
|
|
174
204
|
let currentHeight = 0;
|
|
175
205
|
const emitKeyboardHeight = (event: string, height: number) => {
|
|
176
206
|
debugFrame("keyboard.event", { event, height, previousHeight: currentHeight });
|
|
177
207
|
if (currentHeight === height) return;
|
|
178
208
|
currentHeight = height;
|
|
209
|
+
this.keyboardHeight = height;
|
|
179
210
|
onKeyboardChanged(height);
|
|
211
|
+
for (const subscriber of this.#keyboardSubscribers) subscriber(height);
|
|
180
212
|
};
|
|
181
213
|
this.#stopKeyboardListeners.push(
|
|
182
214
|
...(["willShow", "didShow", "willHide", "didHide"] as const).map((event) =>
|
|
183
|
-
keyboard.listen(event, ({ height }) => {
|
|
215
|
+
keyboard.listen(event, ({ height, duration }) => {
|
|
216
|
+
if (duration > 0) this.keyboardAnimationMs = duration;
|
|
217
|
+
Device.#keyboardRide?.move(height, this.keyboardAnimationMs);
|
|
184
218
|
emitKeyboardHeight(event, height);
|
|
185
219
|
}),
|
|
186
220
|
),
|
|
187
221
|
);
|
|
188
222
|
}
|
|
223
|
+
subscribeKeyboard(onKeyboardChanged: (height: number) => void) {
|
|
224
|
+
this.#keyboardSubscribers.add(onKeyboardChanged);
|
|
225
|
+
return () => {
|
|
226
|
+
this.#keyboardSubscribers.delete(onKeyboardChanged);
|
|
227
|
+
};
|
|
228
|
+
}
|
|
189
229
|
unlistenKeyboardChanged() {
|
|
190
230
|
for (const stop of this.#stopKeyboardListeners.splice(0)) stop();
|
|
191
231
|
}
|