akanjs 3.2.0-rc.2 → 3.2.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 +42 -41
- package/CHANGELOG.md +593 -3
- package/CONTRIBUTING.md +26 -0
- package/base/base.ts +2 -1
- package/client/clientRuntime.ts +1 -0
- package/client/cn.ts +2 -2
- package/client/csrTypes.ts +15 -1
- package/client/frameConfig.ts +5 -2
- package/client/index.ts +249 -26
- package/client/locale.ts +1 -0
- package/client/makePageProto.tsx +33 -82
- package/client/nativeThemeColor.ts +51 -0
- package/client/route/RouteDefinition.ts +24 -7
- package/client/route/RouteGuards.ts +2 -1
- package/client/route/RouteHead.ts +11 -2
- package/client/route/routeArgs.ts +7 -0
- package/client/router.ts +25 -6
- package/client/rscNavigation.ts +3 -3
- package/client/rscRoutePatch.ts +42 -0
- package/client/viewportMeta.ts +34 -4
- package/common/CodeTranscript.ts +1 -1
- package/common/PipelinePlanSchema.ts +2 -2
- package/common/akanGraph.ts +1 -1
- package/common/err.ts +122 -0
- package/common/facetBarrel.ts +38 -0
- package/common/failureCode.ts +18 -0
- package/common/index.ts +9 -0
- package/common/isGuardRefusal.ts +14 -0
- package/common/mcpExposure.ts +17 -4
- package/common/mcpFailure.ts +9 -0
- package/common/pipelinePlan.ts +1 -1
- package/common/restartSchedule.ts +55 -0
- package/common/routeConvention.ts +3 -1
- package/common/types.ts +18 -1
- package/constant/constantRegistry.ts +4 -8
- package/constant/crystalize.ts +1 -2
- package/constant/getDefault.ts +1 -1
- package/constant/immerify.ts +1 -1
- package/constant/index.ts +78 -21
- package/constant/purify.ts +4 -9
- package/constant/serialize.ts +4 -2
- package/constant/types.ts +1 -0
- package/constant/via.ts +1 -2
- package/dictionary/agent.dictionary.ts +4 -0
- package/dictionary/base.dictionary.ts +1 -0
- package/dictionary/locale.ts +1 -1
- package/dictionary/trans.ts +14 -97
- package/document/databaseRegistry.ts +2 -1
- package/document/documentSchema.ts +1 -0
- package/document/filterMeta.ts +4 -1
- package/document/into.ts +2 -1
- package/document/loaderInfo.ts +2 -1
- package/document/noDocumentError.ts +4 -1
- package/document/queryEvaluator.ts +1 -1
- package/document/types.ts +1 -1
- package/fetch/client/fetchClient.ts +87 -270
- package/fetch/client/fetchClientTypes.ts +49 -0
- package/fetch/client/fetchHandle.ts +11 -1
- package/fetch/client/httpClient.ts +14 -2
- package/fetch/client/inflightQueries.ts +17 -0
- package/fetch/client/remoteError.ts +4 -20
- package/fetch/client/requestScope.ts +32 -0
- package/fetch/client/signalCatalog.ts +131 -0
- package/fetch/client/wsClient.ts +11 -0
- package/fetch/index.ts +1 -0
- package/fetch/staleReads.ts +27 -0
- package/fetch/streamedRead.ts +23 -0
- package/package.json +1 -1
- package/server/agentHooks.ts +16 -0
- package/server/akanApp.ts +107 -1272
- package/server/akanOption.ts +17 -4
- package/server/akanServer.ts +167 -675
- package/server/artifact/builderRpc.ts +33 -10
- package/server/artifact/ipcTypes.ts +9 -3
- package/server/artifact/routeSeedIndexStore.ts +4 -2
- package/server/assetHeaders.ts +6 -0
- package/server/console.ts +6 -4
- package/server/decorators.ts +2 -2
- package/server/devtools/README.md +4 -3
- package/server/devtools/devtoolsRouter.ts +9 -5
- package/server/devtools/studio/studioRoute.ts +18 -11
- package/server/di/diLifecycle.ts +24 -35
- package/server/di/predefinedAdaptor.ts +24 -1
- package/server/di/resolveHierarchy.ts +19 -6
- package/server/di/utils.ts +7 -3
- package/server/ed25519Key.ts +31 -15
- package/server/flightRowReader.ts +95 -18
- package/server/gateway/childSupervisor.ts +326 -0
- package/server/gateway/devHostChannel.ts +47 -0
- package/server/gateway/gatewayChildren.ts +135 -0
- package/server/gateway/gatewayConfig.ts +182 -0
- package/server/gateway/gatewayHttpProxy.ts +231 -0
- package/server/gateway/gatewayLogging.ts +111 -0
- package/server/gateway/gatewayRooms.ts +141 -0
- package/server/gateway/gatewayStatus.ts +116 -0
- package/server/gateway/gatewayStatusPage.ts +54 -0
- package/server/gateway/gatewayWebSocketRelay.ts +149 -0
- package/server/head.tsx +4 -19
- package/server/hmr/devHmrController.ts +10 -1
- package/server/htmlResultCache.ts +234 -0
- package/server/imageOptimizer.ts +4 -1
- package/server/index.ts +257 -17
- package/server/lifecycle/parentChannel.ts +78 -0
- package/server/lifecycle/shutdownManager.ts +6 -3
- package/server/lifecycle/startGuard.ts +90 -0
- package/server/logging/logControlSocket.ts +42 -3
- package/server/logging/serverLogging.ts +74 -0
- package/server/machine/machineToken.ts +10 -3
- package/server/mcp/AgentTools.ts +149 -0
- package/server/mcp/AgentToolsAccount.ts +26 -0
- package/server/mcp/McpDispatcher.ts +48 -19
- package/server/mcp/McpPages.ts +21 -6
- package/server/mcp/McpRateLimiter.ts +14 -0
- package/server/mcp/McpRouter.ts +52 -23
- package/server/mcp/McpUiSession.ts +2 -1
- package/server/mcp/index.ts +1 -0
- package/server/nativeFile.ts +30 -11
- package/server/nativeSecret.ts +12 -3
- package/server/oauth/OAuthClientIdMetadata.ts +2 -2
- package/server/ops/opsRoute.ts +5 -1
- package/server/ops/opsToken.ts +3 -1
- package/server/resolver/CascadeRunner.ts +10 -4
- package/server/resolver/database.resolver.ts +10 -417
- package/server/resolver/databaseModelInstance.ts +200 -0
- package/server/resolver/invalidSignal.ts +7 -0
- package/server/resolver/livePause.ts +34 -0
- package/server/resolver/modelFacade.ts +136 -0
- package/server/resolver/modelLoaders.ts +52 -0
- package/server/resolver/modelSchema.ts +52 -0
- package/server/resolver/signal.resolver.ts +92 -116
- package/server/resolver/timedQuery.ts +16 -0
- package/server/resolver/websocketOf.ts +23 -0
- package/server/routeElementComposer.tsx +131 -9
- package/server/routeState.ts +5 -1
- package/server/routeTreeBuilder.ts +22 -9
- package/server/routing/apiRouter.ts +44 -25
- package/server/routing/builtinRoutes.ts +194 -0
- package/server/routing/localRooms.ts +34 -0
- package/server/routing/roomReplay.ts +2 -2
- package/server/routing/serverLimits.ts +4 -1
- package/server/routing/serverListener.ts +194 -0
- package/server/rscClient.tsx +210 -227
- package/server/rscClientCache.ts +165 -0
- package/server/rscClientChunks.ts +209 -0
- package/server/rscClientFetch.ts +15 -3
- package/server/rscClientPatch.ts +78 -15
- package/server/rscDocumentHead.tsx +170 -0
- package/server/rscFlightRenderer.ts +83 -0
- package/server/rscFlightStream.ts +257 -0
- package/server/rscHeadPatch.ts +17 -56
- package/server/rscHostReloads.ts +238 -0
- package/server/rscHostRenderStream.ts +297 -0
- package/server/rscHostRequests.ts +158 -0
- package/server/rscHttp.ts +18 -6
- package/server/rscInlineStream.ts +34 -0
- package/server/rscNavigationState.ts +21 -1
- package/server/rscPagePrompts.ts +11 -5
- package/server/rscParkedRedirect.ts +23 -0
- package/server/rscPatchPlanner.ts +220 -0
- package/server/rscPrefetchCache.ts +68 -32
- package/server/rscRenderControl.ts +33 -0
- package/server/rscRenderFallbacks.ts +297 -0
- package/server/rscRenderHandler.ts +439 -0
- package/server/rscRenderStats.ts +49 -0
- package/server/rscResponse.ts +78 -0
- package/server/rscResultCaches.ts +74 -0
- package/server/rscRouteDocument.tsx +299 -0
- package/server/rscSegmentOutlet.tsx +24 -5
- package/server/rscSegmentOutletReference.ts +14 -12
- package/server/rscWorker.tsx +86 -1392
- package/server/rscWorkerCache.ts +56 -0
- package/server/rscWorkerHost.ts +145 -811
- package/server/rscWorkerProcess.ts +155 -0
- package/server/rscWorkerRecycler.ts +128 -0
- package/server/serverConfig.ts +128 -0
- package/server/serverMetrics.ts +52 -0
- package/server/sitemap.ts +1 -0
- package/server/ssrFromRscRenderer.tsx +20 -20
- package/server/ssrTypes.ts +9 -0
- package/server/webArtifact.ts +86 -0
- package/server/webAssetRoutes.ts +84 -0
- package/server/webCsrSurface.ts +172 -0
- package/server/webDocumentRoute.ts +180 -0
- package/server/webRouteContext.ts +232 -0
- package/server/webRouter.ts +126 -1242
- package/server/webRscRoute.ts +155 -0
- package/server/webSiteFiles.ts +139 -0
- package/server/wellKnownRoutes.ts +73 -0
- package/service/agent.service.ts +59 -5
- package/service/agentAccounts.ts +19 -0
- package/service/agentLoop/agentLoop.ts +387 -0
- package/service/agentLoop/agentLoopTypes.ts +112 -0
- package/service/agentLoop/deltaStream.ts +40 -0
- package/service/agentLoop/loopCompaction.ts +135 -0
- package/service/agentLoop/loopRequest.ts +62 -0
- package/service/agentLoop/loopToolOutput.ts +54 -0
- package/service/agentLoop/loopToolkits.ts +107 -0
- package/service/agentLoop/loopTranscript.ts +102 -0
- package/{signal → service}/agentMeter.ts +83 -15
- package/{signal → service}/agentRelayPolicy.ts +30 -7
- package/service/documentStoreError.ts +16 -0
- package/service/index.ts +7 -0
- package/service/injectError.ts +5 -0
- package/service/injectInfo.ts +30 -18
- package/service/insightQueryError.ts +19 -0
- package/service/ipcTypes.ts +3 -1
- package/service/liveSyncHub.ts +5 -2
- package/service/predefinedAdaptor/agentTools.adaptor.ts +34 -0
- package/service/predefinedAdaptor/anthropicLlm.ts +52 -21
- package/service/predefinedAdaptor/cache.adaptor.ts +3 -2
- package/service/predefinedAdaptor/compress.adaptor.ts +7 -3
- package/service/predefinedAdaptor/database.adaptor.ts +3 -1
- package/service/predefinedAdaptor/documentTransfer.ts +2 -1
- package/service/predefinedAdaptor/index.ts +2 -0
- package/service/predefinedAdaptor/insightQuery.ts +35 -11
- package/service/predefinedAdaptor/llm.adaptor.ts +22 -2
- package/service/predefinedAdaptor/llmSpend.ts +80 -0
- package/service/predefinedAdaptor/openaiDialect.ts +52 -17
- package/service/predefinedAdaptor/openaiLlm.ts +17 -9
- package/service/predefinedAdaptor/role.adaptor.ts +2 -0
- package/service/predefinedAdaptor/searchIndex.ts +5 -1
- package/service/predefinedAdaptor/solidPubsub.adaptor.ts +35 -2
- package/service/predefinedAdaptor/solidQueue.adaptor.ts +2 -2
- package/service/predefinedAdaptor/solidSqlite.ts +3 -2
- package/service/predefinedAdaptor/sql/DocumentHydrator.ts +95 -0
- package/service/predefinedAdaptor/sql/DocumentRowCodec.ts +192 -0
- package/service/predefinedAdaptor/sql/DocumentWriter.ts +292 -0
- package/service/predefinedAdaptor/sql/PostgresInsightSession.ts +15 -5
- package/service/predefinedAdaptor/sql/QueryCompiler.ts +29 -13
- package/service/predefinedAdaptor/sql/QueryScope.ts +70 -0
- package/service/predefinedAdaptor/sql/QueryWriter.ts +200 -0
- package/service/predefinedAdaptor/sql/RawDocumentTable.ts +20 -8
- package/service/predefinedAdaptor/sql/SqlDocumentStore.ts +83 -1124
- package/service/predefinedAdaptor/sql/SqlTableSchema.ts +319 -0
- package/service/predefinedAdaptor/sql/SqliteInsightSession.ts +2 -1
- package/service/predefinedAdaptor/sql/StoredRows.ts +95 -0
- package/service/predefinedAdaptor/sql/UpdateCompiler.ts +6 -2
- package/service/predefinedAdaptor/sql/driver/bunSqlite.ts +3 -3
- package/service/predefinedAdaptor/sql/driver/postgres.ts +1 -1
- package/service/predefinedAdaptor/sql/fieldValues.ts +74 -0
- package/service/predefinedAdaptor/sql/search/fts5.ts +4 -1
- package/service/predefinedAdaptor/sql/search/postgres.ts +6 -2
- package/service/predefinedAdaptor/sql/values.ts +8 -4
- package/service/predefinedAdaptor/sseData.ts +14 -0
- package/service/predefinedAdaptor/storage.adaptor.ts +9 -4
- package/service/predefinedAdaptor/websocket.adaptor.ts +199 -43
- package/service/serve.ts +3 -2
- package/service/serviceModule.ts +2 -2
- package/service/serviceRegistry.ts +1 -0
- package/signal/SignalFailure.ts +30 -1
- package/signal/agent.signal.ts +30 -9
- package/signal/agentTurnStream.ts +12 -8
- package/signal/byIdRead.ts +18 -0
- package/signal/carriedClientIps.ts +1 -0
- package/signal/endpointErrorContract.ts +20 -2
- package/signal/endpointInfo.ts +6 -5
- package/signal/exception.ts +1 -0
- package/signal/index.ts +314 -30
- package/signal/internalInfo.ts +6 -4
- package/signal/mcp/McpDocument.ts +8 -1
- package/signal/mcp/Msg.ts +23 -10
- package/signal/mcp/index.ts +1 -0
- package/signal/mcp/promptError.ts +9 -0
- package/signal/middleware.ts +12 -3
- package/signal/openapi/openapi.ts +10 -1
- package/signal/resolveFieldContext.ts +34 -0
- package/signal/serializer/fetch.serializer.ts +23 -15
- package/signal/signalContext.ts +24 -57
- package/signal/signalContractError.ts +10 -0
- package/signal/signalDeclarationError.ts +13 -0
- package/signal/signalRegistry.ts +3 -1
- package/signal/slice.ts +24 -20
- package/signal/sliceInfo.ts +12 -9
- package/signal/trace.ts +3 -0
- package/signal/types.ts +35 -6
- package/store/action.ts +44 -1086
- package/store/actionErrorKey.ts +9 -0
- package/store/actionOption.ts +22 -0
- package/store/baseSt.ts +1 -0
- package/store/draftFlush.ts +5 -0
- package/store/draftStore.ts +2 -0
- package/store/formDrafts.ts +115 -0
- package/store/formFieldSetters.ts +229 -0
- package/store/index.ts +125 -17
- package/store/modelActionContext.ts +65 -0
- package/store/modelListPatch.ts +53 -0
- package/store/modelOpenActions.ts +158 -0
- package/store/modelWriteActions.ts +240 -0
- package/store/modelWriteGuard.ts +82 -0
- package/store/openSeq.ts +34 -0
- package/store/rootStore.ts +2 -0
- package/store/sliceListActions.ts +370 -0
- package/store/sliceLiveActions.ts +130 -0
- package/store/stateBuilder.ts +2 -0
- package/store/storeInstance.ts +9 -10
- package/store/uploadPoll.ts +52 -0
- package/store/withSelector.ts +6 -4
- package/types/base/base.d.ts +2 -1
- package/types/client/clientRuntime.d.ts +1 -0
- package/types/client/cn.d.ts +2 -2
- package/types/client/csrTypes.d.ts +15 -1
- package/types/client/frameConfig.d.ts +1 -0
- package/types/client/index.d.ts +25 -26
- package/types/client/locale.d.ts +1 -0
- package/types/client/makePageProto.d.ts +28 -26091
- package/types/client/nativeThemeColor.d.ts +6 -0
- package/types/client/route/RouteDefinition.d.ts +2 -2
- package/types/client/route/RouteHead.d.ts +5 -1
- package/types/client/route/routeArgs.d.ts +6 -0
- package/types/client/router.d.ts +6 -3
- package/types/client/rscNavigation.d.ts +3 -2
- package/types/client/rscRoutePatch.d.ts +22 -0
- package/types/client/viewportMeta.d.ts +3 -1
- package/types/common/CodeTranscript.d.ts +1 -1
- package/types/common/akanGraph.d.ts +1 -1
- package/types/common/err.d.ts +48 -0
- package/types/common/facetBarrel.d.ts +4 -0
- package/types/common/failureCode.d.ts +6 -0
- package/types/common/index.d.ts +8 -2
- package/types/common/isGuardRefusal.d.ts +3 -0
- package/types/common/mcpExposure.d.ts +9 -2
- package/types/common/mcpFailure.d.ts +6 -0
- package/types/common/restartSchedule.d.ts +16 -0
- package/types/common/routeConvention.d.ts +2 -0
- package/types/common/types.d.ts +18 -1
- package/types/constant/constantRegistry.d.ts +3 -1
- package/types/constant/crystalize.d.ts +1 -1
- package/types/constant/getDefault.d.ts +1 -1
- package/types/constant/immerify.d.ts +1 -1
- package/types/constant/index.d.ts +21 -21
- package/types/constant/purify.d.ts +2 -1
- package/types/constant/serialize.d.ts +1 -1
- package/types/constant/types.d.ts +1 -0
- package/types/dictionary/agent.dictionary.d.ts +1 -1
- package/types/dictionary/base.dictionary.d.ts +1 -1
- package/types/dictionary/dictionary.d.ts +9 -9
- package/types/dictionary/locale.d.ts +1 -1
- package/types/dictionary/trans.d.ts +3 -26
- package/types/document/databaseRegistry.d.ts +2 -1
- package/types/document/documentSchema.d.ts +1 -0
- package/types/document/filterMeta.d.ts +4 -1
- package/types/document/into.d.ts +1 -1
- package/types/document/loaderInfo.d.ts +2 -1
- package/types/document/noDocumentError.d.ts +8 -1
- package/types/document/queryEvaluator.d.ts +1 -1
- package/types/document/types.d.ts +1 -1
- package/types/fetch/client/fetchClient.d.ts +6 -36
- package/types/fetch/client/fetchClientTypes.d.ts +40 -0
- package/types/fetch/client/fetchHandle.d.ts +1 -0
- package/types/fetch/client/httpClient.d.ts +2 -0
- package/types/fetch/client/inflightQueries.d.ts +2 -0
- package/types/fetch/client/remoteError.d.ts +0 -4
- package/types/fetch/client/requestScope.d.ts +6 -0
- package/types/fetch/client/signalCatalog.d.ts +25 -0
- package/types/fetch/client/wsClient.d.ts +1 -0
- package/types/fetch/index.d.ts +1 -0
- package/types/fetch/staleReads.d.ts +8 -0
- package/types/fetch/streamedRead.d.ts +8 -0
- package/types/server/agentHooks.d.ts +4 -0
- package/types/server/akanApp.d.ts +2 -20
- package/types/server/akanOption.d.ts +9 -3
- package/types/server/akanServer.d.ts +1 -1
- package/types/server/artifact/builderRpc.d.ts +8 -0
- package/types/server/artifact/ipcTypes.d.ts +8 -0
- package/types/server/assetHeaders.d.ts +1 -0
- package/types/server/console.d.ts +4 -3
- package/types/server/devtools/devtoolsRouter.d.ts +4 -1
- package/types/server/devtools/studio/studioRoute.d.ts +2 -1
- package/types/server/di/predefinedAdaptor.d.ts +1 -0
- package/types/server/ed25519Key.d.ts +1 -0
- package/types/server/flightRowReader.d.ts +3 -1
- package/types/server/gateway/childSupervisor.d.ts +33 -0
- package/types/server/gateway/devHostChannel.d.ts +14 -0
- package/types/server/gateway/gatewayChildren.d.ts +47 -0
- package/types/server/gateway/gatewayConfig.d.ts +82 -0
- package/types/server/gateway/gatewayHttpProxy.d.ts +22 -0
- package/types/server/gateway/gatewayLogging.d.ts +16 -0
- package/types/server/gateway/gatewayRooms.d.ts +25 -0
- package/types/server/gateway/gatewayStatus.d.ts +62 -0
- package/types/server/gateway/gatewayStatusPage.d.ts +9 -0
- package/types/server/gateway/gatewayWebSocketRelay.d.ts +17 -0
- package/types/server/head.d.ts +2 -2
- package/types/server/htmlResultCache.d.ts +51 -0
- package/types/server/index.d.ts +17 -17
- package/types/server/lifecycle/parentChannel.d.ts +13 -0
- package/types/server/lifecycle/startGuard.d.ts +10 -0
- package/types/server/logging/rotatingLogWriter.d.ts +1 -1
- package/types/server/logging/serverLogging.d.ts +12 -0
- package/types/server/mcp/AgentTools.d.ts +31 -0
- package/types/server/mcp/AgentToolsAccount.d.ts +7 -0
- package/types/server/mcp/McpDispatcher.d.ts +10 -1
- package/types/server/mcp/McpPages.d.ts +2 -1
- package/types/server/mcp/McpRateLimiter.d.ts +3 -0
- package/types/server/mcp/index.d.ts +1 -0
- package/types/server/resolver/database.resolver.d.ts +2 -2
- package/types/server/resolver/databaseModelInstance.d.ts +4 -0
- package/types/server/resolver/invalidSignal.d.ts +2 -0
- package/types/server/resolver/livePause.d.ts +5 -0
- package/types/server/resolver/modelFacade.d.ts +5 -0
- package/types/server/resolver/modelLoaders.d.ts +9 -0
- package/types/server/resolver/modelSchema.d.ts +6 -0
- package/types/server/resolver/signal.resolver.d.ts +2 -2
- package/types/server/resolver/timedQuery.d.ts +8 -0
- package/types/server/resolver/websocketOf.d.ts +2 -0
- package/types/server/routeElementComposer.d.ts +45 -6
- package/types/server/routeState.d.ts +2 -0
- package/types/server/routing/builtinRoutes.d.ts +24 -0
- package/types/server/routing/localRooms.d.ts +14 -0
- package/types/server/routing/roomReplay.d.ts +2 -2
- package/types/server/routing/serverListener.d.ts +31 -0
- package/types/server/rscClient.d.ts +1 -5
- package/types/server/rscClientCache.d.ts +34 -0
- package/types/server/rscClientChunks.d.ts +18 -0
- package/types/server/rscClientFetch.d.ts +1 -1
- package/types/server/rscClientPatch.d.ts +12 -1
- package/types/server/rscDocumentHead.d.ts +32 -0
- package/types/server/rscFlightRenderer.d.ts +14 -0
- package/types/server/rscFlightStream.d.ts +52 -0
- package/types/server/rscHeadPatch.d.ts +5 -4
- package/types/server/rscHostReloads.d.ts +54 -0
- package/types/server/rscHostRenderStream.d.ts +53 -0
- package/types/server/rscHostRequests.d.ts +29 -0
- package/types/server/rscHttp.d.ts +4 -2
- package/types/server/rscInlineStream.d.ts +9 -0
- package/types/server/rscNavigationState.d.ts +8 -3
- package/types/server/rscParkedRedirect.d.ts +12 -0
- package/types/server/rscPatchPlanner.d.ts +49 -0
- package/types/server/rscPrefetchCache.d.ts +8 -7
- package/types/server/rscRenderControl.d.ts +12 -0
- package/types/server/rscRenderFallbacks.d.ts +41 -0
- package/types/server/rscRenderHandler.d.ts +29 -0
- package/types/server/rscRenderStats.d.ts +32 -0
- package/types/server/rscResponse.d.ts +9 -0
- package/types/server/rscResultCaches.d.ts +18 -0
- package/types/server/rscRouteDocument.d.ts +52 -0
- package/types/server/rscSegmentOutlet.d.ts +5 -0
- package/types/server/rscSegmentOutletReference.d.ts +2 -1
- package/types/server/rscWorker.d.ts +1 -3
- package/types/server/rscWorkerCache.d.ts +33 -1
- package/types/server/rscWorkerHost.d.ts +9 -76
- package/types/server/rscWorkerProcess.d.ts +31 -0
- package/types/server/rscWorkerRecycler.d.ts +22 -0
- package/types/server/serverConfig.d.ts +30 -0
- package/types/server/serverMetrics.d.ts +11 -0
- package/types/server/sitemap.d.ts +1 -0
- package/types/server/ssrFromRscRenderer.d.ts +2 -2
- package/types/server/ssrTypes.d.ts +8 -0
- package/types/server/webArtifact.d.ts +7 -0
- package/types/server/webAssetRoutes.d.ts +11 -0
- package/types/server/webCsrSurface.d.ts +18 -0
- package/types/server/webDocumentRoute.d.ts +19 -0
- package/types/server/webRouteContext.d.ts +45 -0
- package/types/server/webRouter.d.ts +4 -35
- package/types/server/webRscRoute.d.ts +24 -0
- package/types/server/webSiteFiles.d.ts +12 -0
- package/types/server/wellKnownRoutes.d.ts +5 -0
- package/types/service/agent.service.d.ts +13 -4
- package/types/service/agentAccounts.d.ts +8 -0
- package/types/service/agentLoop/agentLoop.d.ts +31 -0
- package/types/service/agentLoop/agentLoopTypes.d.ts +126 -0
- package/types/service/agentLoop/deltaStream.d.ts +3 -0
- package/types/service/agentLoop/loopCompaction.d.ts +11 -0
- package/types/service/agentLoop/loopRequest.d.ts +6 -0
- package/types/service/agentLoop/loopToolOutput.d.ts +7 -0
- package/types/service/agentLoop/loopToolkits.d.ts +14 -0
- package/types/service/agentLoop/loopTranscript.d.ts +12 -0
- package/types/service/agentMeter.d.ts +50 -0
- package/types/service/agentRelayPolicy.d.ts +45 -0
- package/types/service/documentStoreError.d.ts +7 -0
- package/types/service/index.d.ts +7 -0
- package/types/service/injectError.d.ts +4 -0
- package/types/service/injectInfo.d.ts +2 -1
- package/types/service/insightQueryError.d.ts +9 -0
- package/types/service/ipcTypes.d.ts +6 -0
- package/types/service/predefinedAdaptor/agentTools.adaptor.d.ts +31 -0
- package/types/service/predefinedAdaptor/anthropicLlm.d.ts +2 -2
- package/types/service/predefinedAdaptor/index.d.ts +2 -0
- package/types/service/predefinedAdaptor/llm.adaptor.d.ts +18 -2
- package/types/service/predefinedAdaptor/llmSpend.d.ts +22 -0
- package/types/service/predefinedAdaptor/openaiDialect.d.ts +2 -1
- package/types/service/predefinedAdaptor/openaiLlm.d.ts +1 -1
- package/types/service/predefinedAdaptor/role.adaptor.d.ts +2 -0
- package/types/service/predefinedAdaptor/solidPubsub.adaptor.d.ts +3 -0
- package/types/service/predefinedAdaptor/solidSqlite.d.ts +1 -1
- package/types/service/predefinedAdaptor/sql/DocumentHydrator.d.ts +11 -0
- package/types/service/predefinedAdaptor/sql/DocumentRowCodec.d.ts +26 -0
- package/types/service/predefinedAdaptor/sql/DocumentWriter.d.ts +24 -0
- package/types/service/predefinedAdaptor/sql/QueryScope.d.ts +16 -0
- package/types/service/predefinedAdaptor/sql/QueryWriter.d.ts +20 -0
- package/types/service/predefinedAdaptor/sql/SqlDocumentStore.d.ts +1 -32
- package/types/service/predefinedAdaptor/sql/SqlTableSchema.d.ts +20 -0
- package/types/service/predefinedAdaptor/sql/StoredRows.d.ts +27 -0
- package/types/service/predefinedAdaptor/sql/driver/bunSqlite.d.ts +1 -14
- package/types/service/predefinedAdaptor/sql/driver/postgres.d.ts +0 -8
- package/types/service/predefinedAdaptor/sql/fieldValues.d.ts +5 -0
- package/types/service/predefinedAdaptor/sseData.d.ts +5 -0
- package/types/service/predefinedAdaptor/websocket.adaptor.d.ts +14 -5
- package/types/service/serviceModule.d.ts +1 -1
- package/types/service/serviceRegistry.d.ts +1 -0
- package/types/signal/SignalFailure.d.ts +2 -0
- package/types/signal/agentTurnStream.d.ts +2 -1
- package/types/signal/byIdRead.d.ts +7 -0
- package/types/signal/carriedClientIps.d.ts +4 -0
- package/types/signal/endpointErrorContract.d.ts +3 -0
- package/types/signal/exception.d.ts +1 -0
- package/types/signal/index.d.ts +32 -30
- package/types/signal/mcp/McpDocument.d.ts +2 -0
- package/types/signal/mcp/index.d.ts +1 -0
- package/types/signal/mcp/promptError.d.ts +5 -0
- package/types/signal/resolveFieldContext.d.ts +15 -0
- package/types/signal/serializer/fetch.serializer.d.ts +3 -1
- package/types/signal/signalContext.d.ts +1 -13
- package/types/signal/signalContractError.d.ts +4 -0
- package/types/signal/signalDeclarationError.d.ts +4 -0
- package/types/signal/slice.d.ts +15 -13
- package/types/signal/trace.d.ts +3 -0
- package/types/signal/types.d.ts +33 -6
- package/types/store/action.d.ts +8 -27
- package/types/store/actionErrorKey.d.ts +1 -0
- package/types/store/actionOption.d.ts +24 -0
- package/types/store/baseSt.d.ts +2 -295
- package/types/store/draftFlush.d.ts +4 -0
- package/types/store/formDrafts.d.ts +21 -0
- package/types/store/formFieldSetters.d.ts +80 -0
- package/types/store/index.d.ts +17 -16
- package/types/store/modelActionContext.d.ts +189 -0
- package/types/store/modelListPatch.d.ts +34 -0
- package/types/store/modelOpenActions.d.ts +12 -0
- package/types/store/modelWriteActions.d.ts +16 -0
- package/types/store/modelWriteGuard.d.ts +42 -0
- package/types/store/openSeq.d.ts +17 -0
- package/types/store/rootStore.d.ts +6 -0
- package/types/store/sliceListActions.d.ts +295 -0
- package/types/store/sliceLiveActions.d.ts +6 -0
- package/types/store/stateBuilder.d.ts +2 -0
- package/types/store/uploadPoll.d.ts +16 -0
- package/types/store/withSelector.d.ts +1 -1
- package/types/ui/Agent/Chat.d.ts +5 -2
- package/types/ui/Agent/ChatHeader.d.ts +13 -0
- package/types/ui/Agent/ChatPendingCards.d.ts +23 -0
- package/types/ui/Field/Choice.d.ts +2 -1
- package/types/ui/Field/index.d.ts +1 -1
- package/types/ui/Link/inputModality.d.ts +5 -0
- package/types/ui/Link/viewportPrefetch.d.ts +4 -0
- package/types/ui/Load/Edit_Client.d.ts +2 -0
- package/types/ui/Load/Pagination.d.ts +4 -1
- package/types/ui/Load/Stream.d.ts +7 -1
- package/types/ui/Load/StreamBoundary.d.ts +20 -0
- package/types/ui/Load/Units.d.ts +2 -0
- package/types/ui/Load/View.d.ts +2 -0
- package/types/ui/Reference/origin.d.ts +1 -0
- package/types/ui/index.d.ts +1 -1
- package/types/ui/overlayLayer.d.ts +6 -1
- package/types/ui/recipe/badgeRecipe.d.ts +3 -3
- package/types/ui/recipe/buttonRecipe.d.ts +3 -3
- package/types/ui/recipe/inputRecipe.d.ts +1 -1
- package/types/vendor/@akanjs/native/packages/cli/src/lib/project.d.ts +4 -0
- package/types/vendor/@akanjs/native/packages/desktop/src/relaunch.d.ts +1 -0
- package/types/vendor/@akanjs/native/plugins/appearance/src/index.d.ts +9 -0
- package/types/vendor/@akanjs/native/plugins/external-view/src/index.d.ts +18 -11
- package/types/vendor/use-agentic/AgentClientTools.d.ts +19 -0
- package/types/vendor/use-agentic/failureCode.d.ts +4 -0
- package/types/vendor/use-agentic/index.d.ts +1 -0
- package/types/vendor/use-agentic/types.d.ts +11 -0
- package/types/webkit/CsrGuards.d.ts +2 -0
- package/types/webkit/RouteLevelBoundary.d.ts +17 -0
- package/types/webkit/nativeCore.d.ts +1 -0
- package/types/webkit/nativePurchase.d.ts +2 -1
- package/types/webkit/useCsrKeyboard.d.ts +19 -0
- package/types/webkit/useCsrLocationState.d.ts +21 -0
- package/types/webkit/useCsrNavigation.d.ts +25 -0
- package/types/webkit/useCsrRefs.d.ts +33 -0
- package/types/webkit/useCsrRenderTrace.d.ts +13 -0
- package/types/webkit/useCsrStackLifecycle.d.ts +12 -0
- package/types/webkit/useCsrTransitions.d.ts +2 -0
- package/types/webkit/useFrameRuntime.d.ts +1 -0
- package/types/webkit/useGeoLocation.d.ts +1 -1
- package/types/webkit/useHistory.d.ts +2 -3
- package/types/webkit/usePurchase.d.ts +1 -1
- package/types/webkit/useResolvedFrame.d.ts +38 -0
- package/types/webkit/useSyncNavigation.d.ts +22 -0
- package/types/webkit/useTransitionStore.d.ts +1 -0
- package/ui/Agent/Chat.tsx +392 -235
- package/ui/Agent/ChatHeader.tsx +59 -0
- package/ui/Agent/ChatPendingCards.tsx +49 -0
- package/ui/Agent/fetchRunner.ts +8 -1
- package/ui/BottomSheet.tsx +1 -1
- package/ui/Button.tsx +1 -0
- package/ui/Data/Item.tsx +2 -2
- package/ui/Data/ListContainer.tsx +348 -181
- package/ui/Data/useViewModal.ts +10 -4
- package/ui/Dialog/LegacyModal.tsx +1 -1
- package/ui/Dialog/Modal.tsx +1 -1
- package/ui/Field/Choice.tsx +3 -1
- package/ui/Link/inputModality.ts +21 -0
- package/ui/Link/prefetchIntent.ts +7 -25
- package/ui/Link/viewportPrefetch.ts +30 -0
- package/ui/Load/Edit_Client.tsx +7 -1
- package/ui/Load/Pagination.tsx +10 -2
- package/ui/Load/Stream.tsx +24 -4
- package/ui/Load/StreamBoundary.tsx +65 -0
- package/ui/Load/Units.tsx +3 -0
- package/ui/Load/View.tsx +5 -1
- package/ui/Model/EditModal.tsx +2 -1
- package/ui/Popconfirm.tsx +1 -1
- package/ui/Reference/origin.ts +1 -0
- package/ui/Select.tsx +43 -51
- package/ui/Signal/RestApi.tsx +3 -2
- package/ui/System/Client.tsx +32 -8
- package/ui/index.ts +4 -0
- package/ui/overlayLayer.ts +22 -1
- package/vendor/@akanjs/native/CHANGELOG.md +7 -1
- package/vendor/@akanjs/native/native/android/src/com/akanjs/runtime/AkanNativeActivity.kt +27 -12
- package/vendor/@akanjs/native/native/android/src/com/akanjs/runtime/AkanNativePlugin.kt +4 -0
- package/vendor/@akanjs/native/native/desktop/src/external.rs +213 -111
- package/vendor/@akanjs/native/native/desktop/src/lib.rs +12 -4
- package/vendor/@akanjs/native/native/desktop/src/linux/external.rs +509 -0
- package/vendor/@akanjs/native/native/desktop/src/linux/mod.rs +1 -0
- package/vendor/@akanjs/native/native/ios/Sources/AkanNativeViewController.swift +6 -1
- package/vendor/@akanjs/native/packages/cli/src/lib/native-plugins.ts +5 -3
- package/vendor/@akanjs/native/packages/cli/src/lib/project.ts +25 -1
- package/vendor/@akanjs/native/packages/desktop/src/deeplinks.ts +2 -2
- package/vendor/@akanjs/native/packages/desktop/src/host.ts +2 -2
- package/vendor/@akanjs/native/packages/desktop/src/relaunch.ts +8 -3
- package/vendor/@akanjs/native/plugins/app/src/desktop.ts +2 -2
- package/vendor/@akanjs/native/plugins/appearance/android/AppearancePlugin.kt +13 -0
- package/vendor/@akanjs/native/plugins/appearance/ios/AppearancePlugin.swift +27 -0
- package/vendor/@akanjs/native/plugins/appearance/native-plugin.json +2 -2
- package/vendor/@akanjs/native/plugins/appearance/src/index.ts +8 -1
- package/vendor/@akanjs/native/plugins/autostart/src/desktop.ts +2 -1
- package/vendor/@akanjs/native/plugins/external-view/native-plugin.json +4 -1
- package/vendor/@akanjs/native/plugins/external-view/src/index.ts +18 -11
- package/vendor/use-agentic/AgentClientTools.ts +33 -0
- package/vendor/use-agentic/AgentSession.ts +11 -11
- package/vendor/use-agentic/CHANGELOG.md +46 -1
- package/vendor/use-agentic/Compaction.ts +2 -1
- package/vendor/use-agentic/ToolRunner.ts +6 -3
- package/vendor/use-agentic/Transcript.ts +6 -3
- package/vendor/use-agentic/WIRE.md +29 -7
- package/vendor/use-agentic/failureCode.ts +44 -0
- package/vendor/use-agentic/httpRunner.ts +15 -4
- package/vendor/use-agentic/index.ts +1 -0
- package/vendor/use-agentic/types.ts +11 -0
- package/webkit/CsrGuards.ts +7 -2
- package/webkit/McpAppAgent.ts +8 -3
- package/webkit/McpAppFetchBridge.ts +11 -5
- package/webkit/RouteLevelBoundary.tsx +37 -0
- package/webkit/nativeCore.ts +1 -0
- package/webkit/nativePurchase.ts +6 -3
- package/webkit/useCamera.tsx +22 -21
- package/webkit/useCsrKeyboard.ts +155 -0
- package/webkit/useCsrLocationState.ts +58 -0
- package/webkit/useCsrNavigation.ts +302 -0
- package/webkit/useCsrRefs.ts +52 -0
- package/webkit/useCsrRenderTrace.ts +68 -0
- package/webkit/useCsrStackLifecycle.ts +120 -0
- package/webkit/useCsrTransitions.ts +552 -0
- package/webkit/useCsrValues.ts +69 -1234
- package/webkit/useGeoLocation.tsx +4 -1
- package/webkit/useHistory.ts +2 -2
- package/webkit/useLocation.ts +3 -2
- package/webkit/usePurchase.tsx +4 -2
- package/webkit/useResolvedFrame.ts +116 -0
- package/webkit/useSyncNavigation.ts +109 -0
- package/webkit/useTransitionStore.ts +13 -0
- package/types/signal/agentMeter.d.ts +0 -27
- package/types/signal/agentRelayPolicy.d.ts +0 -25
package/webkit/useCsrValues.ts
CHANGED
|
@@ -1,18 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useSpringValue } from "@react-spring/web";
|
|
3
|
-
import { useDrag } from "@use-gesture/react";
|
|
4
2
|
import {
|
|
5
3
|
type CsrContextType,
|
|
6
|
-
router as clientRouter,
|
|
7
4
|
csrLocation,
|
|
8
|
-
Device,
|
|
9
5
|
debugFrame,
|
|
10
|
-
defaultPageState,
|
|
11
|
-
getAuthToken,
|
|
12
|
-
getPathInfo,
|
|
13
6
|
Href,
|
|
14
7
|
type Location,
|
|
15
|
-
type LocationState,
|
|
16
8
|
type NavigationIntent,
|
|
17
9
|
type PageState,
|
|
18
10
|
type PageTransition,
|
|
@@ -22,1069 +14,35 @@ import {
|
|
|
22
14
|
type RouterInstance,
|
|
23
15
|
type RouteState,
|
|
24
16
|
type TransitionType,
|
|
25
|
-
type UseCsrTransition,
|
|
26
17
|
} from "akanjs/client";
|
|
27
18
|
import { isNativeApp, openExternalUrl } from "akanjs/client/native";
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
32
|
-
import { type
|
|
33
|
-
import {
|
|
34
|
-
import {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
resolveLocationWithFrameState,
|
|
49
|
-
resolvePathRoutesWithFrameState,
|
|
50
|
-
useFrameRuntimeResync,
|
|
51
|
-
useFrameSlots,
|
|
52
|
-
useFrameViewport,
|
|
53
|
-
useKeyboardFrame,
|
|
54
|
-
} from "./useFrameRuntime";
|
|
55
|
-
import { useHistory } from "./useHistory";
|
|
56
|
-
import { useLocation } from "./useLocation";
|
|
57
|
-
|
|
58
|
-
const linearEasing = (t: number) => t;
|
|
59
|
-
|
|
60
|
-
const getBottomInsetTop = (clientHeight: number, pageState: PathRoute["pageState"]) =>
|
|
61
|
-
clientHeight - pageState.bottomInset - pageState.bottomSafeArea;
|
|
62
|
-
|
|
63
|
-
const getFrameContentOffset = (ownTop: number, prevTop: number, pageTop: number, progress: number) =>
|
|
64
|
-
ownTop - (prevTop + (pageTop - prevTop) * progress);
|
|
65
|
-
|
|
66
|
-
type GestureIntent = "pending" | "gesture" | "scroll";
|
|
67
|
-
const GESTURE_INTENT_THRESHOLD = 8;
|
|
68
|
-
const GESTURE_AXIS_LOCK_RATIO = 1.25;
|
|
69
|
-
const STACK_VELOCITY_DISMISS_THRESHOLD = 0.45;
|
|
70
|
-
const STACK_SETTLE_MIN_DURATION = 90;
|
|
71
|
-
const STACK_SETTLE_MAX_DURATION = 260;
|
|
72
|
-
const ANDROID_SCALE_TRANSITION_DURATION = 220;
|
|
73
|
-
const CSR_RUNTIME_SEARCH_PARAMS = ["csr", "akanMobileTarget", "akanMobileBasePath", "akanMobileIndexPath"] as const;
|
|
74
|
-
|
|
75
|
-
const getVelocityAwareDuration = (distance: number, velocity: number, fallback: number) => {
|
|
76
|
-
const absVelocity = Math.abs(velocity);
|
|
77
|
-
if (absVelocity <= 0.01) return fallback;
|
|
78
|
-
return clamp(Math.round(Math.abs(distance) / absVelocity), STACK_SETTLE_MIN_DURATION, STACK_SETTLE_MAX_DURATION);
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
const getSyncRouteHref = (location: {
|
|
82
|
-
pathname: string;
|
|
83
|
-
search: string;
|
|
84
|
-
hash: string;
|
|
85
|
-
params?: { [key: string]: string };
|
|
19
|
+
import { useCallback, useMemo, useState } from "react";
|
|
20
|
+
import { useCsrKeyboard } from "./useCsrKeyboard";
|
|
21
|
+
import { type CsrLocationState, useCsrLocationState } from "./useCsrLocationState";
|
|
22
|
+
import { type CsrNavigation, useCsrNavigation } from "./useCsrNavigation";
|
|
23
|
+
import { type CsrRefs, currentRouter, useCsrRefs } from "./useCsrRefs";
|
|
24
|
+
import { useCsrRenderTrace } from "./useCsrRenderTrace";
|
|
25
|
+
import { useCsrStackLifecycle } from "./useCsrStackLifecycle";
|
|
26
|
+
import { useCsrTransitions } from "./useCsrTransitions";
|
|
27
|
+
import { FRAME_Z_INDEX, useFrameSlots, useFrameViewport } from "./useFrameRuntime";
|
|
28
|
+
import { useResolvedFrame } from "./useResolvedFrame";
|
|
29
|
+
import { getSyncRouteHref, useSyncNavigation } from "./useSyncNavigation";
|
|
30
|
+
|
|
31
|
+
const useCsrRouter = ({
|
|
32
|
+
refs: { pendingNavigation, pageContentRef, waitingNavigation, onBack, latestRouter },
|
|
33
|
+
nav,
|
|
34
|
+
navigation,
|
|
35
|
+
}: {
|
|
36
|
+
refs: CsrRefs;
|
|
37
|
+
nav: CsrLocationState;
|
|
38
|
+
navigation: CsrNavigation;
|
|
86
39
|
}) => {
|
|
87
|
-
const
|
|
88
|
-
const
|
|
89
|
-
const
|
|
90
|
-
const
|
|
91
|
-
const mobileBasePath = runtimeSearch.get("akanMobileBasePath") ?? "";
|
|
92
|
-
if (mobileBasePath) configuredBasePaths.add(mobileBasePath);
|
|
93
|
-
const prefix = segments[1] && configuredBasePaths.has(segments[1]) ? segments[1] : "";
|
|
94
|
-
const { path } = getPathInfo(location.pathname, lang, prefix);
|
|
95
|
-
for (const param of CSR_RUNTIME_SEARCH_PARAMS) runtimeSearch.delete(param);
|
|
96
|
-
const search = runtimeSearch.toString();
|
|
97
|
-
return `${path}${search ? `?${search}` : ""}${location.hash ? `#${location.hash}` : ""}`;
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
type Progress = UseCsrTransition["transProgress"];
|
|
101
|
-
type FramePageState = PathRoute["pageState"];
|
|
102
|
-
|
|
103
|
-
const tween = (progress: Progress, from: number, to: number) => progress.to([0, 1], [from, to]);
|
|
104
|
-
const fadeIn = (progress: Progress) => ({ opacity: progress.to((value) => value) });
|
|
105
|
-
const fadeOut = (progress: Progress) => ({ opacity: progress.to((value) => 1 - value) });
|
|
106
|
-
|
|
107
|
-
const pageContentStyle = ({ frameLayout }: RouteState, pageState: FramePageState) => ({
|
|
108
|
-
paddingTop: pageState.topSafeArea + pageState.topInset,
|
|
109
|
-
paddingBottom: Math.max(
|
|
110
|
-
pageState.bottomSafeArea,
|
|
111
|
-
pageState.bottomInset +
|
|
112
|
-
pageState.bottomSafeArea -
|
|
113
|
-
(frameLayout.keyboard.sticky ? frameLayout.keyboardAccessory.height : 0),
|
|
114
|
-
),
|
|
115
|
-
height: frameLayout.contentViewport.height,
|
|
116
|
-
"--akan-content-height": `${frameLayout.contentViewport.height}px`,
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
const prevPageContentStyle = (clientHeight: number, prevPageState: FramePageState) => ({
|
|
120
|
-
paddingTop: prevPageState.topSafeArea + prevPageState.topInset,
|
|
121
|
-
paddingBottom: prevPageState.bottomInset + prevPageState.bottomSafeArea,
|
|
122
|
-
height: clientHeight,
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
const tweenedSafeAreas = (
|
|
126
|
-
progress: Progress,
|
|
127
|
-
clientHeight: number,
|
|
128
|
-
pageState: FramePageState,
|
|
129
|
-
prevPageState: FramePageState,
|
|
130
|
-
) => ({
|
|
131
|
-
topSafeArea: {
|
|
132
|
-
containerStyle: {
|
|
133
|
-
backgroundColor: pageState.topSafeAreaColor,
|
|
134
|
-
height: tween(progress, prevPageState.topSafeArea, pageState.topSafeArea),
|
|
135
|
-
},
|
|
136
|
-
},
|
|
137
|
-
bottomSafeArea: {
|
|
138
|
-
containerStyle: {
|
|
139
|
-
backgroundColor: pageState.bottomSafeAreaColor,
|
|
140
|
-
visibility:
|
|
141
|
-
pageState.bottomInset > 0 || pageState.bottomSafeAreaColor !== defaultPageState.bottomSafeAreaColor
|
|
142
|
-
? ("visible" as const)
|
|
143
|
-
: ("hidden" as const),
|
|
144
|
-
top: tween(progress, clientHeight - prevPageState.bottomSafeArea, clientHeight - pageState.bottomSafeArea),
|
|
145
|
-
height: tween(progress, prevPageState.bottomSafeArea, pageState.bottomSafeArea),
|
|
146
|
-
},
|
|
147
|
-
},
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
const tweenedTopInset = (progress: Progress, pageState: FramePageState, prevPageState: FramePageState) => ({
|
|
151
|
-
top: tween(progress, prevPageState.topSafeArea, pageState.topSafeArea),
|
|
152
|
-
height: tween(progress, prevPageState.topInset, pageState.topInset),
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
const tweenedBottomInset = (
|
|
156
|
-
progress: Progress,
|
|
157
|
-
clientHeight: number,
|
|
158
|
-
pageState: FramePageState,
|
|
159
|
-
prevPageState: FramePageState,
|
|
160
|
-
) => ({
|
|
161
|
-
height: tween(progress, prevPageState.bottomInset, pageState.bottomInset),
|
|
162
|
-
top: tween(progress, getBottomInsetTop(clientHeight, prevPageState), getBottomInsetTop(clientHeight, pageState)),
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
const useFadeSpring = () => {
|
|
166
|
-
const transUnit = useSpringValue(1, { config: { clamp: true } });
|
|
167
|
-
const transUnitRange = useMemo(() => [0, 1], []);
|
|
168
|
-
return {
|
|
169
|
-
transUnit,
|
|
170
|
-
transUnitRange,
|
|
171
|
-
transProgress: transUnit.to((unit) => unit),
|
|
172
|
-
transPercent: transUnit.to([0, 1], [0, 100], "clamp"),
|
|
173
|
-
};
|
|
174
|
-
};
|
|
175
|
-
|
|
176
|
-
const useSlideSpring = (size: number) => {
|
|
177
|
-
const transUnit = useSpringValue(0, { config: { clamp: true } });
|
|
178
|
-
const transUnitRange = useMemo(() => [size, 0], [size]);
|
|
179
|
-
const transUnitReversed = transUnit.to((unit) => transUnitRange[0] - unit);
|
|
180
|
-
const transUnitRangeReversed = useMemo(() => [0, size], [size]);
|
|
181
|
-
return {
|
|
182
|
-
transUnit,
|
|
183
|
-
transUnitRange,
|
|
184
|
-
transProgress: transUnitReversed.to(transUnitRangeReversed, [0, 1], "clamp"),
|
|
185
|
-
transPercent: transUnitReversed.to(transUnitRangeReversed, [0, 100], "clamp"),
|
|
186
|
-
};
|
|
187
|
-
};
|
|
188
|
-
|
|
189
|
-
const usePlayOnForward = (
|
|
190
|
-
{ transUnit, transUnitRange }: Pick<UseCsrTransition, "transUnit" | "transUnitRange">,
|
|
191
|
-
{ history, location }: RouteState,
|
|
192
|
-
config: { duration: number; easing?: (t: number) => number },
|
|
193
|
-
) => {
|
|
194
|
-
useEffect(() => {
|
|
195
|
-
if (history.current.type === "forward") {
|
|
196
|
-
void transUnit.start(transUnitRange[0], { immediate: true });
|
|
197
|
-
void transUnit.start(transUnitRange[1], { config });
|
|
198
|
-
} else void transUnit.start(transUnitRange[1], { immediate: true });
|
|
199
|
-
}, [location.entryId ?? location.pathname]);
|
|
200
|
-
};
|
|
201
|
-
|
|
202
|
-
const useNoneTrans = (routeState: RouteState): UseCsrTransition => {
|
|
203
|
-
const { clientHeight, location, prevLocation } = routeState;
|
|
204
|
-
const transUnit = useSpringValue(0, { config: { clamp: true } });
|
|
205
|
-
const transUnitRange = useMemo(() => [0, 0], []);
|
|
206
|
-
const pageState = location.pathRoute.pageState;
|
|
207
|
-
const prevPageState = prevLocation?.pathRoute.pageState ?? defaultPageState;
|
|
208
|
-
return {
|
|
209
|
-
topSafeArea: {
|
|
210
|
-
containerStyle: {
|
|
211
|
-
backgroundColor: pageState.topSafeAreaColor,
|
|
212
|
-
height: pageState.topSafeArea,
|
|
213
|
-
},
|
|
214
|
-
},
|
|
215
|
-
bottomSafeArea: {
|
|
216
|
-
containerStyle: {
|
|
217
|
-
backgroundColor: pageState.bottomSafeAreaColor,
|
|
218
|
-
top: clientHeight - pageState.bottomSafeArea,
|
|
219
|
-
height: pageState.bottomSafeArea,
|
|
220
|
-
},
|
|
221
|
-
},
|
|
222
|
-
page: {
|
|
223
|
-
containerStyle: {
|
|
224
|
-
top: 0,
|
|
225
|
-
left: 0,
|
|
226
|
-
height: clientHeight,
|
|
227
|
-
},
|
|
228
|
-
contentStyle: pageContentStyle(routeState, pageState),
|
|
229
|
-
},
|
|
230
|
-
prevPage: {
|
|
231
|
-
containerStyle: {
|
|
232
|
-
paddingTop: prevPageState.topSafeArea + prevPageState.topInset,
|
|
233
|
-
},
|
|
234
|
-
contentStyle: { opacity: 0 },
|
|
235
|
-
},
|
|
236
|
-
topInset: {
|
|
237
|
-
containerStyle: {
|
|
238
|
-
top: pageState.topSafeArea,
|
|
239
|
-
height: pageState.topInset,
|
|
240
|
-
},
|
|
241
|
-
contentStyle: { opacity: 1 },
|
|
242
|
-
prevContentStyle: { opacity: 0 },
|
|
243
|
-
},
|
|
244
|
-
topLeftAction: {
|
|
245
|
-
containerStyle: {
|
|
246
|
-
top: pageState.topSafeArea,
|
|
247
|
-
height: pageState.topInset,
|
|
248
|
-
},
|
|
249
|
-
contentStyle: { opacity: 1 },
|
|
250
|
-
prevContentStyle: { opacity: 0 },
|
|
251
|
-
},
|
|
252
|
-
bottomInset: {
|
|
253
|
-
containerStyle: {
|
|
254
|
-
height: pageState.bottomInset,
|
|
255
|
-
top: getBottomInsetTop(clientHeight, pageState),
|
|
256
|
-
},
|
|
257
|
-
contentStyle: { opacity: 1 },
|
|
258
|
-
prevContentStyle: { opacity: 0 },
|
|
259
|
-
},
|
|
260
|
-
pageBind: () => ({}),
|
|
261
|
-
pageClassName: "touch-pan-y",
|
|
262
|
-
transDirection: "none",
|
|
263
|
-
transUnitRange,
|
|
264
|
-
transUnit,
|
|
265
|
-
transProgress: transUnit.to(() => 1),
|
|
266
|
-
transPercent: transUnit.to(() => 100),
|
|
267
|
-
};
|
|
268
|
-
};
|
|
269
|
-
|
|
270
|
-
const useFadeTrans = (routeState: RouteState): UseCsrTransition => {
|
|
271
|
-
const { clientHeight, location, prevLocation, onBack } = routeState;
|
|
272
|
-
const spring = useFadeSpring();
|
|
273
|
-
const { transUnit, transUnitRange, transProgress } = spring;
|
|
274
|
-
const pageState = location.pathRoute.pageState;
|
|
275
|
-
const prevPageState = prevLocation?.pathRoute.pageState ?? defaultPageState;
|
|
276
|
-
const pageBottomInsetTop = getBottomInsetTop(clientHeight, pageState);
|
|
277
|
-
const prevBottomInsetTop = getBottomInsetTop(clientHeight, prevPageState);
|
|
278
|
-
|
|
279
|
-
useEffect(() => {
|
|
280
|
-
onBack.current.fade = async () => {
|
|
281
|
-
await transUnit.start(transUnitRange[0]);
|
|
282
|
-
};
|
|
283
|
-
}, []);
|
|
284
|
-
usePlayOnForward(spring, routeState, { duration: 150 });
|
|
285
|
-
|
|
286
|
-
return {
|
|
287
|
-
...tweenedSafeAreas(transProgress, clientHeight, pageState, prevPageState),
|
|
288
|
-
page: {
|
|
289
|
-
containerStyle: {},
|
|
290
|
-
contentStyle: { ...pageContentStyle(routeState, pageState), opacity: transUnit },
|
|
291
|
-
},
|
|
292
|
-
prevPage: {
|
|
293
|
-
containerStyle: {
|
|
294
|
-
opacity: transProgress.to((progress) => 1 - progress),
|
|
295
|
-
},
|
|
296
|
-
contentStyle: prevPageContentStyle(clientHeight, prevPageState),
|
|
297
|
-
},
|
|
298
|
-
topInset: {
|
|
299
|
-
containerStyle: tweenedTopInset(transProgress, pageState, prevPageState),
|
|
300
|
-
contentStyle: { opacity: transProgress },
|
|
301
|
-
prevContentStyle: fadeOut(transProgress),
|
|
302
|
-
},
|
|
303
|
-
topLeftAction: {
|
|
304
|
-
containerStyle: tweenedTopInset(transProgress, pageState, prevPageState),
|
|
305
|
-
contentStyle: {
|
|
306
|
-
top: tween(transProgress, 0, -(pageState.bottomInset - prevPageState.bottomInset) * 2),
|
|
307
|
-
...fadeIn(transProgress),
|
|
308
|
-
},
|
|
309
|
-
prevContentStyle: {
|
|
310
|
-
top: tween(transProgress, 0, -(pageState.bottomInset - prevPageState.bottomInset) * 2),
|
|
311
|
-
...fadeOut(transProgress),
|
|
312
|
-
},
|
|
313
|
-
},
|
|
314
|
-
bottomInset: {
|
|
315
|
-
containerStyle: tweenedBottomInset(transProgress, clientHeight, pageState, prevPageState),
|
|
316
|
-
contentStyle: {
|
|
317
|
-
height: pageState.bottomInset,
|
|
318
|
-
translateY: transProgress.to((progress) =>
|
|
319
|
-
getFrameContentOffset(pageBottomInsetTop, prevBottomInsetTop, pageBottomInsetTop, progress),
|
|
320
|
-
),
|
|
321
|
-
...fadeIn(transProgress),
|
|
322
|
-
transformOrigin: "top",
|
|
323
|
-
},
|
|
324
|
-
prevContentStyle: {
|
|
325
|
-
height: prevPageState.bottomInset,
|
|
326
|
-
translateY: transProgress.to((progress) =>
|
|
327
|
-
getFrameContentOffset(prevBottomInsetTop, prevBottomInsetTop, pageBottomInsetTop, progress),
|
|
328
|
-
),
|
|
329
|
-
...fadeOut(transProgress),
|
|
330
|
-
transformOrigin: "top",
|
|
331
|
-
},
|
|
332
|
-
},
|
|
333
|
-
pageBind: () => ({}),
|
|
334
|
-
pageClassName: "",
|
|
335
|
-
transDirection: "none",
|
|
336
|
-
...spring,
|
|
337
|
-
};
|
|
338
|
-
};
|
|
339
|
-
|
|
340
|
-
const useScaleOutTrans = (routeState: RouteState): UseCsrTransition => {
|
|
341
|
-
const { clientHeight, location, prevLocation, onBack } = routeState;
|
|
342
|
-
const spring = useFadeSpring();
|
|
343
|
-
const { transUnit, transUnitRange, transProgress } = spring;
|
|
344
|
-
const pageState = location.pathRoute.pageState;
|
|
345
|
-
const prevPageState = prevLocation?.pathRoute.pageState ?? defaultPageState;
|
|
346
|
-
|
|
347
|
-
useEffect(() => {
|
|
348
|
-
onBack.current.scaleOut = async () => {
|
|
349
|
-
await transUnit.start(transUnitRange[0], { config: { duration: ANDROID_SCALE_TRANSITION_DURATION } });
|
|
350
|
-
};
|
|
351
|
-
}, []);
|
|
352
|
-
usePlayOnForward(spring, routeState, { duration: ANDROID_SCALE_TRANSITION_DURATION });
|
|
353
|
-
|
|
354
|
-
return {
|
|
355
|
-
...tweenedSafeAreas(transProgress, clientHeight, pageState, prevPageState),
|
|
356
|
-
page: {
|
|
357
|
-
containerStyle: {
|
|
358
|
-
transform: transProgress.to((progress) => `scale(${0.92 + progress * 0.08})`),
|
|
359
|
-
},
|
|
360
|
-
contentStyle: { ...pageContentStyle(routeState, pageState), opacity: transProgress },
|
|
361
|
-
},
|
|
362
|
-
prevPage: {
|
|
363
|
-
containerStyle: {
|
|
364
|
-
transform: transProgress.to((progress) => `scale(${1 - progress * 0.02})`),
|
|
365
|
-
},
|
|
366
|
-
contentStyle: {
|
|
367
|
-
...prevPageContentStyle(clientHeight, prevPageState),
|
|
368
|
-
opacity: transProgress.to((progress) => 1 - progress * 0.35),
|
|
369
|
-
},
|
|
370
|
-
},
|
|
371
|
-
topInset: {
|
|
372
|
-
containerStyle: tweenedTopInset(transProgress, pageState, prevPageState),
|
|
373
|
-
contentStyle: { opacity: transProgress },
|
|
374
|
-
prevContentStyle: fadeOut(transProgress),
|
|
375
|
-
},
|
|
376
|
-
topLeftAction: {
|
|
377
|
-
containerStyle: tweenedTopInset(transProgress, pageState, prevPageState),
|
|
378
|
-
contentStyle: { opacity: transProgress },
|
|
379
|
-
prevContentStyle: fadeOut(transProgress),
|
|
380
|
-
},
|
|
381
|
-
bottomInset: {
|
|
382
|
-
containerStyle: tweenedBottomInset(transProgress, clientHeight, pageState, prevPageState),
|
|
383
|
-
contentStyle: { opacity: transProgress },
|
|
384
|
-
prevContentStyle: fadeOut(transProgress),
|
|
385
|
-
},
|
|
386
|
-
pageBind: () => ({}),
|
|
387
|
-
pageClassName: "",
|
|
388
|
-
transDirection: "none",
|
|
389
|
-
...spring,
|
|
390
|
-
};
|
|
391
|
-
};
|
|
392
|
-
|
|
393
|
-
const useStackTrans = (routeState: RouteState): UseCsrTransition => {
|
|
394
|
-
const { clientWidth, clientHeight, location, prevLocation, onBack, pageContentRef } = routeState;
|
|
395
|
-
const spring = useSlideSpring(clientWidth);
|
|
396
|
-
const { transUnit, transUnitRange, transProgress } = spring;
|
|
397
|
-
const initThreshold = useMemo(() => Math.floor(clientWidth), [clientWidth]);
|
|
398
|
-
const threshold = useMemo(() => Math.floor(clientWidth / 3), [clientWidth]);
|
|
399
|
-
const pageState = location.pathRoute.pageState;
|
|
400
|
-
const prevPageState = prevLocation?.pathRoute.pageState ?? defaultPageState;
|
|
401
|
-
const gestureIntent = useRef<GestureIntent>("pending");
|
|
402
|
-
const scrollLockRef = useRef<{ overflowY: string; touchAction: string } | null>(null);
|
|
403
|
-
const stackBackConfigRef = useRef<{ duration: number } | null>(null);
|
|
404
|
-
const lockPageScroll = useCallback(() => {
|
|
405
|
-
const pageContent = pageContentRef.current;
|
|
406
|
-
if (!pageContent || scrollLockRef.current) return;
|
|
407
|
-
scrollLockRef.current = {
|
|
408
|
-
overflowY: pageContent.style.overflowY,
|
|
409
|
-
touchAction: pageContent.style.touchAction,
|
|
410
|
-
};
|
|
411
|
-
pageContent.style.overflowY = "hidden";
|
|
412
|
-
pageContent.style.touchAction = "none";
|
|
413
|
-
}, [pageContentRef]);
|
|
414
|
-
const unlockPageScroll = useCallback(() => {
|
|
415
|
-
const pageContent = pageContentRef.current;
|
|
416
|
-
const scrollLock = scrollLockRef.current;
|
|
417
|
-
if (!pageContent || !scrollLock) return;
|
|
418
|
-
pageContent.style.overflowY = scrollLock.overflowY;
|
|
419
|
-
pageContent.style.touchAction = scrollLock.touchAction;
|
|
420
|
-
scrollLockRef.current = null;
|
|
421
|
-
}, [pageContentRef]);
|
|
422
|
-
useEffect(() => {
|
|
423
|
-
onBack.current.stack = async () => {
|
|
424
|
-
const config = stackBackConfigRef.current;
|
|
425
|
-
stackBackConfigRef.current = null;
|
|
426
|
-
await transUnit.start(transUnitRange[0], config ? { config } : undefined);
|
|
427
|
-
};
|
|
428
|
-
}, [transUnitRange]);
|
|
429
|
-
useEffect(() => unlockPageScroll, [unlockPageScroll]);
|
|
430
|
-
usePlayOnForward(spring, routeState, { duration: 150 });
|
|
431
|
-
|
|
432
|
-
const pageBind = useDrag(
|
|
433
|
-
({ first, last, movement: [mx, my], velocity: [vx], direction: [dx], initial: [ix], cancel }) => {
|
|
434
|
-
if (first) {
|
|
435
|
-
gestureIntent.current = "pending";
|
|
436
|
-
stackBackConfigRef.current = null;
|
|
437
|
-
unlockPageScroll();
|
|
438
|
-
}
|
|
439
|
-
if (ix > initThreshold) {
|
|
440
|
-
gestureIntent.current = "scroll";
|
|
441
|
-
cancel();
|
|
442
|
-
return;
|
|
443
|
-
}
|
|
444
|
-
if (gestureIntent.current === "pending") {
|
|
445
|
-
const absX = Math.abs(mx);
|
|
446
|
-
const absY = Math.abs(my);
|
|
447
|
-
if (absY >= GESTURE_INTENT_THRESHOLD && absY > absX * GESTURE_AXIS_LOCK_RATIO) {
|
|
448
|
-
gestureIntent.current = "scroll";
|
|
449
|
-
void transUnit.start(transUnitRange[1], { immediate: true });
|
|
450
|
-
cancel();
|
|
451
|
-
return;
|
|
452
|
-
}
|
|
453
|
-
if (absX < GESTURE_INTENT_THRESHOLD || absX <= absY * GESTURE_AXIS_LOCK_RATIO) return;
|
|
454
|
-
gestureIntent.current = "gesture";
|
|
455
|
-
lockPageScroll();
|
|
456
|
-
void Device.getDevice().hideKeyboard();
|
|
457
|
-
}
|
|
458
|
-
if (gestureIntent.current !== "gesture") {
|
|
459
|
-
cancel();
|
|
460
|
-
return;
|
|
461
|
-
}
|
|
462
|
-
if (mx < transUnitRange[1]) void transUnit.start(transUnitRange[1], { immediate: true });
|
|
463
|
-
else if (mx > transUnitRange[0]) void transUnit.start(transUnitRange[0], { immediate: true });
|
|
464
|
-
else if (!last) void transUnit.start(mx, { immediate: true });
|
|
465
|
-
if (last) {
|
|
466
|
-
const shouldComplete = mx > threshold || (dx > 0 && vx > STACK_VELOCITY_DISMISS_THRESHOLD);
|
|
467
|
-
const target = shouldComplete ? transUnitRange[0] : transUnitRange[1];
|
|
468
|
-
const duration = getVelocityAwareDuration(target - mx, vx, shouldComplete ? 150 : 180);
|
|
469
|
-
if (shouldComplete) stackBackConfigRef.current = { duration };
|
|
470
|
-
else void transUnit.start(transUnitRange[1], { config: { duration } });
|
|
471
|
-
unlockPageScroll();
|
|
472
|
-
gestureIntent.current = "pending";
|
|
473
|
-
if (!shouldComplete) return;
|
|
474
|
-
clientRouter.back();
|
|
475
|
-
void clientRouter.navigation().catch(() => {
|
|
476
|
-
stackBackConfigRef.current = null;
|
|
477
|
-
void transUnit.start(transUnitRange[1], { config: { duration } });
|
|
478
|
-
});
|
|
479
|
-
}
|
|
480
|
-
},
|
|
481
|
-
{ filterTaps: true },
|
|
482
|
-
);
|
|
483
|
-
|
|
484
|
-
return {
|
|
485
|
-
...tweenedSafeAreas(transProgress, clientHeight, pageState, prevPageState),
|
|
486
|
-
page: {
|
|
487
|
-
containerStyle: {},
|
|
488
|
-
contentStyle: { ...pageContentStyle(routeState, pageState), translateX: transUnit },
|
|
489
|
-
},
|
|
490
|
-
prevPage: {
|
|
491
|
-
containerStyle: {
|
|
492
|
-
top: 0,
|
|
493
|
-
left: 0,
|
|
494
|
-
height: clientHeight,
|
|
495
|
-
translateX: transUnit.to((unit) => (unit - clientWidth) / 5),
|
|
496
|
-
},
|
|
497
|
-
contentStyle: {
|
|
498
|
-
...prevPageContentStyle(clientHeight, prevPageState),
|
|
499
|
-
opacity: transProgress.to((progress) => 1 - progress / 2),
|
|
500
|
-
},
|
|
501
|
-
},
|
|
502
|
-
topInset: {
|
|
503
|
-
containerStyle: tweenedTopInset(transProgress, pageState, prevPageState),
|
|
504
|
-
contentStyle: { ...fadeIn(transProgress), translateX: tween(transProgress, clientWidth / 5, 0) },
|
|
505
|
-
prevContentStyle: { ...fadeOut(transProgress), translateX: tween(transProgress, 0, -clientWidth / 5) },
|
|
506
|
-
},
|
|
507
|
-
topLeftAction: {
|
|
508
|
-
containerStyle: {
|
|
509
|
-
...tweenedTopInset(transProgress, pageState, prevPageState),
|
|
510
|
-
minWidth: tween(transProgress, prevPageState.topInset, pageState.topInset),
|
|
511
|
-
},
|
|
512
|
-
contentStyle: fadeIn(transProgress),
|
|
513
|
-
prevContentStyle: fadeOut(transProgress),
|
|
514
|
-
},
|
|
515
|
-
bottomInset: {
|
|
516
|
-
containerStyle: tweenedBottomInset(transProgress, clientHeight, pageState, prevPageState),
|
|
517
|
-
contentStyle: { height: pageState.bottomInset, translateX: transUnit, ...fadeIn(transProgress) },
|
|
518
|
-
prevContentStyle: {
|
|
519
|
-
height: prevPageState.bottomInset,
|
|
520
|
-
translateX: transUnit.to((unit) => (unit - clientWidth) / 5),
|
|
521
|
-
...fadeOut(transProgress),
|
|
522
|
-
},
|
|
523
|
-
},
|
|
524
|
-
pageBind,
|
|
525
|
-
pageClassName: "touch-pan-y",
|
|
526
|
-
transDirection: "horizontal",
|
|
527
|
-
...spring,
|
|
528
|
-
};
|
|
529
|
-
};
|
|
530
|
-
|
|
531
|
-
const useBottomUpTrans = (routeState: RouteState): UseCsrTransition => {
|
|
532
|
-
const { clientHeight, location, prevLocation, onBack } = routeState;
|
|
533
|
-
const spring = useSlideSpring(clientHeight);
|
|
534
|
-
const { transUnit, transUnitRange, transProgress } = spring;
|
|
535
|
-
const initThreshold = useMemo(() => Math.floor(clientHeight / 3), [clientHeight]);
|
|
536
|
-
const threshold = useMemo(() => Math.floor(clientHeight / 2), [clientHeight]);
|
|
537
|
-
const pageState = location.pathRoute.pageState;
|
|
538
|
-
const prevPageState = prevLocation?.pathRoute.pageState ?? defaultPageState;
|
|
539
|
-
useEffect(() => {
|
|
540
|
-
onBack.current.bottomUp = async () => {
|
|
541
|
-
await transUnit.start(transUnitRange[0], { config: { duration: 220, easing: linearEasing } });
|
|
542
|
-
};
|
|
543
|
-
}, [transUnitRange]);
|
|
544
|
-
usePlayOnForward(spring, routeState, { duration: 220, easing: linearEasing });
|
|
545
|
-
|
|
546
|
-
const pageBind = useDrag(
|
|
547
|
-
({ first, last, movement: [, my], initial: [, iy], cancel }) => {
|
|
548
|
-
if (iy > initThreshold) {
|
|
549
|
-
cancel();
|
|
550
|
-
return;
|
|
551
|
-
}
|
|
552
|
-
if (first) void Device.getDevice().hideKeyboard();
|
|
553
|
-
if (my < transUnitRange[1]) void transUnit.start(transUnitRange[1], { immediate: true });
|
|
554
|
-
else if (my > transUnitRange[0]) void transUnit.start(transUnitRange[0], { immediate: true });
|
|
555
|
-
else if (!last) void transUnit.start(my, { immediate: true });
|
|
556
|
-
else if (my < threshold) void transUnit.start(transUnitRange[1]);
|
|
557
|
-
if (!last || my <= threshold) return;
|
|
558
|
-
clientRouter.back();
|
|
559
|
-
void clientRouter.navigation().catch(() => transUnit.start(transUnitRange[1]));
|
|
560
|
-
},
|
|
561
|
-
{ axis: "y", filterTaps: true, threshold: 10 },
|
|
562
|
-
);
|
|
563
|
-
|
|
564
|
-
return {
|
|
565
|
-
...tweenedSafeAreas(transProgress, clientHeight, pageState, prevPageState),
|
|
566
|
-
page: {
|
|
567
|
-
containerStyle: {},
|
|
568
|
-
contentStyle: { ...pageContentStyle(routeState, pageState), translateY: transUnit },
|
|
569
|
-
},
|
|
570
|
-
prevPage: {
|
|
571
|
-
containerStyle: {
|
|
572
|
-
translateY: 0,
|
|
573
|
-
},
|
|
574
|
-
contentStyle: {
|
|
575
|
-
...prevPageContentStyle(clientHeight, prevPageState),
|
|
576
|
-
opacity: transProgress.to((progress) => 1 - progress / 2),
|
|
577
|
-
},
|
|
578
|
-
},
|
|
579
|
-
topInset: {
|
|
580
|
-
containerStyle: tweenedTopInset(transProgress, pageState, prevPageState),
|
|
581
|
-
contentStyle: fadeIn(transProgress),
|
|
582
|
-
prevContentStyle: fadeOut(transProgress),
|
|
583
|
-
},
|
|
584
|
-
topLeftAction: {
|
|
585
|
-
containerStyle: tweenedTopInset(transProgress, pageState, prevPageState),
|
|
586
|
-
contentStyle: fadeIn(transProgress),
|
|
587
|
-
prevContentStyle: fadeOut(transProgress),
|
|
588
|
-
},
|
|
589
|
-
bottomInset: {
|
|
590
|
-
containerStyle: tweenedBottomInset(transProgress, clientHeight, pageState, prevPageState),
|
|
591
|
-
contentStyle: fadeIn(transProgress),
|
|
592
|
-
prevContentStyle: fadeOut(transProgress),
|
|
593
|
-
},
|
|
594
|
-
pageBind,
|
|
595
|
-
pageClassName: "touch-pan-x",
|
|
596
|
-
transDirection: "vertical",
|
|
597
|
-
...spring,
|
|
598
|
-
};
|
|
599
|
-
};
|
|
600
|
-
|
|
601
|
-
export const useCsrValues = (rootRouteGuide: RouteGuide, pathRoutes: PathRoute[]) => {
|
|
602
|
-
const { viewport, updateViewport } = useFrameViewport();
|
|
603
|
-
const { frameSlots, pendingFrameSlots, registerFrameSlot, promotePendingSlots, clearPendingSlots } = useFrameSlots();
|
|
604
|
-
const [transitionPageStateSnapshot, setTransitionPageStateSnapshot] = useState<Map<string, PageState> | null>(null);
|
|
605
|
-
const pageStateByPathRef = useRef(new Map<string, PageState>());
|
|
606
|
-
const navigationIntentId = useRef(0);
|
|
607
|
-
const transitionPlanId = useRef(0);
|
|
608
|
-
const navigationLocked = useRef(false);
|
|
609
|
-
const pendingNavigation = useRef<NavigationIntent | null>(null);
|
|
610
|
-
const waitingNavigation = useRef<{ kind: "push" | "replace"; href: string; scrollToTop?: boolean } | null>(null);
|
|
611
|
-
const renderCountRef = useRef(0);
|
|
612
|
-
const basePageStateMap = useRef(new WeakMap<PathRoute, PathRoute["pageState"]>());
|
|
613
|
-
const topSafeAreaRef = useRef<HTMLDivElement>(null);
|
|
614
|
-
const bottomSafeAreaRef = useRef<HTMLDivElement>(null);
|
|
615
|
-
const pageContentRef = useRef<HTMLDivElement>(null);
|
|
616
|
-
const prevPageContentRef = useRef<HTMLDivElement>(null);
|
|
617
|
-
const onBack = useRef<{ [K in TransitionType]?: () => Promise<void> }>({});
|
|
618
|
-
const frameRootRef = useRef<HTMLDivElement>(null);
|
|
619
|
-
const lastBroadcastSyncHref = useRef<string | null>(null);
|
|
620
|
-
const syncNavigationReset = useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
621
|
-
|
|
622
|
-
const { getLocation } = useLocation({ rootRouteGuide });
|
|
623
|
-
const [initialStack] = useState(() => {
|
|
624
|
-
const current = getLocation(csrLocation.href);
|
|
625
|
-
return CsrStack.restore(current, getLocation) ?? { locations: [current], idx: 0 };
|
|
626
|
-
});
|
|
627
|
-
const {
|
|
628
|
-
history,
|
|
629
|
-
setHistoryForward,
|
|
630
|
-
setHistoryBack,
|
|
631
|
-
setHistoryJump,
|
|
632
|
-
getNextLocation,
|
|
633
|
-
getCurrentLocation,
|
|
634
|
-
getPrevLocation,
|
|
635
|
-
getScrollTop,
|
|
636
|
-
} = useHistory(initialStack.locations, initialStack);
|
|
637
|
-
history.current.account ??= { token: getAuthToken() ?? null, generation: 0 };
|
|
638
|
-
const [isBackgrounded, setIsBackgrounded] = useState(() => document.visibilityState === "hidden");
|
|
639
|
-
const [locationState, setLocationState] = useState<LocationState>({
|
|
640
|
-
location: getCurrentLocation(),
|
|
641
|
-
prevLocation: getPrevLocation(),
|
|
642
|
-
pendingLocation: null,
|
|
643
|
-
navigationIntent: null,
|
|
644
|
-
phase: "idle",
|
|
645
|
-
});
|
|
646
|
-
const { location, prevLocation } = locationState;
|
|
647
|
-
const pendingLocation = locationState.pendingLocation ?? null;
|
|
648
|
-
const navigationIntent = locationState.navigationIntent ?? null;
|
|
649
|
-
const phase = locationState.phase ?? "idle";
|
|
650
|
-
const pageStateByPath = useMemo(
|
|
651
|
-
() =>
|
|
652
|
-
resolveFramePageStateMap({
|
|
653
|
-
pathRoutes,
|
|
654
|
-
frameSlots,
|
|
655
|
-
pendingFrameSlots,
|
|
656
|
-
pendingPath: pendingLocation?.pathRoute.path,
|
|
657
|
-
visiblePaths: [
|
|
658
|
-
location.pathRoute.path,
|
|
659
|
-
...(prevLocation ? [prevLocation.pathRoute.path] : []),
|
|
660
|
-
...(pendingLocation ? [pendingLocation.pathRoute.path] : []),
|
|
661
|
-
],
|
|
662
|
-
basePageStateMap: basePageStateMap.current,
|
|
663
|
-
}),
|
|
664
|
-
[
|
|
665
|
-
pathRoutes,
|
|
666
|
-
frameSlots,
|
|
667
|
-
pendingFrameSlots,
|
|
668
|
-
pendingLocation?.pathRoute.path,
|
|
669
|
-
location.pathRoute.path,
|
|
670
|
-
prevLocation?.pathRoute.path,
|
|
671
|
-
],
|
|
672
|
-
);
|
|
673
|
-
useEffect(() => {
|
|
674
|
-
if (!transitionPageStateSnapshot) pageStateByPathRef.current = pageStateByPath;
|
|
675
|
-
}, [pageStateByPath, transitionPageStateSnapshot]);
|
|
676
|
-
const latestPageStateByPath = useRef(pageStateByPath);
|
|
677
|
-
const latestFrameSlots = useRef(frameSlots);
|
|
678
|
-
const latestPendingFrameSlots = useRef(pendingFrameSlots);
|
|
679
|
-
useEffect(() => {
|
|
680
|
-
latestPageStateByPath.current = pageStateByPath;
|
|
681
|
-
latestFrameSlots.current = frameSlots;
|
|
682
|
-
latestPendingFrameSlots.current = pendingFrameSlots;
|
|
683
|
-
}, [pageStateByPath, frameSlots, pendingFrameSlots]);
|
|
684
|
-
if (pageStateByPathRef.current.size === 0) pageStateByPathRef.current = pageStateByPath;
|
|
685
|
-
const effectivePageStateByPath = transitionPageStateSnapshot ?? pageStateByPath;
|
|
686
|
-
const resolvedPathRoutes = useMemo(
|
|
687
|
-
() => resolvePathRoutesWithFrameState(pathRoutes, effectivePageStateByPath),
|
|
688
|
-
[pathRoutes, effectivePageStateByPath],
|
|
689
|
-
);
|
|
690
|
-
const resolvedPathRouteMap = useMemo(
|
|
691
|
-
() => new Map(resolvedPathRoutes.map((pathRoute) => [pathRoute.path, pathRoute])),
|
|
692
|
-
[resolvedPathRoutes],
|
|
693
|
-
);
|
|
694
|
-
const resolvedLocation = resolveLocationWithFrameState(location, resolvedPathRouteMap) ?? location;
|
|
695
|
-
const resolvedPrevLocation = resolveLocationWithFrameState(prevLocation, resolvedPathRouteMap);
|
|
696
|
-
const resolvedPendingLocation = resolveLocationWithFrameState(pendingLocation, resolvedPathRouteMap);
|
|
697
|
-
const stackEntries = CsrStack.entriesOf({
|
|
698
|
-
history: history.current,
|
|
699
|
-
location,
|
|
700
|
-
prevLocation,
|
|
701
|
-
pendingLocation,
|
|
702
|
-
phase,
|
|
703
|
-
}).map((entry) => ({
|
|
704
|
-
...entry,
|
|
705
|
-
location: resolveLocationWithFrameState(entry.location, resolvedPathRouteMap) ?? entry.location,
|
|
706
|
-
}));
|
|
707
|
-
const frameDumpRef = useRef({ phase, location, prevLocation, pendingLocation, stackEntries });
|
|
708
|
-
frameDumpRef.current = { phase, location, prevLocation, pendingLocation, stackEntries };
|
|
709
|
-
useEffect(() => {
|
|
710
|
-
CsrFrameDump.watchFrame(() => {
|
|
711
|
-
const frame = frameDumpRef.current;
|
|
712
|
-
return {
|
|
713
|
-
phase: frame.phase,
|
|
714
|
-
location: frame.location.href,
|
|
715
|
-
prevLocation: frame.prevLocation?.href ?? null,
|
|
716
|
-
pendingLocation: frame.pendingLocation?.href ?? null,
|
|
717
|
-
stack: frame.stackEntries.map(({ key, location: entry, pageType }) => ({
|
|
718
|
-
key,
|
|
719
|
-
path: entry.pathRoute.path,
|
|
720
|
-
pageType,
|
|
721
|
-
})),
|
|
722
|
-
};
|
|
723
|
-
});
|
|
724
|
-
}, []);
|
|
725
|
-
const platformProfile = getFramePlatformProfile();
|
|
726
|
-
const accessoryHeight = resolveKeyboardAccessoryHeight(resolvedLocation.pathRoute.path, frameSlots);
|
|
727
|
-
const shouldAnchorContentBottom = hasBottomAnchoredKeyboardSlot(resolvedLocation.pathRoute.path, frameSlots);
|
|
728
|
-
const keyboardFrame = useKeyboardFrame({
|
|
729
|
-
bottomSafeArea: resolvedLocation.pathRoute.pageState.bottomSafeArea,
|
|
730
|
-
sticky: hasKeyboardStickySlot(resolvedLocation.pathRoute.path, frameSlots),
|
|
731
|
-
viewport,
|
|
732
|
-
platformProfile,
|
|
733
|
-
freeze: phase === "transitioning",
|
|
734
|
-
});
|
|
735
|
-
const keyboardLayout = useMemo(
|
|
736
|
-
() =>
|
|
737
|
-
resolveKeyboardLayout({
|
|
738
|
-
viewport,
|
|
739
|
-
keyboard: keyboardFrame,
|
|
740
|
-
accessoryHeight,
|
|
741
|
-
bottomSafeArea: resolvedLocation.pathRoute.pageState.bottomSafeArea,
|
|
742
|
-
}),
|
|
743
|
-
[viewport, keyboardFrame, accessoryHeight, resolvedLocation.pathRoute.pageState.bottomSafeArea],
|
|
744
|
-
);
|
|
745
|
-
const contentBottomAnchorRef = useRef<{
|
|
746
|
-
path: string;
|
|
747
|
-
contentViewportHeight: number;
|
|
748
|
-
bottomDistance: number;
|
|
749
|
-
} | null>(null);
|
|
750
|
-
const contentBottomAnchorRafRef = useRef<number | null>(null);
|
|
751
|
-
useLayoutEffect(() => {
|
|
752
|
-
const element = pageContentRef.current;
|
|
753
|
-
const path = resolvedLocation.pathRoute.path;
|
|
754
|
-
if (!element || !shouldAnchorContentBottom || !keyboardFrame.sticky) {
|
|
755
|
-
contentBottomAnchorRef.current = null;
|
|
756
|
-
if (contentBottomAnchorRafRef.current !== null) {
|
|
757
|
-
cancelAnimationFrame(contentBottomAnchorRafRef.current);
|
|
758
|
-
contentBottomAnchorRafRef.current = null;
|
|
759
|
-
}
|
|
760
|
-
return;
|
|
761
|
-
}
|
|
762
|
-
|
|
763
|
-
const previous = contentBottomAnchorRef.current;
|
|
764
|
-
const currentBottomDistance = Math.max(0, element.scrollHeight - element.scrollTop - element.clientHeight);
|
|
765
|
-
if (!previous || previous.path !== path) {
|
|
766
|
-
contentBottomAnchorRef.current = {
|
|
767
|
-
path,
|
|
768
|
-
contentViewportHeight: keyboardLayout.contentViewport.height,
|
|
769
|
-
bottomDistance: currentBottomDistance,
|
|
770
|
-
};
|
|
771
|
-
return;
|
|
772
|
-
}
|
|
773
|
-
|
|
774
|
-
const shouldRestoreBottom = previous.contentViewportHeight !== keyboardLayout.contentViewport.height;
|
|
775
|
-
const bottomDistance = previous.bottomDistance;
|
|
776
|
-
if (shouldRestoreBottom) {
|
|
777
|
-
const nextScrollTop = Math.max(0, element.scrollHeight - element.clientHeight - bottomDistance);
|
|
778
|
-
if (Math.abs(element.scrollTop - nextScrollTop) > 1) {
|
|
779
|
-
debugFrame("keyboard.contentAnchor", {
|
|
780
|
-
path,
|
|
781
|
-
from: element.scrollTop,
|
|
782
|
-
to: nextScrollTop,
|
|
783
|
-
bottomDistance,
|
|
784
|
-
contentViewportHeight: keyboardLayout.contentViewport.height,
|
|
785
|
-
});
|
|
786
|
-
element.scrollTop = nextScrollTop;
|
|
787
|
-
}
|
|
788
|
-
const startedAt = performance.now();
|
|
789
|
-
const duration = (keyboardFrame.animationDuration ?? 0) + 50;
|
|
790
|
-
const keepBottomAnchored = () => {
|
|
791
|
-
const scrollTop = Math.max(0, element.scrollHeight - element.clientHeight - bottomDistance);
|
|
792
|
-
if (Math.abs(element.scrollTop - scrollTop) > 1) element.scrollTop = scrollTop;
|
|
793
|
-
if (performance.now() - startedAt < duration) {
|
|
794
|
-
contentBottomAnchorRafRef.current = requestAnimationFrame(keepBottomAnchored);
|
|
795
|
-
} else {
|
|
796
|
-
contentBottomAnchorRafRef.current = null;
|
|
797
|
-
}
|
|
798
|
-
};
|
|
799
|
-
if (contentBottomAnchorRafRef.current !== null) cancelAnimationFrame(contentBottomAnchorRafRef.current);
|
|
800
|
-
contentBottomAnchorRafRef.current = requestAnimationFrame(keepBottomAnchored);
|
|
801
|
-
}
|
|
802
|
-
|
|
803
|
-
contentBottomAnchorRef.current = {
|
|
804
|
-
path,
|
|
805
|
-
contentViewportHeight: keyboardLayout.contentViewport.height,
|
|
806
|
-
bottomDistance: Math.max(0, element.scrollHeight - element.scrollTop - element.clientHeight),
|
|
807
|
-
};
|
|
808
|
-
return () => {
|
|
809
|
-
if (contentBottomAnchorRafRef.current !== null) {
|
|
810
|
-
cancelAnimationFrame(contentBottomAnchorRafRef.current);
|
|
811
|
-
contentBottomAnchorRafRef.current = null;
|
|
812
|
-
}
|
|
813
|
-
};
|
|
814
|
-
}, [
|
|
815
|
-
pageContentRef,
|
|
816
|
-
resolvedLocation.pathRoute.path,
|
|
817
|
-
shouldAnchorContentBottom,
|
|
818
|
-
keyboardFrame.sticky,
|
|
819
|
-
keyboardFrame.animationDuration,
|
|
820
|
-
keyboardLayout.contentViewport.height,
|
|
821
|
-
]);
|
|
822
|
-
useEffect(() => {
|
|
823
|
-
const element = pageContentRef.current;
|
|
824
|
-
const path = resolvedLocation.pathRoute.path;
|
|
825
|
-
if (!element || !shouldAnchorContentBottom || !keyboardFrame.sticky) return;
|
|
826
|
-
const updateBottomDistance = () => {
|
|
827
|
-
contentBottomAnchorRef.current = {
|
|
828
|
-
path,
|
|
829
|
-
contentViewportHeight: keyboardLayout.contentViewport.height,
|
|
830
|
-
bottomDistance: Math.max(0, element.scrollHeight - element.scrollTop - element.clientHeight),
|
|
831
|
-
};
|
|
832
|
-
};
|
|
833
|
-
element.addEventListener("scroll", updateBottomDistance, { passive: true });
|
|
834
|
-
return () => element.removeEventListener("scroll", updateBottomDistance);
|
|
835
|
-
}, [
|
|
836
|
-
pageContentRef,
|
|
837
|
-
resolvedLocation.pathRoute.path,
|
|
838
|
-
shouldAnchorContentBottom,
|
|
839
|
-
keyboardFrame.sticky,
|
|
840
|
-
keyboardLayout.contentViewport.height,
|
|
841
|
-
]);
|
|
842
|
-
useFrameRuntimeResync({ updateViewport });
|
|
843
|
-
const shouldPrepareFrameTransition = useCallback(
|
|
844
|
-
(nextHref?: string) => {
|
|
845
|
-
if (keyboardFrame.visible) return true;
|
|
846
|
-
if (!nextHref) return resolvedLocation.pathRoute.pageState.transition !== "none";
|
|
847
|
-
const nextLocation = getLocation(nextHref);
|
|
848
|
-
return (
|
|
849
|
-
resolvedLocation.pathRoute.pageState.transition !== "none" ||
|
|
850
|
-
nextLocation.pathRoute.pageState.transition !== "none"
|
|
851
|
-
);
|
|
852
|
-
},
|
|
853
|
-
[getLocation, keyboardFrame.visible, resolvedLocation.pathRoute.pageState.transition],
|
|
854
|
-
);
|
|
855
|
-
const startFrameTransition = useCallback(async () => {
|
|
856
|
-
const snapshot = new Map(pageStateByPathRef.current);
|
|
857
|
-
setTransitionPageStateSnapshot(snapshot);
|
|
858
|
-
window.setTimeout(() => setTransitionPageStateSnapshot(null), 360);
|
|
859
|
-
await prepareForFrameTransition();
|
|
860
|
-
}, []);
|
|
861
|
-
const settle = (prev: LocationState["prevLocation"]) =>
|
|
862
|
-
setLocationState({
|
|
863
|
-
location: getCurrentLocation(),
|
|
864
|
-
prevLocation: prev,
|
|
865
|
-
pendingLocation: null,
|
|
866
|
-
navigationIntent: null,
|
|
867
|
-
phase: "idle",
|
|
868
|
-
});
|
|
869
|
-
|
|
870
|
-
const cancelPendingNavigation = useCallback(() => {
|
|
871
|
-
const pending = pendingNavigation.current;
|
|
872
|
-
if (!pending) return null;
|
|
873
|
-
pendingNavigation.current = null;
|
|
874
|
-
navigationLocked.current = false;
|
|
875
|
-
clearPendingSlots();
|
|
876
|
-
debugFrame("navigation.cancel", { reason: "superseded", id: pending.id, to: pending.to.href });
|
|
877
|
-
setLocationState((current) => ({ ...current, pendingLocation: null, navigationIntent: null, phase: "idle" }));
|
|
878
|
-
return pending;
|
|
879
|
-
}, [clearPendingSlots]);
|
|
880
|
-
const applyingSyncNavigation = useRef(false);
|
|
881
|
-
const broadcastSyncNavigation = useCallback((kind: "push" | "replace" | "back" | "pop", href: string) => {
|
|
882
|
-
if (applyingSyncNavigation.current || lastBroadcastSyncHref.current === href) return;
|
|
883
|
-
lastBroadcastSyncHref.current = href;
|
|
884
|
-
const syncNavigation = (
|
|
885
|
-
globalThis as typeof globalThis & {
|
|
886
|
-
__AKAN_DEV_SYNC_NAVIGATION__?: (href: string, kind: "push" | "replace" | "back" | "pop") => void;
|
|
887
|
-
}
|
|
888
|
-
).__AKAN_DEV_SYNC_NAVIGATION__;
|
|
889
|
-
syncNavigation?.(href, kind);
|
|
890
|
-
}, []);
|
|
891
|
-
const runForwardNavigation = useCallback(
|
|
892
|
-
(kind: "push" | "replace", href: string, { scrollToTop }: RouteOptions = {}) => {
|
|
893
|
-
const fromLocation = getCurrentLocation();
|
|
894
|
-
const target = getLocation(href);
|
|
895
|
-
|
|
896
|
-
const toLocation =
|
|
897
|
-
kind === "replace" && target.pathRoute.path === fromLocation.pathRoute.path
|
|
898
|
-
? { ...target, entryId: fromLocation.entryId }
|
|
899
|
-
: target;
|
|
900
|
-
const scrollTop = pageContentRef.current?.scrollTop ?? 0;
|
|
901
|
-
const usePendingNavigation =
|
|
902
|
-
CsrStack.keyOf(toLocation) !== CsrStack.keyOf(fromLocation) &&
|
|
903
|
-
shouldPrepareFrameTransition(href) &&
|
|
904
|
-
toLocation.pathRoute.pageState.transition !== "none";
|
|
905
|
-
|
|
906
|
-
if (!usePendingNavigation) {
|
|
907
|
-
setHistoryForward({ type: kind, location: toLocation, scrollTop, scrollToTop });
|
|
908
|
-
settle(kind === "replace" ? prevLocation : fromLocation);
|
|
909
|
-
if (kind === "push") csrLocation.push({ akanEntryId: toLocation.entryId }, href);
|
|
910
|
-
else csrLocation.replace({ akanEntryId: toLocation.entryId }, href);
|
|
911
|
-
return;
|
|
912
|
-
}
|
|
913
|
-
|
|
914
|
-
if (navigationLocked.current) {
|
|
915
|
-
|
|
916
|
-
const waiting = waitingNavigation.current;
|
|
917
|
-
waitingNavigation.current = { kind: waiting?.kind === "push" ? "push" : kind, href, scrollToTop };
|
|
918
|
-
debugFrame("navigation.wait", { kind, from: fromLocation.href, to: href });
|
|
919
|
-
return;
|
|
920
|
-
}
|
|
921
|
-
navigationLocked.current = true;
|
|
922
|
-
const intent: NavigationIntent = {
|
|
923
|
-
id: ++navigationIntentId.current,
|
|
924
|
-
kind,
|
|
925
|
-
from: fromLocation,
|
|
926
|
-
to: toLocation,
|
|
927
|
-
scrollTop,
|
|
928
|
-
scrollToTop,
|
|
929
|
-
createdAt: Date.now(),
|
|
930
|
-
};
|
|
931
|
-
pendingNavigation.current = intent;
|
|
932
|
-
debugFrame("navigation.intent", { id: intent.id, kind, from: fromLocation.href, to: href });
|
|
933
|
-
clearPendingSlots();
|
|
934
|
-
setLocationState({
|
|
935
|
-
location: fromLocation,
|
|
936
|
-
prevLocation,
|
|
937
|
-
pendingLocation: toLocation,
|
|
938
|
-
navigationIntent: intent,
|
|
939
|
-
phase: "preparing",
|
|
940
|
-
});
|
|
941
|
-
|
|
942
|
-
const commitNavigation = async (timedOut: boolean) => {
|
|
943
|
-
const latestPageStates = latestPageStateByPath.current;
|
|
944
|
-
const fromPageState = latestPageStates.get(fromLocation.pathRoute.path) ?? fromLocation.pathRoute.pageState;
|
|
945
|
-
const toPageState = latestPageStates.get(toLocation.pathRoute.path) ?? toLocation.pathRoute.pageState;
|
|
946
|
-
const fromFrame = createFrameSnapshot({
|
|
947
|
-
location: fromLocation,
|
|
948
|
-
pageState: fromPageState,
|
|
949
|
-
viewport,
|
|
950
|
-
frameSlots: getFrameSlotsForSnapshot(fromLocation.pathRoute.path, latestFrameSlots.current),
|
|
951
|
-
});
|
|
952
|
-
const toFrame = createFrameSnapshot({
|
|
953
|
-
location: toLocation,
|
|
954
|
-
pageState: toPageState,
|
|
955
|
-
viewport,
|
|
956
|
-
frameSlots: getFrameSlotsForSnapshot(toLocation.pathRoute.path, latestPendingFrameSlots.current),
|
|
957
|
-
});
|
|
958
|
-
const plan = createTransitionPlan({
|
|
959
|
-
id: ++transitionPlanId.current,
|
|
960
|
-
intent,
|
|
961
|
-
type: toPageState.transition,
|
|
962
|
-
direction: "forward",
|
|
963
|
-
fromFrame,
|
|
964
|
-
toFrame,
|
|
965
|
-
});
|
|
966
|
-
debugFrame(timedOut ? "navigation.frameTimeout" : "navigation.frameReady", {
|
|
967
|
-
id: intent.id,
|
|
968
|
-
to: href,
|
|
969
|
-
pendingSlots: toFrame.frameSlots,
|
|
970
|
-
});
|
|
971
|
-
debugFrame("transition.plan", {
|
|
972
|
-
id: plan.id,
|
|
973
|
-
type: plan.type,
|
|
974
|
-
duration: plan.duration,
|
|
975
|
-
actions: plan.actions.map((action) => action.type),
|
|
976
|
-
});
|
|
977
|
-
await prepareForFrameTransition();
|
|
978
|
-
if (pendingNavigation.current !== intent) return;
|
|
979
|
-
pendingNavigation.current = null;
|
|
980
|
-
setTransitionPageStateSnapshot(new Map(latestPageStates));
|
|
981
|
-
setHistoryForward({ type: kind, location: toLocation, scrollTop, scrollToTop });
|
|
982
|
-
promotePendingSlots();
|
|
983
|
-
setLocationState({
|
|
984
|
-
location: getCurrentLocation(),
|
|
985
|
-
prevLocation: fromLocation,
|
|
986
|
-
pendingLocation: null,
|
|
987
|
-
navigationIntent: intent,
|
|
988
|
-
phase: "transitioning",
|
|
989
|
-
});
|
|
990
|
-
if (kind === "push") csrLocation.push({ akanEntryId: toLocation.entryId }, href);
|
|
991
|
-
else csrLocation.replace({ akanEntryId: toLocation.entryId }, href);
|
|
992
|
-
debugFrame("navigation.commit", { id: intent.id, kind, to: href });
|
|
993
|
-
window.setTimeout(
|
|
994
|
-
() => {
|
|
995
|
-
setTransitionPageStateSnapshot(null);
|
|
996
|
-
setLocationState((current) => ({
|
|
997
|
-
...current,
|
|
998
|
-
|
|
999
|
-
prevLocation: getPrevLocation(),
|
|
1000
|
-
pendingLocation: null,
|
|
1001
|
-
navigationIntent: null,
|
|
1002
|
-
phase: "idle",
|
|
1003
|
-
}));
|
|
1004
|
-
navigationLocked.current = false;
|
|
1005
|
-
clearPendingSlots();
|
|
1006
|
-
debugFrame("transition.actionEnd", { id: plan.id, phase: "idle" });
|
|
1007
|
-
const waiting = waitingNavigation.current;
|
|
1008
|
-
waitingNavigation.current = null;
|
|
1009
|
-
if (waiting) latestRouter.current[waiting.kind](waiting.href, { scrollToTop: waiting.scrollToTop });
|
|
1010
|
-
},
|
|
1011
|
-
Math.max(360, plan.duration),
|
|
1012
|
-
);
|
|
1013
|
-
};
|
|
1014
|
-
|
|
1015
|
-
const waitUntilReady = () => {
|
|
1016
|
-
if (pendingNavigation.current !== intent) return;
|
|
1017
|
-
const elapsedMs = Date.now() - intent.createdAt;
|
|
1018
|
-
const ready = isPendingFrameReady({
|
|
1019
|
-
path: toLocation.pathRoute.path,
|
|
1020
|
-
pendingFrameSlots: latestPendingFrameSlots.current,
|
|
1021
|
-
elapsedMs,
|
|
1022
|
-
});
|
|
1023
|
-
if (ready) {
|
|
1024
|
-
void commitNavigation(elapsedMs >= PENDING_FRAME_READY_TIMEOUT_MS);
|
|
1025
|
-
return;
|
|
1026
|
-
}
|
|
1027
|
-
window.setTimeout(waitUntilReady, 16);
|
|
1028
|
-
};
|
|
1029
|
-
window.setTimeout(waitUntilReady, 16);
|
|
1030
|
-
},
|
|
1031
|
-
[
|
|
1032
|
-
clearPendingSlots,
|
|
1033
|
-
broadcastSyncNavigation,
|
|
1034
|
-
getCurrentLocation,
|
|
1035
|
-
getLocation,
|
|
1036
|
-
getPrevLocation,
|
|
1037
|
-
prevLocation,
|
|
1038
|
-
promotePendingSlots,
|
|
1039
|
-
setHistoryForward,
|
|
1040
|
-
shouldPrepareFrameTransition,
|
|
1041
|
-
viewport,
|
|
1042
|
-
],
|
|
1043
|
-
);
|
|
1044
|
-
renderCountRef.current += 1;
|
|
1045
|
-
if (renderCountRef.current <= 5 || renderCountRef.current % 20 === 0) {
|
|
1046
|
-
debugFrame("csr.render", {
|
|
1047
|
-
count: renderCountRef.current,
|
|
1048
|
-
path: resolvedLocation.pathRoute.path,
|
|
1049
|
-
href: resolvedLocation.href,
|
|
1050
|
-
viewport,
|
|
1051
|
-
keyboardFrame,
|
|
1052
|
-
contentViewport: keyboardLayout.contentViewport,
|
|
1053
|
-
keyboardAccessory: keyboardLayout.keyboardAccessory,
|
|
1054
|
-
frameSlotPaths: Object.keys(frameSlots),
|
|
1055
|
-
});
|
|
1056
|
-
}
|
|
1057
|
-
useEffect(() => {
|
|
1058
|
-
debugFrame("keyboard.layoutResolve", {
|
|
1059
|
-
path: resolvedLocation.pathRoute.path,
|
|
1060
|
-
keyboardHeight: keyboardFrame.height,
|
|
1061
|
-
visualHeight: viewport.visualHeight,
|
|
1062
|
-
visualOffsetTop: viewport.visualOffsetTop,
|
|
1063
|
-
contentViewport: keyboardLayout.contentViewport,
|
|
1064
|
-
accessory: keyboardLayout.keyboardAccessory,
|
|
1065
|
-
slotHeight: accessoryHeight,
|
|
1066
|
-
platformProfile,
|
|
1067
|
-
frozen: keyboardFrame.frozen,
|
|
1068
|
-
source: keyboardFrame.source,
|
|
1069
|
-
});
|
|
1070
|
-
}, [
|
|
1071
|
-
resolvedLocation.pathRoute.path,
|
|
1072
|
-
keyboardFrame.height,
|
|
1073
|
-
keyboardFrame.offset,
|
|
1074
|
-
keyboardFrame.frozen,
|
|
1075
|
-
keyboardFrame.source,
|
|
1076
|
-
viewport.visualHeight,
|
|
1077
|
-
viewport.visualOffsetTop,
|
|
1078
|
-
keyboardLayout,
|
|
1079
|
-
accessoryHeight,
|
|
1080
|
-
platformProfile,
|
|
1081
|
-
]);
|
|
1082
|
-
useEffect(() => {
|
|
1083
|
-
debugFrame("csr.mount", { path: resolvedLocation.pathRoute.path, viewport });
|
|
1084
|
-
csrLocation.replace({ ...((csrLocation.state as object | null) ?? {}), akanEntryId: getCurrentLocation().entryId });
|
|
1085
|
-
return () => debugFrame("csr.unmount", { lastPath: getCurrentLocation().pathRoute.path });
|
|
1086
|
-
}, []);
|
|
40
|
+
const { getLocation, getCurrentLocation, getPrevLocation, getNextLocation, getScrollTop, history, location } = nav;
|
|
41
|
+
const { setHistoryForward, setHistoryBack, setHistoryJump } = nav;
|
|
42
|
+
const { cancelPendingNavigation, runForwardNavigation, broadcastSyncNavigation, settle } = navigation;
|
|
43
|
+
const { shouldPrepareFrameTransition, startFrameTransition } = navigation;
|
|
1087
44
|
const getRouter = useCallback((): RouterInstance => {
|
|
45
|
+
const playBack = (transition: TransitionType) => onBack.current[transition]?.();
|
|
1088
46
|
const forward =
|
|
1089
47
|
(kind: "push" | "replace") =>
|
|
1090
48
|
(href: string, { scrollToTop }: RouteOptions = {}) => {
|
|
@@ -1104,8 +62,8 @@ export const useCsrValues = (rootRouteGuide: RouteGuide, pathRoutes: PathRoute[]
|
|
|
1104
62
|
return;
|
|
1105
63
|
}
|
|
1106
64
|
if (pendingNavigation.current?.to.href === href) return;
|
|
1107
|
-
|
|
1108
|
-
const cancelled = cancelPendingNavigation();
|
|
65
|
+
|
|
66
|
+
const cancelled: NavigationIntent | null = cancelPendingNavigation();
|
|
1109
67
|
if (location.href === href) {
|
|
1110
68
|
if (!pageContentRef.current) return;
|
|
1111
69
|
pageContentRef.current.scrollTop = getScrollTop(location);
|
|
@@ -1130,7 +88,7 @@ export const useCsrValues = (rootRouteGuide: RouteGuide, pathRoutes: PathRoute[]
|
|
|
1130
88
|
|
|
1131
89
|
broadcastSyncNavigation("back", getSyncRouteHref(targetLocation));
|
|
1132
90
|
if (shouldPrepareFrameTransition()) await startFrameTransition();
|
|
1133
|
-
await
|
|
91
|
+
await playBack(location.pathRoute.pageState.transition);
|
|
1134
92
|
const scrollTop = pageContentRef.current?.scrollTop ?? 0;
|
|
1135
93
|
setHistoryBack({ type: "back", location, scrollTop, scrollToTop });
|
|
1136
94
|
settle(getPrevLocation());
|
|
@@ -1179,7 +137,7 @@ export const useCsrValues = (rootRouteGuide: RouteGuide, pathRoutes: PathRoute[]
|
|
|
1179
137
|
} else {
|
|
1180
138
|
const location = getCurrentLocation();
|
|
1181
139
|
if (shouldPrepareFrameTransition(href)) await startFrameTransition();
|
|
1182
|
-
if (!isUaAnimated) await
|
|
140
|
+
if (!isUaAnimated) await playBack(location.pathRoute.pageState.transition);
|
|
1183
141
|
setHistoryBack({ type: "popBack", location, scrollTop });
|
|
1184
142
|
settle(getPrevLocation());
|
|
1185
143
|
}
|
|
@@ -1187,67 +145,48 @@ export const useCsrValues = (rootRouteGuide: RouteGuide, pathRoutes: PathRoute[]
|
|
|
1187
145
|
return router;
|
|
1188
146
|
}, [location, runForwardNavigation, cancelPendingNavigation, broadcastSyncNavigation, shouldPrepareFrameTransition]);
|
|
1189
147
|
const liveRouter = getRouter();
|
|
1190
|
-
const latestRouter = useRef(liveRouter);
|
|
1191
148
|
latestRouter.current = liveRouter;
|
|
1192
149
|
|
|
1193
150
|
const [router] = useState<RouterInstance>(() => ({
|
|
1194
|
-
push: (href, routeOptions) => latestRouter.
|
|
1195
|
-
replace: (href, routeOptions) => latestRouter.
|
|
1196
|
-
back: (routeOptions) => latestRouter.
|
|
1197
|
-
refresh: () => latestRouter.
|
|
151
|
+
push: (href, routeOptions) => currentRouter(latestRouter).push(href, routeOptions),
|
|
152
|
+
replace: (href, routeOptions) => currentRouter(latestRouter).replace(href, routeOptions),
|
|
153
|
+
back: (routeOptions) => currentRouter(latestRouter).back(routeOptions),
|
|
154
|
+
refresh: () => currentRouter(latestRouter).refresh(),
|
|
1198
155
|
}));
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
resolvedLocation.
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
const target = new URL(href, window.location.origin);
|
|
1234
|
-
const targetHref = `${target.pathname}${target.search}${target.hash}`;
|
|
1235
|
-
|
|
1236
|
-
if (targetHref === getSyncRouteHref(getCurrentLocation()) || targetHref === lastBroadcastSyncHref.current) return;
|
|
1237
|
-
applyingSyncNavigation.current = true;
|
|
1238
|
-
globalThis.__AKAN_DEV_SYNC_NAVIGATION_APPLYING__ = true;
|
|
1239
|
-
const previous = getPrevLocation();
|
|
1240
|
-
|
|
1241
|
-
if (kind !== "push" && kind !== "replace" && previous && getSyncRouteHref(previous) === targetHref)
|
|
1242
|
-
clientRouter.back({ scrollToTop: false });
|
|
1243
|
-
else if (kind === "replace" || kind === "back" || kind === "pop")
|
|
1244
|
-
clientRouter.replace(targetHref, { scrollToTop: false });
|
|
1245
|
-
else clientRouter.push(targetHref, { scrollToTop: false });
|
|
1246
|
-
resetSyncNavigation();
|
|
1247
|
-
};
|
|
1248
|
-
window.addEventListener("akan:sync-navigation", handleSyncNavigation);
|
|
1249
|
-
return () => window.removeEventListener("akan:sync-navigation", handleSyncNavigation);
|
|
1250
|
-
}, [getCurrentLocation, getPrevLocation, router]);
|
|
156
|
+
return router;
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
export const useCsrValues = (rootRouteGuide: RouteGuide, pathRoutes: PathRoute[]) => {
|
|
160
|
+
const { viewport, updateViewport } = useFrameViewport();
|
|
161
|
+
const slots = useFrameSlots();
|
|
162
|
+
const [transitionPageStateSnapshot, setTransitionPageStateSnapshot] = useState<Map<string, PageState> | null>(null);
|
|
163
|
+
const refs = useCsrRefs();
|
|
164
|
+
const nav = useCsrLocationState(rootRouteGuide);
|
|
165
|
+
const frame = useResolvedFrame({ pathRoutes, slots, transitionPageStateSnapshot, refs, nav });
|
|
166
|
+
const keyboard = useCsrKeyboard({
|
|
167
|
+
viewport,
|
|
168
|
+
updateViewport,
|
|
169
|
+
frameSlots: slots.frameSlots,
|
|
170
|
+
phase: nav.phase,
|
|
171
|
+
resolvedLocation: frame.resolvedLocation,
|
|
172
|
+
pageContentRef: refs.pageContentRef,
|
|
173
|
+
});
|
|
174
|
+
const navigation = useCsrNavigation({ viewport, slots, setTransitionPageStateSnapshot, refs, nav, frame, keyboard });
|
|
175
|
+
useCsrRenderTrace({ viewport, frameSlots: slots.frameSlots, refs, nav, frame, keyboard });
|
|
176
|
+
const router = useCsrRouter({ refs, nav, navigation });
|
|
177
|
+
useSyncNavigation({
|
|
178
|
+
refs,
|
|
179
|
+
nav,
|
|
180
|
+
resolvedLocation: frame.resolvedLocation,
|
|
181
|
+
broadcastSyncNavigation: navigation.broadcastSyncNavigation,
|
|
182
|
+
router,
|
|
183
|
+
});
|
|
184
|
+
const { registerFrameSlot } = slots;
|
|
185
|
+
const { topSafeAreaRef, bottomSafeAreaRef, prevPageContentRef, pageContentRef, frameRootRef, onBack } = refs;
|
|
186
|
+
const { navigationIntent, phase, isBackgrounded, history } = nav;
|
|
187
|
+
const { resolvedLocation, resolvedPrevLocation, resolvedPendingLocation, stackEntries } = frame;
|
|
188
|
+
const { resolvedPathRoutes, effectivePageStateByPath } = frame;
|
|
189
|
+
const { keyboardFrame, keyboardLayout, shouldAnchorContentBottom, platformProfile } = keyboard;
|
|
1251
190
|
const routeState: RouteState = {
|
|
1252
191
|
clientWidth: viewport.width,
|
|
1253
192
|
clientHeight: viewport.height,
|
|
@@ -1279,18 +218,7 @@ export const useCsrValues = (rootRouteGuide: RouteGuide, pathRoutes: PathRoute[]
|
|
|
1279
218
|
pageStateByPath: effectivePageStateByPath,
|
|
1280
219
|
},
|
|
1281
220
|
};
|
|
1282
|
-
const
|
|
1283
|
-
const useFadeTransition = useFadeTrans(routeState);
|
|
1284
|
-
const useScaleOutTransition = useScaleOutTrans(routeState);
|
|
1285
|
-
const useStackTransition = useStackTrans(routeState);
|
|
1286
|
-
const useBottomUpTransition = useBottomUpTrans(routeState);
|
|
1287
|
-
const useCsrTransitionMap: { [key in TransitionType]: UseCsrTransition } = {
|
|
1288
|
-
none: useNonTransition,
|
|
1289
|
-
fade: useFadeTransition,
|
|
1290
|
-
stack: useStackTransition,
|
|
1291
|
-
bottomUp: useBottomUpTransition,
|
|
1292
|
-
scaleOut: useScaleOutTransition,
|
|
1293
|
-
};
|
|
221
|
+
const useCsrTransitionMap = useCsrTransitions(routeState);
|
|
1294
222
|
|
|
1295
223
|
const contentResizeStyle = useMemo(() => {
|
|
1296
224
|
if (!shouldAnchorContentBottom || !keyboardFrame.sticky) return null;
|
|
@@ -1306,100 +234,7 @@ export const useCsrValues = (rootRouteGuide: RouteGuide, pathRoutes: PathRoute[]
|
|
|
1306
234
|
contentResizeStyle && csrTransition.page
|
|
1307
235
|
? { ...csrTransition.page, contentStyle: { ...csrTransition.page.contentStyle, ...contentResizeStyle } }
|
|
1308
236
|
: csrTransition.page;
|
|
1309
|
-
|
|
1310
|
-
const nativeBackStateRef = useRef({
|
|
1311
|
-
path: resolvedLocation.pathRoute.path,
|
|
1312
|
-
keyboardHeight: keyboardFrame.height,
|
|
1313
|
-
keyboardVisible: keyboardFrame.visible,
|
|
1314
|
-
router: clientRouter,
|
|
1315
|
-
});
|
|
1316
|
-
|
|
1317
|
-
useEffect(() => {
|
|
1318
|
-
if (pageContentRef.current) pageContentRef.current.scrollTop = getScrollTop(location);
|
|
1319
|
-
if (prevPageContentRef.current)
|
|
1320
|
-
prevPageContentRef.current.scrollTop = prevLocation ? getScrollTop(prevLocation) : 0;
|
|
1321
|
-
}, [location.href]);
|
|
1322
|
-
|
|
1323
|
-
useEffect(() => {
|
|
1324
|
-
for (const shown of [location, prevLocation]) if (shown?.entryId) history.current.dormant?.delete(shown.entryId);
|
|
1325
|
-
CsrStack.save(history.current);
|
|
1326
|
-
}, [location, prevLocation]);
|
|
1327
|
-
|
|
1328
|
-
useEffect(() => {
|
|
1329
|
-
const sync = () => setIsBackgrounded(document.visibilityState === "hidden");
|
|
1330
|
-
document.addEventListener("visibilitychange", sync);
|
|
1331
|
-
return () => document.removeEventListener("visibilitychange", sync);
|
|
1332
|
-
}, []);
|
|
1333
|
-
|
|
1334
|
-
useEffect(() => {
|
|
1335
|
-
nativeNavigation.current?.showPushesExcept(location.pathname);
|
|
1336
|
-
}, [location.pathname]);
|
|
1337
|
-
|
|
1338
|
-
useEffect(() => {
|
|
1339
|
-
nativeBackStateRef.current = {
|
|
1340
|
-
path: resolvedLocation.pathRoute.path,
|
|
1341
|
-
keyboardHeight: keyboardFrame.height,
|
|
1342
|
-
keyboardVisible: keyboardFrame.visible,
|
|
1343
|
-
router: clientRouter,
|
|
1344
|
-
};
|
|
1345
|
-
nativeNavigation.current?.syncBack();
|
|
1346
|
-
}, [keyboardFrame.height, keyboardFrame.visible, resolvedLocation.pathRoute.path]);
|
|
1347
|
-
|
|
1348
|
-
const backFollow = useRef(csrTransition);
|
|
1349
|
-
backFollow.current = csrTransition;
|
|
1350
|
-
const followBack = useCallback(({ phase, progress }: NativeBackProgress) => {
|
|
1351
|
-
const { transUnit, transUnitRange } = backFollow.current;
|
|
1352
|
-
const transition = getCurrentLocation().pathRoute.pageState.transition;
|
|
1353
|
-
if (transition === "none" || history.current.idx === 0 || nativeBackStateRef.current.keyboardVisible) return;
|
|
1354
|
-
const [hidden, shown] = transUnitRange;
|
|
1355
|
-
if (phase === "cancelled") {
|
|
1356
|
-
void transUnit.start(shown);
|
|
1357
|
-
return;
|
|
1358
|
-
}
|
|
1359
|
-
|
|
1360
|
-
const follow = transition === "stack" || transition === "bottomUp" ? progress : progress / 2;
|
|
1361
|
-
void transUnit.start(shown + (hidden - shown) * follow, { immediate: true });
|
|
1362
|
-
}, []);
|
|
1363
|
-
const [, setReleased] = useState(0);
|
|
1364
|
-
const latestStackEntries = useRef(stackEntries);
|
|
1365
|
-
latestStackEntries.current = stackEntries;
|
|
1366
|
-
const releaseHidden = useCallback(() => {
|
|
1367
|
-
history.current.dormant ??= new Set();
|
|
1368
|
-
for (const { pageType, location: hidden } of latestStackEntries.current)
|
|
1369
|
-
if (pageType === "cached" && hidden.entryId) history.current.dormant.add(hidden.entryId);
|
|
1370
|
-
setReleased((count) => count + 1);
|
|
1371
|
-
}, []);
|
|
1372
|
-
useEffect(() => {
|
|
1373
|
-
const redraw = () => {
|
|
1374
|
-
if (CsrStack.redrawFor(history.current, getCurrentLocation(), getAuthToken() ?? null))
|
|
1375
|
-
setReleased((count) => count + 1);
|
|
1376
|
-
};
|
|
1377
|
-
redraw();
|
|
1378
|
-
window.addEventListener("akan:auth", redraw);
|
|
1379
|
-
return () => window.removeEventListener("akan:auth", redraw);
|
|
1380
|
-
}, []);
|
|
1381
|
-
useEffect(() => {
|
|
1382
|
-
if (phase === "idle") CsrStack.leave(history.current, location);
|
|
1383
|
-
}, [phase, location]);
|
|
1384
|
-
|
|
1385
|
-
useEffect(() => {
|
|
1386
|
-
const navigation = new NativeNavigation({
|
|
1387
|
-
historyIdx: () => history.current.idx,
|
|
1388
|
-
backState: () => nativeBackStateRef.current,
|
|
1389
|
-
dismissKeyboard: prepareForFrameTransition,
|
|
1390
|
-
onBackProgress: followBack,
|
|
1391
|
-
onMemoryWarning: releaseHidden,
|
|
1392
|
-
});
|
|
1393
|
-
nativeNavigation.current = navigation;
|
|
1394
|
-
const stop = navigation.listen();
|
|
1395
|
-
navigation.showPushesExcept(getCurrentLocation().pathname);
|
|
1396
|
-
const stopUpdates = new NativeUpdates().listen();
|
|
1397
|
-
return () => {
|
|
1398
|
-
stop();
|
|
1399
|
-
stopUpdates();
|
|
1400
|
-
nativeNavigation.current = null;
|
|
1401
|
-
};
|
|
1402
|
-
}, []);
|
|
237
|
+
useCsrStackLifecycle({ refs, nav, frame, keyboard, csrTransition });
|
|
1403
238
|
|
|
1404
239
|
return {
|
|
1405
240
|
...routeState,
|