akanjs 3.3.0-rc.8 → 3.3.0-rc.80
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ko.md +9 -5
- package/README.md +7 -5
- package/base/utils.ts +2 -0
- package/client/appOpenedTab.ts +2 -1
- package/client/clientRuntime.ts +2 -0
- package/client/cookie.ts +15 -6
- package/client/csrLocation.ts +61 -9
- package/client/csrRuntimeParams.ts +33 -0
- package/client/csrTypes.ts +22 -2
- package/client/device.ts +26 -14
- package/client/dictionaryAsset.ts +103 -25
- package/client/dictionaryGroups.ts +113 -0
- package/client/dictionaryModule.ts +23 -0
- package/client/dictionaryPart.ts +113 -0
- package/client/frameConfig.ts +9 -0
- package/client/index.ts +10 -0
- package/client/keyboardRide.ts +396 -0
- package/client/makePageProto.tsx +22 -2
- package/client/nativeBoot.ts +3 -0
- package/client/nativeErrorReport.ts +55 -0
- package/client/nativeHost.ts +2 -31
- package/client/nativeShell.ts +32 -0
- package/client/notFoundView.ts +9 -0
- package/client/pendingNavigation.ts +103 -0
- package/client/pressLoading.ts +29 -0
- package/client/redirectMove.ts +13 -0
- package/client/reportText.ts +27 -0
- package/client/route/RouteDefinition.ts +33 -7
- package/client/router.ts +39 -26
- package/client/rscClientErrorSender.ts +85 -0
- package/client/rscNavigation.ts +8 -1
- package/client/scriptPolicy.ts +14 -0
- package/client/sharedContext.ts +3 -1
- package/client/sharedContextKey.ts +2 -0
- package/client/shellState.ts +151 -0
- package/client/shellStateHooks.ts +2 -0
- package/client/translator.ts +7 -1
- package/client/translatorState.ts +18 -1
- package/client/usePendingNavigation.ts +38 -0
- package/common/Logger.ts +1 -1
- package/common/TraceContext.ts +5 -3
- package/common/index.ts +1 -0
- package/common/sessionTokenContract.ts +7 -0
- package/common/websocketContract.ts +5 -2
- package/constant/constantRegistry.ts +36 -33
- package/constant/immerable.ts +2 -0
- package/constant/immerify.ts +1 -1
- package/constant/index.ts +1 -0
- package/constant/inputParser.ts +7 -0
- package/constant/types.ts +10 -9
- package/constant/via.ts +1 -1
- package/dictionary/agent.dictionary.ts +4 -0
- package/fetch/client/fetchClient.ts +22 -42
- package/fetch/client/fetchHandle.ts +3 -1
- package/fetch/client/httpClient.ts +15 -1
- package/fetch/client/modelRuntimes.ts +89 -0
- package/fetch/client/requestScope.ts +4 -1
- package/fetch/client/signalCatalog.ts +9 -4
- package/fetch/client/sliceInitHandle.ts +5 -3
- package/fetch/client/wsClient.ts +10 -1
- package/fetch/fetchType/appliedReturn.type.ts +4 -2
- package/fetch/requestStorage.ts +20 -0
- package/index.ts +58 -1
- package/package.json +17 -2
- package/server/SSR_MEMORY_DIAGNOSIS.md +4 -0
- package/server/akanApp.ts +21 -5
- package/server/akanOption.ts +28 -0
- package/server/akanServer.ts +136 -40
- package/server/appWorker.ts +177 -0
- package/server/appWorkerError.ts +5 -0
- package/server/appWorkerPath.ts +22 -0
- package/server/artifact/builderRpc.ts +1 -0
- package/server/artifact/ipcTypes.ts +4 -0
- package/server/artifact/routeClientCache.ts +4 -0
- package/server/assetHeaders.ts +11 -8
- package/server/clientErrorReport.ts +248 -0
- package/server/clientReportId.ts +54 -0
- package/server/devtools/devtoolsRouter.ts +27 -16
- package/server/devtools/signalSerializer.ts +18 -1
- package/server/devtools/studio/studioDocument.tsx +3 -1
- package/server/devtools/studio/studioRoute.ts +5 -2
- package/server/devtools/types.ts +6 -0
- package/server/di/diLifecycle.ts +25 -186
- package/server/di/moduleSelection.ts +202 -0
- package/server/flightSanitizeRecorded.fixture.json +36 -34
- package/server/forwardedError.ts +43 -0
- package/server/gateway/childSupervisor.ts +8 -4
- package/server/gateway/gatewayChildren.ts +1 -0
- package/server/gateway/gatewayConfig.ts +5 -0
- package/server/gateway/gatewayHttpProxy.ts +1 -1
- package/server/gateway/gatewayStatus.ts +11 -1
- package/server/gateway/gatewayStatusPage.ts +18 -11
- package/server/headSplice.ts +73 -0
- package/server/hmr/clientReport.ts +9 -9
- package/server/hmr/clientScript.ts +4 -1
- package/server/hmr/csrDevShell.ts +7 -4
- package/server/hmr/devArtifactPruner.ts +7 -1
- package/server/hmr/devBaseArtifact.ts +5 -1
- package/server/hmr/wsHub.ts +1 -0
- package/server/htmlResultCache.ts +107 -39
- package/server/index.ts +5 -0
- package/server/lifecycle/buildEnv.ts +2 -0
- package/server/lifecycle/envProfile.ts +27 -0
- package/server/lifecycle/parentChannel.ts +11 -4
- package/server/lifecycle/secretEnv.ts +98 -0
- package/server/lifecycle/shutdownManager.ts +6 -0
- package/server/logging/logForwarder.ts +2 -2
- package/server/logging/serverLogging.ts +24 -10
- package/server/mcp/McpAppFrame.ts +42 -0
- package/server/mcp/McpAuth.ts +12 -2
- package/server/mcp/McpDispatcher.ts +20 -3
- package/server/mcp/McpFoundTools.ts +69 -0
- package/server/mcp/McpRouter.ts +165 -166
- package/server/mcp/McpSearch.ts +161 -0
- package/server/mcp/McpShelves.ts +95 -0
- package/server/mcp/McpWire.ts +92 -0
- package/server/mcp/index.ts +2 -0
- package/server/metrics/metricMerge.ts +1 -1
- package/server/metrics/pubsubGauges.ts +27 -0
- package/server/metrics/slowStatementLog.ts +63 -0
- package/server/metrics/statementMetrics.ts +259 -0
- package/server/metrics/statementPlanCheck.ts +141 -0
- package/server/metrics/statementReport.ts +105 -0
- package/server/migration/migrationRunner.ts +13 -10
- package/server/oauth/OAuthAuthorize.ts +8 -3
- package/server/oauth/OAuthErrors.ts +5 -1
- package/server/ops/statusAccess.ts +10 -2
- package/server/otlp/otlpBatcher.ts +221 -0
- package/server/otlp/otlpConfig.ts +185 -0
- package/server/otlp/otlpEncode.ts +114 -0
- package/server/otlp/otlpExporter.ts +98 -0
- package/server/otlp/otlpSampler.ts +50 -0
- package/server/pageFailure.ts +33 -0
- package/server/renderBusyResponse.ts +7 -2
- package/server/resolver/timedQuery.ts +7 -3
- package/server/resolver/unmountedRoutes.ts +55 -0
- package/server/routeCacheTally.ts +6 -0
- package/server/routeElementComposer.tsx +38 -3
- package/server/routeLevelRuns.ts +72 -0
- package/server/routeState.ts +1 -1
- package/server/routeTreeBuilder.ts +30 -1
- package/server/routing/apiRouter.ts +24 -7
- package/server/routing/appWsData.ts +4 -1
- package/server/routing/builtinRoutes.ts +13 -1
- package/server/routing/devBuild.ts +4 -0
- package/server/routing/devSurfacePolicy.ts +2 -1
- package/server/routing/devSurfaces.ts +4 -0
- package/server/routing/roomReplay.ts +4 -0
- package/server/routing/serverListener.ts +125 -55
- package/server/routing/soloAppRoutes.ts +7 -1
- package/server/routing/webSurfaceHold.ts +117 -0
- package/server/routing/wsCredentialRevocation.ts +55 -0
- package/server/rscClient.tsx +74 -7
- package/server/rscClientChunks.ts +8 -1
- package/server/rscClientErrors.ts +28 -0
- package/server/rscFirstRenderMemory.ts +49 -0
- package/server/rscFlightRenderer.ts +21 -4
- package/server/rscFlightStream.ts +2 -2
- package/server/rscPatchPlanner.ts +35 -9
- package/server/rscPrefetchCache.ts +19 -5
- package/server/rscPressLoading.tsx +40 -0
- package/server/rscRenderHandler.ts +19 -3
- package/server/rscRenderStats.ts +3 -0
- package/server/rscRouteDocument.tsx +2 -2
- package/server/rscSegmentOutlet.tsx +21 -1
- package/server/rscSegmentOutletReference.ts +2 -1
- package/server/rscWorker.tsx +5 -1
- package/server/rscWorkerCache.ts +3 -1
- package/server/rscWorkerHost.ts +19 -2
- package/server/rscWorkerProcess.ts +12 -0
- package/server/rscWorkerRecycler.ts +3 -3
- package/server/scriptPolicy.ts +161 -0
- package/server/scriptPolicyReport.ts +147 -0
- package/server/selfExec.ts +13 -1
- package/server/serverConfig.ts +12 -0
- package/server/serverMetrics.ts +21 -2
- package/server/ssrFromRscRenderer.tsx +29 -201
- package/server/ssrInlineScripts.ts +202 -0
- package/server/ssrTypes.ts +9 -2
- package/server/systemPageDocument.tsx +6 -2
- package/server/systemPages.tsx +9 -4
- package/server/types.tsx +12 -0
- package/server/vendor/akanjs-client.ts +1 -0
- package/server/webArtifact.ts +16 -5
- package/server/webCsrSurface.ts +34 -12
- package/server/webDocumentRoute.ts +48 -18
- package/server/webRouteContext.ts +34 -7
- package/server/webRouter.ts +8 -0
- package/server/webRscRoute.ts +6 -3
- package/service/agent.service.ts +1 -0
- package/service/agentLoop/agentLoop.ts +58 -19
- package/service/agentLoop/agentLoopTypes.ts +45 -0
- package/service/agentLoop/loopCompaction.ts +14 -4
- package/service/agentLoop/loopContext.ts +5 -2
- package/service/agentLoop/loopLent.ts +80 -0
- package/service/agentLoop/loopRequest.ts +25 -2
- package/service/agentLoop/loopToolBudget.ts +37 -0
- package/service/agentLoop/loopToolSearch.ts +85 -0
- package/service/agentLoop/loopToolkits.ts +223 -32
- package/service/agentLoop/loopTranscript.ts +1 -1
- package/service/ipcTypes.ts +38 -1
- package/service/predefinedAdaptor/anthropicLlm.ts +336 -56
- package/service/predefinedAdaptor/anthropicTools.ts +59 -0
- package/service/predefinedAdaptor/database.adaptor.ts +41 -9
- package/service/predefinedAdaptor/index.ts +1 -0
- package/service/predefinedAdaptor/llm.adaptor.ts +34 -0
- package/service/predefinedAdaptor/llmOverflow.ts +19 -0
- package/service/predefinedAdaptor/openaiDialect.ts +27 -13
- package/service/predefinedAdaptor/openaiLlm.ts +1 -2
- package/service/predefinedAdaptor/solidPubsub.adaptor.ts +16 -0
- package/service/predefinedAdaptor/sql/driver/bunSqlite.ts +49 -11
- package/service/predefinedAdaptor/sql/driver/postgres.ts +47 -10
- package/service/predefinedAdaptor/sql/statementFingerprint.ts +117 -0
- package/service/predefinedAdaptor/sql/statementPlans.ts +71 -0
- package/service/predefinedAdaptor/sql/statementProbe.ts +110 -0
- package/service/predefinedAdaptor/sql/statementScrub.ts +149 -0
- package/service/predefinedAdaptor/websocket.adaptor.ts +62 -16
- package/service/toolNames.ts +7 -1
- package/signal/CrossSiteGuard.ts +5 -0
- package/signal/browserError.ts +28 -0
- package/signal/endpointInfo.ts +2 -1
- package/signal/errorReporting.ts +168 -0
- package/signal/index.ts +2 -0
- package/signal/internalInfo.ts +2 -2
- package/signal/mcp/McpDocument.ts +13 -4
- package/signal/mcp/mcpProtocol.ts +6 -0
- package/signal/requestTrace.ts +40 -3
- package/signal/roomKey.ts +3 -6
- package/signal/signalContext.ts +4 -4
- package/signal/spanExport.ts +137 -0
- package/signal/trace.ts +41 -10
- package/store/actionErrorMessage.ts +15 -1
- package/store/agent/AgentContext.ts +48 -8
- package/store/agent/AgentInline.ts +50 -0
- package/store/agent/AgentVisual.ts +3 -2
- package/store/agent/ScreenReader.ts +7 -1
- package/store/agent/ScreenSettle.ts +29 -0
- package/store/agent/ScreenTarget.ts +2 -2
- package/store/agent/StoreCatalogue.ts +1 -1
- package/store/agent/StoreSurfaceSource.ts +70 -17
- package/store/agentic/AgentNavigate.ts +20 -0
- package/store/agentic/fieldToolEntries.ts +374 -0
- package/store/agentic/fieldTools.ts +49 -0
- package/store/agentic/formFields.ts +7 -2
- package/store/agentic/formFieldsReexport.ts +2 -0
- package/store/agentic/index.ts +2 -1
- package/store/agentic/useFieldTool.ts +3 -248
- package/store/agentic/useFormTools.ts +3 -45
- package/store/agentic/useRelationFieldTool.ts +2 -60
- package/store/baseSt.ts +7 -6
- package/store/draftStore.ts +2 -2
- package/store/formUploadOf.ts +6 -3
- package/store/index.ts +2 -0
- package/store/shellMirror.ts +49 -0
- package/store/sliceLiveActions.ts +4 -3
- package/store/storeFacade.ts +50 -0
- package/store/storeInstance.ts +92 -72
- package/test/signalTestRuntime.ts +9 -2
- package/test/testServer.ts +7 -1
- package/types/base/utils.d.ts +1 -0
- package/types/client/clientRuntime.d.ts +4 -0
- package/types/client/cookie.d.ts +4 -3
- package/types/client/csrLocation.d.ts +11 -3
- package/types/client/csrRuntimeParams.d.ts +6 -0
- package/types/client/csrTypes.d.ts +21 -2
- package/types/client/device.d.ts +3 -1
- package/types/client/dictionaryAsset.d.ts +4 -1
- package/types/client/dictionaryGroups.d.ts +7 -0
- package/types/client/dictionaryModule.d.ts +10 -0
- package/types/client/dictionaryPart.d.ts +13 -0
- package/types/client/index.d.ts +8 -3
- package/types/client/keyboardRide.d.ts +20 -0
- package/types/client/makePageProto.d.ts +1 -1
- package/types/client/nativeErrorReport.d.ts +10 -0
- package/types/client/nativeHost.d.ts +1 -6
- package/types/client/nativeShell.d.ts +10 -0
- package/types/client/notFoundView.d.ts +8 -0
- package/types/client/pendingNavigation.d.ts +35 -0
- package/types/client/pressLoading.d.ts +4 -0
- package/types/client/redirectMove.d.ts +5 -0
- package/types/client/reportText.d.ts +4 -0
- package/types/client/route/RouteDefinition.d.ts +12 -1
- package/types/client/router.d.ts +9 -1
- package/types/client/rscClientErrorSender.d.ts +12 -0
- package/types/client/rscNavigation.d.ts +2 -0
- package/types/client/scriptPolicy.d.ts +4 -0
- package/types/client/sharedContextKey.d.ts +2 -0
- package/types/client/shellState.d.ts +54 -0
- package/types/client/shellStateHooks.d.ts +1 -0
- package/types/client/translator.d.ts +1 -0
- package/types/client/translatorState.d.ts +9 -1
- package/types/client/usePendingNavigation.d.ts +10 -0
- package/types/common/TraceContext.d.ts +1 -0
- package/types/common/index.d.ts +1 -0
- package/types/common/sessionTokenContract.d.ts +6 -0
- package/types/common/websocketContract.d.ts +1 -0
- package/types/constant/immerable.d.ts +1 -0
- package/types/constant/index.d.ts +1 -1
- package/types/constant/types.d.ts +6 -5
- package/types/dictionary/agent.dictionary.d.ts +1 -1
- package/types/dictionary/dictionary.d.ts +4 -4
- package/types/fetch/client/fetchClient.d.ts +3 -0
- package/types/fetch/client/httpClient.d.ts +1 -0
- package/types/fetch/client/modelRuntimes.d.ts +17 -0
- package/types/fetch/client/signalCatalog.d.ts +2 -1
- package/types/fetch/client/wsClient.d.ts +3 -1
- package/types/fetch/fetchType/appliedReturn.type.d.ts +4 -0
- package/types/fetch/requestStorage.d.ts +6 -0
- package/types/index.d.ts +58 -1
- package/types/server/akanOption.d.ts +16 -1
- package/types/server/akanServer.d.ts +15 -1
- package/types/server/appWorker.d.ts +40 -0
- package/types/server/appWorkerError.d.ts +4 -0
- package/types/server/appWorkerPath.d.ts +9 -0
- package/types/server/artifact/ipcTypes.d.ts +4 -0
- package/types/server/artifact/routeClientCache.d.ts +1 -0
- package/types/server/assetHeaders.d.ts +7 -4
- package/types/server/clientErrorReport.d.ts +28 -0
- package/types/server/clientReportId.d.ts +9 -0
- package/types/server/devtools/signalSerializer.d.ts +3 -1
- package/types/server/devtools/studio/studioDocument.d.ts +1 -0
- package/types/server/devtools/types.d.ts +5 -0
- package/types/server/di/diLifecycle.d.ts +2 -1
- package/types/server/di/moduleSelection.d.ts +22 -0
- package/types/server/forwardedError.d.ts +13 -0
- package/types/server/gateway/gatewayChildren.d.ts +1 -0
- package/types/server/gateway/gatewayConfig.d.ts +1 -0
- package/types/server/gateway/gatewayStatus.d.ts +1 -0
- package/types/server/headSplice.d.ts +11 -0
- package/types/server/hmr/clientReport.d.ts +2 -0
- package/types/server/hmr/csrDevShell.d.ts +3 -1
- package/types/server/hmr/devBaseArtifact.d.ts +1 -0
- package/types/server/hmr/wsHub.d.ts +1 -0
- package/types/server/htmlResultCache.d.ts +8 -1
- package/types/server/index.d.ts +5 -1
- package/types/server/lifecycle/buildEnv.d.ts +1 -0
- package/types/server/lifecycle/envProfile.d.ts +7 -0
- package/types/server/lifecycle/parentChannel.d.ts +2 -2
- package/types/server/lifecycle/secretEnv.d.ts +20 -0
- package/types/server/logging/logForwarder.d.ts +1 -0
- package/types/server/logging/rotatingLogWriter.d.ts +1 -1
- package/types/server/logging/serverLogging.d.ts +1 -0
- package/types/server/mcp/McpAppFrame.d.ts +9 -0
- package/types/server/mcp/McpAuth.d.ts +2 -0
- package/types/server/mcp/McpDispatcher.d.ts +7 -2
- package/types/server/mcp/McpFoundTools.d.ts +14 -0
- package/types/server/mcp/McpRouter.d.ts +6 -0
- package/types/server/mcp/McpSearch.d.ts +40 -0
- package/types/server/mcp/McpShelves.d.ts +30 -0
- package/types/server/mcp/McpWire.d.ts +39 -0
- package/types/server/mcp/index.d.ts +2 -0
- package/types/server/metrics/pubsubGauges.d.ts +6 -0
- package/types/server/metrics/slowStatementLog.d.ts +18 -0
- package/types/server/metrics/statementMetrics.d.ts +45 -0
- package/types/server/metrics/statementPlanCheck.d.ts +16 -0
- package/types/server/metrics/statementReport.d.ts +28 -0
- package/types/server/oauth/OAuthAuthorize.d.ts +5 -2
- package/types/server/ops/statusAccess.d.ts +1 -0
- package/types/server/otlp/otlpBatcher.d.ts +18 -0
- package/types/server/otlp/otlpConfig.d.ts +25 -0
- package/types/server/otlp/otlpEncode.d.ts +13 -0
- package/types/server/otlp/otlpExporter.d.ts +18 -0
- package/types/server/otlp/otlpSampler.d.ts +10 -0
- package/types/server/pageFailure.d.ts +14 -0
- package/types/server/resolver/timedQuery.d.ts +1 -0
- package/types/server/resolver/unmountedRoutes.d.ts +6 -0
- package/types/server/routeCacheTally.d.ts +1 -1
- package/types/server/routeElementComposer.d.ts +8 -2
- package/types/server/routeLevelRuns.d.ts +12 -0
- package/types/server/routing/apiRouter.d.ts +1 -0
- package/types/server/routing/appWsData.d.ts +1 -0
- package/types/server/routing/devBuild.d.ts +3 -0
- package/types/server/routing/roomReplay.d.ts +1 -0
- package/types/server/routing/serverListener.d.ts +6 -1
- package/types/server/routing/soloAppRoutes.d.ts +2 -1
- package/types/server/routing/webSurfaceHold.d.ts +13 -0
- package/types/server/routing/wsCredentialRevocation.d.ts +13 -0
- package/types/server/rscClient.d.ts +2 -0
- package/types/server/rscClientChunks.d.ts +3 -1
- package/types/server/rscClientErrors.d.ts +3 -0
- package/types/server/rscFirstRenderMemory.d.ts +16 -0
- package/types/server/rscFlightStream.d.ts +1 -1
- package/types/server/rscPatchPlanner.d.ts +1 -1
- package/types/server/rscPrefetchCache.d.ts +1 -0
- package/types/server/rscPressLoading.d.ts +5 -0
- package/types/server/rscRenderStats.d.ts +2 -0
- package/types/server/rscSegmentOutlet.d.ts +4 -1
- package/types/server/rscSegmentOutletReference.d.ts +2 -1
- package/types/server/rscWorkerCache.d.ts +3 -1
- package/types/server/rscWorkerProcess.d.ts +1 -0
- package/types/server/rscWorkerRecycler.d.ts +1 -1
- package/types/server/scriptPolicy.d.ts +38 -0
- package/types/server/scriptPolicyReport.d.ts +18 -0
- package/types/server/selfExec.d.ts +1 -0
- package/types/server/serverConfig.d.ts +1 -0
- package/types/server/serverMetrics.d.ts +3 -1
- package/types/server/ssrFromRscRenderer.d.ts +2 -6
- package/types/server/ssrInlineScripts.d.ts +42 -0
- package/types/server/ssrTypes.d.ts +9 -2
- package/types/server/systemPageDocument.d.ts +3 -1
- package/types/server/systemPages.d.ts +2 -1
- package/types/server/types.d.ts +25 -0
- package/types/server/vendor/akanjs-client.d.ts +1 -0
- package/types/server/webRouteContext.d.ts +5 -4
- package/types/server/webRouter.d.ts +1 -0
- package/types/service/agent.service.d.ts +1 -0
- package/types/service/agentLoop/agentLoop.d.ts +2 -1
- package/types/service/agentLoop/agentLoopTypes.d.ts +43 -0
- package/types/service/agentLoop/loopCompaction.d.ts +2 -2
- package/types/service/agentLoop/loopLent.d.ts +16 -0
- package/types/service/agentLoop/loopToolBudget.d.ts +8 -0
- package/types/service/agentLoop/loopToolSearch.d.ts +13 -0
- package/types/service/agentLoop/loopToolkits.d.ts +9 -2
- package/types/service/ipcTypes.d.ts +39 -1
- package/types/service/predefinedAdaptor/anthropicLlm.d.ts +85 -18
- package/types/service/predefinedAdaptor/anthropicTools.d.ts +32 -0
- package/types/service/predefinedAdaptor/database.adaptor.d.ts +2 -0
- package/types/service/predefinedAdaptor/index.d.ts +1 -0
- package/types/service/predefinedAdaptor/llm.adaptor.d.ts +33 -0
- package/types/service/predefinedAdaptor/llmOverflow.d.ts +7 -0
- package/types/service/predefinedAdaptor/solidPubsub.adaptor.d.ts +3 -1
- package/types/service/predefinedAdaptor/sql/driver/bunSqlite.d.ts +3 -1
- package/types/service/predefinedAdaptor/sql/driver/postgres.d.ts +3 -1
- package/types/service/predefinedAdaptor/sql/statementFingerprint.d.ts +21 -0
- package/types/service/predefinedAdaptor/sql/statementPlans.d.ts +17 -0
- package/types/service/predefinedAdaptor/sql/statementProbe.d.ts +37 -0
- package/types/service/predefinedAdaptor/sql/statementScrub.d.ts +5 -0
- package/types/service/predefinedAdaptor/websocket.adaptor.d.ts +10 -0
- package/types/signal/CrossSiteGuard.d.ts +1 -0
- package/types/signal/agent.signal.d.ts +1 -0
- package/types/signal/browserError.d.ts +20 -0
- package/types/signal/endpointInfo.d.ts +2 -2
- package/types/signal/errorReporting.d.ts +27 -0
- package/types/signal/index.d.ts +2 -0
- package/types/signal/internalInfo.d.ts +2 -2
- package/types/signal/mcp/McpDocument.d.ts +3 -0
- package/types/signal/mcp/mcpProtocol.d.ts +5 -0
- package/types/signal/requestTrace.d.ts +3 -1
- package/types/signal/spanExport.d.ts +47 -0
- package/types/signal/trace.d.ts +8 -2
- package/types/store/actionErrorMessage.d.ts +1 -0
- package/types/store/agent/AgentContext.d.ts +2 -0
- package/types/store/agent/AgentInline.d.ts +5 -0
- package/types/store/agent/ScreenReader.d.ts +2 -0
- package/types/store/agent/ScreenSettle.d.ts +5 -0
- package/types/store/agent/StoreSurfaceSource.d.ts +1 -1
- package/types/store/agentic/AgentNavigate.d.ts +10 -0
- package/types/store/agentic/fieldToolEntries.d.ts +28 -0
- package/types/store/agentic/fieldTools.d.ts +5 -0
- package/types/store/agentic/formFieldsReexport.d.ts +1 -0
- package/types/store/agentic/index.d.ts +2 -1
- package/types/store/baseSt.d.ts +1 -1
- package/types/store/index.d.ts +1 -1
- package/types/store/shellMirror.d.ts +8 -0
- package/types/store/storeFacade.d.ts +9 -0
- package/types/test/signalTestRuntime.d.ts +1 -1
- package/types/test/testServer.d.ts +2 -0
- package/types/ui/Constant/schemaDoc.d.ts +1 -0
- package/types/ui/Data/Dashboard.d.ts +1 -0
- package/types/ui/Data/ListContainer.d.ts +1 -0
- package/types/ui/Data/QueryMaker.d.ts +1 -0
- package/types/ui/Data/RefPicker.d.ts +1 -0
- package/types/ui/Dialog/LazyLegacyModal.d.ts +1 -0
- package/types/ui/DismissDragGesture.d.ts +9 -0
- package/types/ui/Field/Text.d.ts +2 -2
- package/types/ui/Field/lightRefCache.d.ts +2 -1
- package/types/ui/Field/useRelationWindow.d.ts +2 -1
- package/types/ui/Link/Anchor.d.ts +4 -2
- package/types/ui/Load/LoadingMark.d.ts +4 -0
- package/types/ui/Load/Stream.d.ts +1 -1
- package/types/ui/Load/StreamDeferred.d.ts +11 -0
- package/types/ui/Load/sliceClaim.d.ts +4 -3
- package/types/ui/Model/resetModels.d.ts +1 -0
- package/types/ui/Signal/Arg.d.ts +1 -0
- package/types/ui/Signal/Doc.d.ts +1 -0
- package/types/ui/Signal/Endpoint.d.ts +1 -0
- package/types/ui/Signal/RestApi.d.ts +1 -0
- package/types/ui/Signal/WebSocket.d.ts +1 -0
- package/types/ui/Signal/endpointEntries.d.ts +1 -0
- package/types/ui/Signal/makeExample.d.ts +1 -0
- package/types/ui/Signal/useApiDescriptions.d.ts +1 -0
- package/types/ui/System/isSamePathValue.d.ts +2 -0
- package/types/ui/modelRuntime.d.ts +1 -0
- package/types/ui/useDismissDrag.d.ts +10 -3
- package/types/ui/useLeave.d.ts +9 -0
- package/types/vendor/@akanjs/native/packages/cli/src/lib/maven.d.ts +2 -2
- package/types/vendor/@akanjs/native/packages/core/src/boot.d.ts +2 -2
- package/types/vendor/@akanjs/native/plugins/keyboard/src/index.d.ts +3 -2
- package/types/vendor/use-agentic/types.d.ts +2 -0
- package/types/webkit/CsrMoves.d.ts +7 -0
- package/types/webkit/CsrStack.d.ts +2 -1
- package/types/webkit/McpAppHost.d.ts +4 -1
- package/types/webkit/csrPageReadiness.d.ts +18 -0
- package/types/webkit/csrPendingNavigation.d.ts +7 -0
- package/types/webkit/csrSlide.d.ts +37 -0
- package/types/webkit/isDragLift.d.ts +5 -0
- package/types/webkit/nativeNavigation.d.ts +4 -2
- package/types/webkit/nativeSplash.d.ts +6 -0
- package/types/webkit/openSurfaces.d.ts +13 -0
- package/types/webkit/scrollerTakesDrag.d.ts +4 -0
- package/types/webkit/useCsrNavigation.d.ts +2 -2
- package/types/webkit/useEscapeKey.d.ts +7 -2
- package/types/webkit/useFrameRuntime.d.ts +5 -2
- package/types/webkit/useResolvedFrame.d.ts +2 -0
- package/ui/Agent/Chat.tsx +65 -46
- package/ui/Agent/agentSessionOf.ts +2 -1
- package/ui/Agent/fetchRunner.ts +5 -1
- package/ui/Agent/useKeyboardFrame.ts +4 -2
- package/ui/BottomSheet.tsx +3 -7
- package/ui/Constant/schemaDoc.ts +1 -0
- package/ui/Copy.tsx +5 -3
- package/ui/Data/Dashboard.tsx +1 -0
- package/ui/Data/ListContainer.tsx +1 -0
- package/ui/Data/QueryMaker.tsx +1 -0
- package/ui/Data/RefPicker.tsx +1 -0
- package/ui/Dialog/LazyLegacyModal.tsx +5 -0
- package/ui/Dialog/LegacyModal.tsx +3 -4
- package/ui/Dialog/Modal.tsx +40 -22
- package/ui/Dialog/index.tsx +2 -2
- package/ui/Dialog/modalSurface.ts +6 -4
- package/ui/DismissDragGesture.tsx +19 -0
- package/ui/DragAction.tsx +9 -4
- package/ui/Field/Label.tsx +5 -2
- package/ui/Field/Text.tsx +7 -4
- package/ui/Field/index.tsx +2 -3
- package/ui/Field/lightRefCache.ts +9 -8
- package/ui/Field/useRelationOptions.ts +2 -2
- package/ui/Field/useRelationWindow.ts +9 -4
- package/ui/Input.tsx +1 -1
- package/ui/Link/Anchor.tsx +34 -5
- package/ui/Link/activePath.ts +2 -3
- package/ui/Link/index.tsx +11 -1
- package/ui/Load/LoadingMark.tsx +8 -0
- package/ui/Load/PageCSR.tsx +3 -1
- package/ui/Load/Stream.tsx +11 -1
- package/ui/Load/StreamDeferred.tsx +27 -0
- package/ui/Load/Units.tsx +4 -3
- package/ui/Load/sliceClaim.ts +11 -5
- package/ui/Model/EditModal.tsx +6 -7
- package/ui/Model/EditWrapper.tsx +2 -3
- package/ui/Model/NewWrapper_Client.tsx +2 -3
- package/ui/Model/ViewEditModal.tsx +4 -5
- package/ui/Model/ViewModal.tsx +2 -3
- package/ui/Model/ViewWrapper.tsx +2 -3
- package/ui/Model/editSeed.ts +1 -1
- package/ui/Model/resetModels.ts +11 -0
- package/ui/Signal/Arg.tsx +4 -1
- package/ui/Signal/Doc.tsx +12 -3
- package/ui/Signal/Endpoint.tsx +4 -1
- package/ui/Signal/RestApi.tsx +1 -0
- package/ui/Signal/WebSocket.tsx +1 -0
- package/ui/Signal/endpointEntries.ts +1 -0
- package/ui/Signal/makeExample.ts +1 -0
- package/ui/Signal/useApiDescriptions.ts +10 -0
- package/ui/System/CSR.tsx +31 -12
- package/ui/System/Client.tsx +75 -61
- package/ui/System/Messages.tsx +31 -47
- package/ui/System/isSamePathValue.ts +13 -0
- package/ui/Tooltip.tsx +1 -1
- package/ui/agentAttrs.ts +1 -1
- package/ui/modelRuntime.ts +2 -0
- package/ui/styles.css +14 -0
- package/ui/useDismissDrag.ts +135 -5
- package/ui/useLeave.ts +42 -0
- package/vendor/@akanjs/native/README.ko.md +1 -1
- package/vendor/@akanjs/native/README.md +1 -1
- package/vendor/@akanjs/native/THIRD_PARTY_NOTICES.md +78 -56
- package/vendor/@akanjs/native/native/android/maven.lock.json +462 -1
- package/vendor/@akanjs/native/native/android/src/com/akanjs/runtime/AkanNativeActivity.kt +27 -14
- package/vendor/@akanjs/native/native/ios/Sources/AkanNativePlugin.swift +9 -0
- package/vendor/@akanjs/native/packages/cli/src/lib/compat.ts +1 -1
- package/vendor/@akanjs/native/packages/cli/src/lib/distribution.ts +1 -1
- package/vendor/@akanjs/native/packages/cli/src/lib/maven.ts +12 -4
- package/vendor/@akanjs/native/packages/cli/src/platforms/android.ts +2 -2
- package/vendor/@akanjs/native/packages/core/src/boot.ts +2 -2
- package/vendor/@akanjs/native/plugins/browser/ios/BrowserPlugin.swift +4 -3
- package/vendor/@akanjs/native/plugins/camera/ios/CameraPlugin.swift +3 -0
- package/vendor/@akanjs/native/plugins/keyboard/src/index.ts +3 -2
- package/vendor/use-agentic/types.ts +2 -0
- package/webkit/CsrMoves.ts +30 -0
- package/webkit/CsrRouteTable.ts +2 -1
- package/webkit/CsrStack.ts +17 -9
- package/webkit/McpAppAgent.ts +1 -1
- package/webkit/McpAppFetchBridge.ts +1 -1
- package/webkit/McpAppHost.ts +14 -2
- package/webkit/RenderLayer.tsx +177 -79
- package/webkit/bootCsr.tsx +27 -9
- package/webkit/csrPageReadiness.ts +43 -0
- package/webkit/csrPendingNavigation.ts +24 -0
- package/webkit/csrSlide.ts +190 -0
- package/webkit/isDragLift.ts +7 -0
- package/webkit/nativeNavigation.ts +42 -4
- package/webkit/nativeSplash.ts +30 -0
- package/webkit/openSurfaces.ts +54 -0
- package/webkit/scrollerTakesDrag.ts +34 -0
- package/webkit/useCsrNavigation.ts +109 -36
- package/webkit/useCsrStackLifecycle.ts +2 -1
- package/webkit/useCsrTransitions.ts +190 -44
- package/webkit/useCsrValues.ts +57 -33
- package/webkit/useEscapeKey.tsx +10 -23
- package/webkit/useFrameRuntime.ts +11 -5
- package/webkit/usePageLocation.ts +4 -5
- package/ARCHITECTURE.md +0 -199
- package/CHANGELOG.md +0 -5264
- package/CODE_OF_CONDUCT.md +0 -54
- package/CONTRIBUTING.md +0 -109
- package/vendor/@akanjs/native/CHANGELOG.md +0 -32
- package/vendor/use-agentic/CHANGELOG.md +0 -708
package/README.ko.md
CHANGED
|
@@ -47,10 +47,13 @@ akan start <app-name> --open
|
|
|
47
47
|
### 기존 저장소 안에서 시작하기
|
|
48
48
|
|
|
49
49
|
앱이 놓일 폴더와 실행 방식이 정해진 작업이라면, 예를 들어 다른 저장소의 하위 폴더, Node와 npm만 있는 호스트, 스펙이 정한
|
|
50
|
-
URL이라면, 코딩 에이전트는 묻지 않고 아래대로 진행하면 됩니다.
|
|
50
|
+
URL이라면, 코딩 에이전트는 묻지 않고 아래대로 진행하면 됩니다. 스캐폴드에 필요한 것은 아래가 전부라서 다른 패키지의
|
|
51
|
+
README나 코드를 먼저 읽을 필요가 없습니다.
|
|
51
52
|
|
|
52
53
|
- **그 폴더에 바로 만들기:** `bunx create-akan-workspace@latest . --app <app> --dir <folder> --sample false`.
|
|
53
|
-
`<folder>` 자체에 쓰고, 이미 있는 파일은 덮어쓰지 않고 멈추며, 샘플 모듈과 페이지는 만들지 않습니다.
|
|
54
|
+
`<folder>` 자체에 쓰고, 이미 있는 파일은 덮어쓰지 않고 멈추며, 샘플 모듈과 페이지는 만들지 않습니다. `akan` CLI는
|
|
55
|
+
Bun의 전역 폴더(`~/.bun`, `PATH`에는 아무것도 넣지 않음)에 설치하고 `bun install`을 실행할 뿐, 빌드도 서버 실행도
|
|
56
|
+
하지 않으며, 다른 git 저장소가 추적하는 폴더에서는 `git init`도 커밋도 하지 않습니다. 함께 생기는
|
|
54
57
|
`AGENTS.md`, `CLAUDE.md`, `.claude/`, `.agents/`, `.cursor/`, `.mcp.json`은 지우지 마세요. 에이전트가 따를 규칙과
|
|
55
58
|
도구가 들어 있습니다.
|
|
56
59
|
- **`<folder>`에서 작업하기.** `akan`은 워크스페이스 루트에서만 실행되고, 그곳에서 연 에이전트 세션이 워크스페이스의
|
|
@@ -61,9 +64,9 @@ URL이라면, 코딩 에이전트는 묻지 않고 아래대로 진행하면 됩
|
|
|
61
64
|
(`/books/OL45804W`)로 내보내려면 `akan.config.ts`에 `i18n: { defaultLocale: "en", locales: ["en"], localePrefix:
|
|
62
65
|
"as-needed" }`를 두세요. `<Link>`도 따라갑니다.
|
|
63
66
|
- **Node와 npm만 있는 호스트:** `npx -y bun@1.4.4 x create-akan-workspace@latest . --app <app> --dir <folder> --sample false`를
|
|
64
|
-
실행한 뒤 `npm run build`, `PORT=3000 npm start`로 빌드하고
|
|
65
|
-
|
|
66
|
-
|
|
67
|
+
실행한 뒤 `npm run build`, `PORT=3000 npm start`로 빌드하고 띄우고, 나머지는 `npx akan <command>`로 실행합니다.
|
|
68
|
+
워크스페이스가 `bun`을 의존성에 넣어 둡니다. `npm i -g bun`으로 설치한 Bun으로 실행해도 같습니다. 새로 clone한 사본도 그대로 빌드됩니다. 빌드가 git이 무시하는 파일 중 없는
|
|
69
|
+
것을 먼저 씁니다.
|
|
67
70
|
- **실행할 곳에 맞게 빌드하기.** 셸이나 Bun이 읽는 `.env.local`에서 지정한 변수가 워크스페이스 `.env`보다 우선하고(빈
|
|
68
71
|
값은 지정하지 않은 것으로 보며, 빌드는 그렇게 가져간 값을 하나씩 알려 줍니다), `AKAN_PUBLIC_ENV`는 `--env`가 둘보다
|
|
69
72
|
우선합니다. 새 워크스페이스의 `.env`는 `local`이라 내 컴퓨터나 테스트 러너에서는 이대로 맞지만, 서버가
|
|
@@ -107,6 +110,7 @@ cd dist/apps/<app> && PORT=3000 bun main.js
|
|
|
107
110
|
- `akanjs`는 npm 패키지 하나입니다. subpath(`akanjs/base`, `akanjs/client`, `akanjs/signal`, `akanjs/ui`, …)가 서버
|
|
108
111
|
전용, 클라이언트 전용, UI, 툴링 코드를 나누고([패키지 레퍼런스](https://akanjs.com/references/akanjs/base)), 툴링은
|
|
109
112
|
`@akanjs/cli`와 `@akanjs/devkit`으로 나옵니다.
|
|
113
|
+
- 버전별 변경: [`CHANGELOG.md`](https://github.com/akan-team/akanjs/blob/main/pkgs/akanjs/CHANGELOG.md).
|
|
110
114
|
- 기여: [`CONTRIBUTING.md`](https://github.com/akan-team/akanjs/blob/main/pkgs/akanjs/CONTRIBUTING.md)와
|
|
111
115
|
[행동 강령](https://github.com/akan-team/akanjs/blob/main/pkgs/akanjs/CODE_OF_CONDUCT.md). 라이선스: MIT
|
|
112
116
|
([`LICENSE`](https://github.com/akan-team/akanjs/blob/main/pkgs/akanjs/LICENSE)).
|
package/README.md
CHANGED
|
@@ -46,11 +46,13 @@ generates a sample app. The app opens on `http://localhost:8282`.
|
|
|
46
46
|
### Inside an existing repository
|
|
47
47
|
|
|
48
48
|
When a task fixes where the app lives and how it runs, for example a folder in another repository, a host with only
|
|
49
|
-
Node and npm, or URLs given by a spec, a coding agent needs these, and nothing has to ask
|
|
49
|
+
Node and npm, or URLs given by a spec, a coding agent needs these, and nothing has to ask. They are the whole
|
|
50
|
+
scaffold: no other package's README or code has to be read first.
|
|
50
51
|
|
|
51
52
|
- **Create the workspace in that folder:** `bunx create-akan-workspace@latest . --app <app> --dir <folder> --sample false`.
|
|
52
53
|
It writes into `<folder>` itself, refuses to overwrite a file already there, and leaves out the sample module and
|
|
53
|
-
pages.
|
|
54
|
+
pages. It also puts the `akan` CLI in Bun's global folder (`~/.bun`, nothing on `PATH`) and runs `bun install`; it
|
|
55
|
+
builds and starts nothing, and in a folder another git repository tracks it neither runs `git init` nor commits. Keep the `AGENTS.md`, `CLAUDE.md`, `.claude/`, `.agents/`, `.cursor/` and `.mcp.json` it writes: they carry
|
|
54
56
|
the rules and tools an agent works through.
|
|
55
57
|
- **Work from `<folder>`.** `akan` runs only from the workspace root, and an agent session opened there loads the
|
|
56
58
|
workspace's rules and MCP server.
|
|
@@ -60,9 +62,8 @@ Node and npm, or URLs given by a spec, a coding agent needs these, and nothing h
|
|
|
60
62
|
set `i18n: { defaultLocale: "en", locales: ["en"], localePrefix: "as-needed" }` in `akan.config.ts`; `<Link>`
|
|
61
63
|
follows.
|
|
62
64
|
- **A host with only Node and npm:** `npx -y bun@1.4.4 x create-akan-workspace@latest . --app <app> --dir <folder> --sample false`,
|
|
63
|
-
then `npm run build` and `PORT=3000 npm start
|
|
64
|
-
|
|
65
|
-
scripts it writes and what a fresh clone needs.
|
|
65
|
+
then `npm run build` and `PORT=3000 npm start`, and `npx akan <command>` for the rest: the workspace lists `bun` in
|
|
66
|
+
its dependencies, as it does under a Bun from `npm i -g bun`. A fresh clone builds as is, since the build writes the git-ignored files it lacks.
|
|
66
67
|
- **Build for where it runs.** A variable set in the shell, or in a `.env.local` Bun loads, outranks the workspace `.env`
|
|
67
68
|
(an empty one counts as unset, and the build names each one it took), and `--env` outranks both for `AKAN_PUBLIC_ENV`. A new workspace's `.env` says `local`, which suits your own machine or a test runner, but the
|
|
68
69
|
server runs without endpoint rate limits and on local defaults. For a host others can reach, run
|
|
@@ -106,6 +107,7 @@ you are running on a public URL.
|
|
|
106
107
|
- `akanjs` is one npm package. Its subpaths (`akanjs/base`, `akanjs/client`, `akanjs/signal`, `akanjs/ui`, …) keep
|
|
107
108
|
server-only, client-only, UI and tooling code apart, and the [package reference](https://akanjs.com/references/akanjs/base)
|
|
108
109
|
covers them; the tooling ships as `@akanjs/cli` and `@akanjs/devkit`.
|
|
110
|
+
- Changes by version: [`CHANGELOG.md`](https://github.com/akan-team/akanjs/blob/main/pkgs/akanjs/CHANGELOG.md).
|
|
109
111
|
- Contributing: [`CONTRIBUTING.md`](https://github.com/akan-team/akanjs/blob/main/pkgs/akanjs/CONTRIBUTING.md) and
|
|
110
112
|
the [code of conduct](https://github.com/akan-team/akanjs/blob/main/pkgs/akanjs/CODE_OF_CONDUCT.md). License: MIT
|
|
111
113
|
([`LICENSE`](https://github.com/akan-team/akanjs/blob/main/pkgs/akanjs/LICENSE)).
|
package/base/utils.ts
CHANGED
|
@@ -25,3 +25,5 @@ export const applyFnToArrayObjects = <Input, Fn extends (arg: never) => unknown>
|
|
|
25
25
|
if (Array.isArray(arraiedData)) return arraiedData.map((data) => applyFnToArrayObjects(data, fn)) as Result;
|
|
26
26
|
return fn(arraiedData as never) as Result;
|
|
27
27
|
};
|
|
28
|
+
|
|
29
|
+
export const loadedAfter = (..._modules: unknown[]): void => {};
|
package/client/appOpenedTab.ts
CHANGED
package/client/clientRuntime.ts
CHANGED
|
@@ -38,6 +38,8 @@ type RuntimeErr = {
|
|
|
38
38
|
|
|
39
39
|
type RuntimeWs = {
|
|
40
40
|
connected: boolean;
|
|
41
|
+
state?: "connecting" | "open" | "closed" | "gaveUp";
|
|
42
|
+
connect?: (option?: { fresh?: boolean }) => void;
|
|
41
43
|
on: (event: string, handler: (...args: unknown[]) => void) => void;
|
|
42
44
|
off: (event: string, handler: (...args: unknown[]) => void) => void;
|
|
43
45
|
};
|
package/client/cookie.ts
CHANGED
|
@@ -153,25 +153,34 @@ export interface GetOption {
|
|
|
153
153
|
unauthorize: string;
|
|
154
154
|
}
|
|
155
155
|
interface SetAuthOption {
|
|
156
|
-
jwt
|
|
156
|
+
jwt?: string | null;
|
|
157
157
|
}
|
|
158
158
|
const announceAuth = () => {
|
|
159
159
|
if (typeof window !== "undefined") window.dispatchEvent(new Event("akan:auth"));
|
|
160
160
|
};
|
|
161
|
+
|
|
162
|
+
const reopenSocket = () => {
|
|
163
|
+
const { ws } = fetch;
|
|
164
|
+
if (ws?.state === "open" || ws?.state === "connecting") ws.connect?.({ fresh: true });
|
|
165
|
+
};
|
|
161
166
|
/** Sets the active auth token on fetch, then keeps it where the next launch finds it: client storage on a CSR client,
|
|
162
|
-
* the session cookie elsewhere unless the server already holds it there (`SessionCookie.issue`).
|
|
163
|
-
|
|
164
|
-
|
|
167
|
+
* the session cookie elsewhere unless the server already holds it there (`SessionCookie.issue`). An answer with no
|
|
168
|
+
* token beside a session the server holds is a cookie-only session: fetch sends no token and the socket reconnects. */
|
|
169
|
+
export const setAuth = ({ jwt }: SetAuthOption = {}) => {
|
|
170
|
+
const token = jwt ?? "";
|
|
171
|
+
const cookieOnly = !token && serverHoldsSession();
|
|
172
|
+
fetch.setJwt(cookieOnly ? null : token);
|
|
165
173
|
|
|
166
|
-
if (isCsrClient()) void secretStorage.setItem(storedAuthTokenKey(),
|
|
174
|
+
if (isCsrClient()) void secretStorage.setItem(storedAuthTokenKey(), token);
|
|
167
175
|
else {
|
|
168
176
|
|
|
169
177
|
void secretStorage.removeItem(storedAuthTokenKey());
|
|
170
|
-
if (!serverHoldsSession()) setCookie(authTokenKey(),
|
|
178
|
+
if (!serverHoldsSession()) setCookie(authTokenKey(), token);
|
|
171
179
|
}
|
|
172
180
|
|
|
173
181
|
for (const key of retiredAuthTokenKeys()) removeCookie(key);
|
|
174
182
|
void secretStorage.removeItem(legacyAuthTokenKey);
|
|
183
|
+
if (cookieOnly) reopenSocket();
|
|
175
184
|
announceAuth();
|
|
176
185
|
};
|
|
177
186
|
|
package/client/csrLocation.ts
CHANGED
|
@@ -4,12 +4,16 @@ declare global {
|
|
|
4
4
|
var __AKAN_EMBED__: { kind: "mcp-app"; origin?: string; account?: Record<string, unknown> | null } | undefined;
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
+
const popWaitMs = 1000;
|
|
8
|
+
|
|
7
9
|
/** The document's location and history, as the routers read and move them. */
|
|
8
10
|
export class CsrLocation {
|
|
9
11
|
|
|
10
12
|
#view: URL | null = null;
|
|
11
|
-
#entry: { idx: number | undefined; href: string } | null = null;
|
|
13
|
+
#entry: { idx: number | undefined; href: string; from: string | undefined } | null = null;
|
|
12
14
|
#onBack: ((idx: number) => void) | null = null;
|
|
15
|
+
#backAsked: object | null = null;
|
|
16
|
+
#backSent: object | null = null;
|
|
13
17
|
|
|
14
18
|
/** Reads `href`, a path on the app's origin, as this document's location from now on; a view never moves. */
|
|
15
19
|
view(href: string) {
|
|
@@ -44,25 +48,28 @@ export class CsrLocation {
|
|
|
44
48
|
}
|
|
45
49
|
|
|
46
50
|
/**
|
|
47
|
-
* The entry on screen as of the last write or traversal,
|
|
48
|
-
*
|
|
51
|
+
* The entry on screen as of the last write or traversal, its index, and `from`, the address a push stacked it on
|
|
52
|
+
* (none for an entry a document load or a fragment link made); during a `popstate` it is still the entry left,
|
|
53
|
+
* which `state` no longer reads.
|
|
49
54
|
*/
|
|
50
55
|
entry() {
|
|
51
56
|
return this.#entry ?? this.observe();
|
|
52
57
|
}
|
|
53
58
|
|
|
54
59
|
observe() {
|
|
55
|
-
|
|
60
|
+
const state = window.history?.state;
|
|
61
|
+
this.#entry = { idx: CsrLocation.idxOf(state), href: this.href, from: CsrLocation.#fromOf(state) };
|
|
56
62
|
return this.#entry;
|
|
57
63
|
}
|
|
58
64
|
|
|
59
65
|
push(state: unknown, href: string) {
|
|
60
|
-
|
|
66
|
+
const stacked = CsrLocation.#indexed(state, (this.entry().idx ?? 0) + 1) as { __akanRouter?: object };
|
|
67
|
+
window.history.pushState({ ...stacked, __akanRouter: { ...stacked.__akanRouter, from: this.href } }, "", href);
|
|
61
68
|
this.observe();
|
|
62
69
|
}
|
|
63
70
|
|
|
64
71
|
replace(state: unknown, href?: string) {
|
|
65
|
-
const indexed = CsrLocation.#indexed(state, this.entry().idx ?? 0);
|
|
72
|
+
const indexed = CsrLocation.#rewritten(CsrLocation.#indexed(state, this.entry().idx ?? 0), window.history.state);
|
|
66
73
|
if (href === undefined) window.history.replaceState(indexed, "");
|
|
67
74
|
else window.history.replaceState(indexed, "", href);
|
|
68
75
|
this.observe();
|
|
@@ -73,6 +80,18 @@ export class CsrLocation {
|
|
|
73
80
|
return Number.isInteger(idx) ? (idx as number) : undefined;
|
|
74
81
|
}
|
|
75
82
|
|
|
83
|
+
static #fromOf(state: unknown) {
|
|
84
|
+
const from = (state as { __akanRouter?: { from?: unknown } } | null)?.__akanRouter?.from;
|
|
85
|
+
return typeof from === "string" ? from : undefined;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
static #rewritten(state: unknown, live: unknown) {
|
|
89
|
+
const from = CsrLocation.#fromOf(live);
|
|
90
|
+
if (from === undefined || CsrLocation.#fromOf(state) !== undefined) return state;
|
|
91
|
+
const record = (state ?? {}) as { __akanRouter?: object };
|
|
92
|
+
return { ...record, __akanRouter: { ...record.__akanRouter, from } };
|
|
93
|
+
}
|
|
94
|
+
|
|
76
95
|
static #indexed(state: unknown, idx: number) {
|
|
77
96
|
if (CsrLocation.idxOf(state) !== undefined) return state;
|
|
78
97
|
const record = (state ?? {}) as { __akanRouter?: object };
|
|
@@ -84,10 +103,43 @@ export class CsrLocation {
|
|
|
84
103
|
this.#onBack = listener;
|
|
85
104
|
}
|
|
86
105
|
|
|
87
|
-
back()
|
|
88
|
-
|
|
89
|
-
|
|
106
|
+
/** Holds the entry on screen as left until `moving`, a shell's back, settles; `back()` holds it until the pop lands. */
|
|
107
|
+
leaving(moving: unknown) {
|
|
108
|
+
const entry = this.entry();
|
|
109
|
+
this.#backAsked = entry;
|
|
110
|
+
const release = () => {
|
|
111
|
+
if (this.#backAsked === entry) this.#backAsked = null;
|
|
112
|
+
};
|
|
113
|
+
void Promise.resolve(moving).then(release, release);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/** Whether a back has left the entry on screen and not landed yet. */
|
|
117
|
+
isLeaving() {
|
|
118
|
+
const entry = this.entry();
|
|
119
|
+
return entry === this.#backAsked || entry === this.#backSent;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/** Settles once the back's pop has moved the address, or at once when no entry of this document is under it. */
|
|
123
|
+
back(): Promise<void> {
|
|
124
|
+
const entry = this.entry();
|
|
125
|
+
if (entry.idx !== undefined) this.#onBack?.(entry.idx - 1);
|
|
126
|
+
|
|
127
|
+
const pops = entry.idx !== undefined && entry.idx > 0;
|
|
128
|
+
if (pops) this.#backSent = entry;
|
|
129
|
+
const landed = pops ? CsrLocation.#nextPop() : Promise.resolve();
|
|
90
130
|
window.history.back();
|
|
131
|
+
return landed;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
static #nextPop() {
|
|
135
|
+
return new Promise<void>((resolve) => {
|
|
136
|
+
const land = () => {
|
|
137
|
+
clearTimeout(cap);
|
|
138
|
+
resolve();
|
|
139
|
+
};
|
|
140
|
+
const cap = setTimeout(land, popWaitMs);
|
|
141
|
+
window.addEventListener("popstate", land, { once: true });
|
|
142
|
+
});
|
|
91
143
|
}
|
|
92
144
|
|
|
93
145
|
assign(href: string) {
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { csrLocation } from "./csrLocation";
|
|
2
|
+
import { Href } from "./href";
|
|
3
|
+
|
|
4
|
+
/** The params a CSR boot reads off its address (`?csr=true`), which every address it moves to carries along. */
|
|
5
|
+
export class CsrRuntimeParams {
|
|
6
|
+
static readonly #names = ["csr", "akanMobileTarget", "akanMobileBasePath", "akanMobileIndexPath"] as const;
|
|
7
|
+
|
|
8
|
+
static carry(href: string) {
|
|
9
|
+
const currentSearch = new URLSearchParams(csrLocation.search);
|
|
10
|
+
if (currentSearch.get("csr") !== "true" || Href.hasWebScheme(href)) return href;
|
|
11
|
+
|
|
12
|
+
const [hrefWithoutHash, hash = ""] = href.split("#");
|
|
13
|
+
const [pathname, search = ""] = hrefWithoutHash.split("?");
|
|
14
|
+
const nextSearch = new URLSearchParams(search);
|
|
15
|
+
for (const param of CsrRuntimeParams.#names) {
|
|
16
|
+
if (nextSearch.has(param)) continue;
|
|
17
|
+
const value = currentSearch.get(param);
|
|
18
|
+
if (value !== null) nextSearch.set(param, value);
|
|
19
|
+
}
|
|
20
|
+
const query = nextSearch.toString();
|
|
21
|
+
return `${pathname}${query ? `?${query}` : ""}${hash ? `#${hash}` : ""}`;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
static sameRoute(a: string, b: string) {
|
|
25
|
+
const [left, right] = [a, b].map((href) => {
|
|
26
|
+
const url = new URL(href, "http://route.invalid");
|
|
27
|
+
for (const param of CsrRuntimeParams.#names) url.searchParams.delete(param);
|
|
28
|
+
url.searchParams.sort();
|
|
29
|
+
return `${url.pathname}?${url.searchParams.toString()}${url.hash}`;
|
|
30
|
+
});
|
|
31
|
+
return left === right;
|
|
32
|
+
}
|
|
33
|
+
}
|
package/client/csrTypes.ts
CHANGED
|
@@ -21,6 +21,9 @@ export type PageSafeAreaConfig =
|
|
|
21
21
|
};
|
|
22
22
|
/** The sides whose chrome the page runs under instead of below. */
|
|
23
23
|
export type PageOverlayConfig = boolean | "top" | "bottom";
|
|
24
|
+
|
|
25
|
+
/** How a page's navbar moves when it transitions; see `PageConfig.navbarMotion`. */
|
|
26
|
+
export type NavbarMotion = "crossfade" | "page";
|
|
24
27
|
/** `"stream"` flushes the shell (`Loading` included) then streams; a redirect in suspended content becomes a client one.
|
|
25
28
|
* `"block"` buffers the whole document, so an error in slow content can still render a clean error page. */
|
|
26
29
|
export type SsrRenderMode = "stream" | "block";
|
|
@@ -42,14 +45,23 @@ export interface PageConfig {
|
|
|
42
45
|
* and an overlaid side's safe area defaults to transparent.
|
|
43
46
|
*/
|
|
44
47
|
overlay?: PageOverlayConfig;
|
|
48
|
+
/**
|
|
49
|
+
* How the navbar (`Layout.Navbar`'s top inset and its back button) moves when this page transitions.
|
|
50
|
+
* `"crossfade"`, the default, keeps one bar in place and crossfades the two pages' bars, as UIKit's does; between a
|
|
51
|
+
* page with a bar and one without, the bar's height folds away. `"page"` moves each bar with its page, as a part of
|
|
52
|
+
* the page, for a bar that is the page's own surface (translucent, or with no fill of its own).
|
|
53
|
+
*/
|
|
54
|
+
navbarMotion?: NavbarMotion;
|
|
45
55
|
gesture?: boolean;
|
|
46
56
|
cache?: boolean;
|
|
47
57
|
/** Initial full-document SSR strategy. Defaults to `"stream"`. */
|
|
48
58
|
ssr?: SsrRenderMode;
|
|
49
59
|
/**
|
|
50
60
|
* Opt-in suffix-only RSC commits under `AKAN_PUBLIC_RSC_PARTIAL_COMMIT=1`: the page's `.head()` is plain `title`,
|
|
51
|
-
* `meta` and `link` tags, and the layouts above it
|
|
52
|
-
*
|
|
61
|
+
* `meta` and `link` tags, and the layouts above it draw on the server only from the args they declare. A move to a
|
|
62
|
+
* sibling page, or to another param or query of this page that no layout above declares with `.param()` or
|
|
63
|
+
* `.search()`, then renders the page alone and keeps those layouts as drawn; what follows the path in them is read
|
|
64
|
+
* on the client (`usePathCtx()`, `Link`'s `activeClassName`).
|
|
53
65
|
*/
|
|
54
66
|
rscPatchHeadSafe?: boolean;
|
|
55
67
|
/** `false` answers a `Link` prefetch of the page (on a layout, of every page under it) without rendering it, for a
|
|
@@ -77,6 +89,8 @@ export interface CsrState {
|
|
|
77
89
|
/** Web only: the sides whose safe area `env(safe-area-inset-*)` measures, since a browser tells script nothing. */
|
|
78
90
|
safeAreaEnv?: { top: boolean; bottom: boolean };
|
|
79
91
|
overlay?: { top: boolean; bottom: boolean };
|
|
92
|
+
/** Set when the page declares one; left out, the navbar crossfades. */
|
|
93
|
+
navbarMotion?: NavbarMotion;
|
|
80
94
|
gesture: boolean;
|
|
81
95
|
cache: boolean;
|
|
82
96
|
ssr: SsrRenderMode;
|
|
@@ -168,6 +182,8 @@ export interface RouteRender {
|
|
|
168
182
|
getRouteDefinition?: () => PromiseOrObject<RouteDefinition | undefined>;
|
|
169
183
|
/** The query names the level reads; `undefined` for a legacy module, which receives every one. */
|
|
170
184
|
getSearchNames?: () => PromiseOrObject<string[] | undefined>;
|
|
185
|
+
/** The params the level reads beyond `lang`; `undefined` for a legacy module, which receives every one. */
|
|
186
|
+
getParamNames?: () => PromiseOrObject<string[] | undefined>;
|
|
171
187
|
}
|
|
172
188
|
export interface RouteViewport {
|
|
173
189
|
/** `viewport-fit=cover`: the page runs under the notch and home indicator, and `env(safe-area-inset-*)` measures them. */
|
|
@@ -416,6 +432,10 @@ export const pageActivityContext = sharedContext<PageActivityState>("pageActivit
|
|
|
416
432
|
export interface PathRoute {
|
|
417
433
|
path: string;
|
|
418
434
|
pathSegments: string[];
|
|
435
|
+
/** The not-found view a path no page matches draws, under the layouts it reached. */
|
|
436
|
+
notFound?: true;
|
|
437
|
+
/** The pages matched ahead of this one that take some of its paths, as `/:lang/chat/new` does of `/:lang/chat/:id`. */
|
|
438
|
+
shadowedBy?: string[];
|
|
419
439
|
renderPage: RouteRender;
|
|
420
440
|
pageState: PageState;
|
|
421
441
|
pageConfigChain?: PageConfig[];
|
package/client/device.ts
CHANGED
|
@@ -1,22 +1,30 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import { parseAkanI18nEnv } from "akanjs/common";
|
|
2
3
|
import type { RefObject } from "react";
|
|
3
4
|
import { csrLocation } from "./csrLocation";
|
|
4
5
|
import { readCssSafeAreaInsets } from "./frameConfig";
|
|
5
6
|
import type { DeviceInfo } from "./native";
|
|
6
7
|
|
|
7
8
|
type NativeModule = typeof import("./native");
|
|
9
|
+
type KeyboardRideClass = typeof import("./keyboardRide").KeyboardRide;
|
|
8
10
|
type NativeControls = Pick<NativeModule, "haptics" | "keyboard">;
|
|
9
11
|
type ProcessEnvLike = { env?: Record<string, string | undefined> };
|
|
10
12
|
type DebugPayload = Record<string, unknown>;
|
|
11
13
|
|
|
12
14
|
const globalWithProcess = globalThis as typeof globalThis & { process?: ProcessEnvLike };
|
|
13
15
|
|
|
14
|
-
/** Whether the
|
|
16
|
+
/** Whether the shell left the keyboard to the page; an older shell still pans to the field, so the page must not. */
|
|
15
17
|
export const isPageKeyboardAvoidance = () =>
|
|
16
18
|
(globalThis as { __AKAN_NATIVE__?: { keyboardAvoidance?: string } }).__AKAN_NATIVE__?.keyboardAvoidance === "page";
|
|
17
19
|
|
|
18
20
|
export const IOS_KEYBOARD_ANIMATION_EASING = "cubic-bezier(0.38, 0.7, 0.125, 1)";
|
|
19
21
|
|
|
22
|
+
export const ANDROID_KEYBOARD_ANIMATION_EASING = "cubic-bezier(0.2, 0, 0, 1)";
|
|
23
|
+
export const nativeKeyboardEasing = () =>
|
|
24
|
+
(globalThis as { __AKAN_NATIVE__?: { platform?: string } }).__AKAN_NATIVE__?.platform === "android"
|
|
25
|
+
? ANDROID_KEYBOARD_ANIMATION_EASING
|
|
26
|
+
: IOS_KEYBOARD_ANIMATION_EASING;
|
|
27
|
+
|
|
20
28
|
const debugSessionId = crypto.getRandomValues(new Uint32Array(1))[0].toString(36);
|
|
21
29
|
let debugSeq = 0;
|
|
22
30
|
|
|
@@ -98,6 +106,12 @@ const langInPath = (pathname: string, supportLanguages: string[] | readonly stri
|
|
|
98
106
|
return supportLanguages.find((language) => language === predefinedLangPath);
|
|
99
107
|
};
|
|
100
108
|
|
|
109
|
+
const supportedLang = (code: string, supportLanguages: string[] | readonly string[]) => {
|
|
110
|
+
if (supportLanguages.length === 0 || supportLanguages.includes(code)) return code;
|
|
111
|
+
const { defaultLocale } = parseAkanI18nEnv();
|
|
112
|
+
return supportLanguages.includes(defaultLocale) ? defaultLocale : (supportLanguages[0] ?? code);
|
|
113
|
+
};
|
|
114
|
+
|
|
101
115
|
const createWebDevice = ({
|
|
102
116
|
lang,
|
|
103
117
|
supportLanguages,
|
|
@@ -107,7 +121,7 @@ const createWebDevice = ({
|
|
|
107
121
|
}) => {
|
|
108
122
|
const pathname = typeof window === "undefined" ? "" : csrLocation.pathname;
|
|
109
123
|
return new Device({
|
|
110
|
-
lang: lang ?? langInPath(pathname, supportLanguages) ?? getBrowserLanguage(),
|
|
124
|
+
lang: lang ?? langInPath(pathname, supportLanguages) ?? supportedLang(getBrowserLanguage(), supportLanguages),
|
|
111
125
|
info: webDeviceInfo,
|
|
112
126
|
topSafeArea: 0,
|
|
113
127
|
bottomSafeArea: 0,
|
|
@@ -139,7 +153,8 @@ export class Device {
|
|
|
139
153
|
|
|
140
154
|
const { top: topSafeArea, bottom: bottomSafeArea } = readCssSafeAreaInsets();
|
|
141
155
|
Device.instance = new Device({
|
|
142
|
-
lang:
|
|
156
|
+
lang:
|
|
157
|
+
lang ?? langInPath(window.location.pathname, supportLanguages) ?? supportedLang(languageCode, supportLanguages),
|
|
143
158
|
info,
|
|
144
159
|
topSafeArea,
|
|
145
160
|
bottomSafeArea,
|
|
@@ -177,9 +192,16 @@ export class Device {
|
|
|
177
192
|
async hideKeyboard() {
|
|
178
193
|
await this.#native?.keyboard.hide();
|
|
179
194
|
}
|
|
195
|
+
|
|
196
|
+
static #keyboardRide: KeyboardRideClass | null = null;
|
|
180
197
|
listenKeyboardChanged(onKeyboardChanged: (height: number) => void) {
|
|
181
198
|
const keyboard = this.#native?.keyboard;
|
|
182
199
|
if (!keyboard) return;
|
|
200
|
+
if (isPageKeyboardAvoidance())
|
|
201
|
+
void import("./keyboardRide").then(({ KeyboardRide }) => {
|
|
202
|
+
Device.#keyboardRide = KeyboardRide;
|
|
203
|
+
KeyboardRide.watchFocus();
|
|
204
|
+
});
|
|
183
205
|
let currentHeight = 0;
|
|
184
206
|
const emitKeyboardHeight = (event: string, height: number) => {
|
|
185
207
|
debugFrame("keyboard.event", { event, height, previousHeight: currentHeight });
|
|
@@ -193,22 +215,12 @@ export class Device {
|
|
|
193
215
|
...(["willShow", "didShow", "willHide", "didHide"] as const).map((event) =>
|
|
194
216
|
keyboard.listen(event, ({ height, duration }) => {
|
|
195
217
|
if (duration > 0) this.keyboardAnimationMs = duration;
|
|
196
|
-
|
|
218
|
+
Device.#keyboardRide?.move(height, this.keyboardAnimationMs);
|
|
197
219
|
emitKeyboardHeight(event, height);
|
|
198
220
|
}),
|
|
199
221
|
),
|
|
200
222
|
);
|
|
201
223
|
}
|
|
202
|
-
|
|
203
|
-
#moveRootWithKeyboard(height: number) {
|
|
204
|
-
const root = document.documentElement;
|
|
205
|
-
if (this.keyboardAnimationMs > 0) {
|
|
206
|
-
root.style.setProperty("--akan-keyboard-duration", `${this.keyboardAnimationMs}ms`);
|
|
207
|
-
root.style.setProperty("--akan-keyboard-easing", IOS_KEYBOARD_ANIMATION_EASING);
|
|
208
|
-
}
|
|
209
|
-
root.style.setProperty("--akan-keyboard-cover", `${height}px`);
|
|
210
|
-
root.toggleAttribute("data-akan-keyboard", height > 0);
|
|
211
|
-
}
|
|
212
224
|
subscribeKeyboard(onKeyboardChanged: (height: number) => void) {
|
|
213
225
|
this.#keyboardSubscribers.add(onKeyboardChanged);
|
|
214
226
|
return () => {
|
|
@@ -1,32 +1,110 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type DictionaryModule, importDictionaryModule } from "./dictionaryModule";
|
|
2
|
+
import { DictionaryPart } from "./dictionaryPart";
|
|
3
|
+
import { TranslatorState } from "./translatorState";
|
|
2
4
|
|
|
3
|
-
interface
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
interface DictionaryAssetState {
|
|
6
|
+
loads: Map<string, Promise<DictionaryModule>>;
|
|
7
|
+
appliedSeqByLang: Map<string, number>;
|
|
8
|
+
seq: number;
|
|
9
|
+
|
|
10
|
+
wholes: WeakSet<object>;
|
|
11
|
+
|
|
12
|
+
groupsBySnapshot: WeakMap<object, Set<string>>;
|
|
6
13
|
}
|
|
7
14
|
|
|
15
|
+
const dictionaryAssetStateKey = "__AKAN_DICTIONARY_ASSET__";
|
|
16
|
+
|
|
8
17
|
export class DictionaryAsset {
|
|
9
|
-
static
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
18
|
+
static #state(): DictionaryAssetState {
|
|
19
|
+
const globalScope = globalThis as typeof globalThis & { [dictionaryAssetStateKey]?: DictionaryAssetState };
|
|
20
|
+
globalScope[dictionaryAssetStateKey] ??= {
|
|
21
|
+
loads: new Map(),
|
|
22
|
+
appliedSeqByLang: new Map(),
|
|
23
|
+
seq: 0,
|
|
24
|
+
wholes: new WeakSet(),
|
|
25
|
+
groupsBySnapshot: new WeakMap(),
|
|
26
|
+
};
|
|
27
|
+
return globalScope[dictionaryAssetStateKey];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
static async load(urls: string | readonly string[] | null | undefined): Promise<void> {
|
|
31
|
+
const list = (typeof urls === "string" ? urls.split(",") : (urls ?? [])).filter(Boolean);
|
|
32
|
+
if (!list.length) return;
|
|
33
|
+
const state = DictionaryAsset.#state();
|
|
34
|
+
const seq = ++state.seq;
|
|
35
|
+
TranslatorState.get().loadSeq = seq;
|
|
36
|
+
const loaded = await Promise.allSettled(list.map((url) => DictionaryAsset.#loading(url)));
|
|
37
|
+
loaded.forEach((result, idx) => {
|
|
38
|
+
const url = list[idx];
|
|
39
|
+
if (result.status === "fulfilled" && url) DictionaryAsset.#apply(url, result.value, seq);
|
|
40
|
+
});
|
|
41
|
+
const failed = loaded.find((result) => result.status === "rejected");
|
|
42
|
+
if (failed) throw failed.reason;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
static async add(url: string): Promise<boolean> {
|
|
46
|
+
const dictionaryModule = await DictionaryAsset.#loading(url);
|
|
47
|
+
return DictionaryAsset.#apply(url, dictionaryModule, null);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
static holdsEveryGroup(lang: string): boolean {
|
|
51
|
+
const replaced = TranslatorState.get().replacedByLang.get(lang);
|
|
52
|
+
return !!replaced && DictionaryAsset.#state().wholes.has(replaced);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
static holdsGroup(lang: string, group: string): boolean {
|
|
56
|
+
const replaced = TranslatorState.get().replacedByLang.get(lang);
|
|
57
|
+
return !!replaced && !!DictionaryAsset.#state().groupsBySnapshot.get(replaced)?.has(group);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
static #markGroups(snapshot: object, groups: readonly string[]) {
|
|
61
|
+
const { groupsBySnapshot } = DictionaryAsset.#state();
|
|
62
|
+
const marked = groupsBySnapshot.get(snapshot) ?? new Set<string>();
|
|
63
|
+
for (const group of groups) marked.add(group);
|
|
64
|
+
groupsBySnapshot.set(snapshot, marked);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
static #apply(
|
|
68
|
+
url: string,
|
|
69
|
+
{ lang, default: dictionary, parts, table, groups, part }: DictionaryModule,
|
|
70
|
+
seq: number | null,
|
|
71
|
+
) {
|
|
72
|
+
const state = DictionaryAsset.#state();
|
|
73
|
+
const translator = TranslatorState.get();
|
|
74
|
+
const replaced = translator.replacedByLang.get(lang);
|
|
75
|
+
if (part)
|
|
76
|
+
return (
|
|
77
|
+
!!replaced && DictionaryPart.urlOf(lang, part) === url && DictionaryPart.merge(lang, url, dictionary, replaced)
|
|
78
|
+
);
|
|
79
|
+
const sameBuild = !!table && !!replaced && translator.tableByLang.get(lang) === table;
|
|
80
|
+
if (groups && sameBuild) {
|
|
81
|
+
if (!state.wholes.has(replaced) && DictionaryPart.merge(lang, url, dictionary, replaced))
|
|
82
|
+
DictionaryAsset.#markGroups(replaced, groups);
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
if (seq === null || (state.appliedSeqByLang.get(lang) ?? 0) > seq) return false;
|
|
86
|
+
state.appliedSeqByLang.set(lang, seq);
|
|
87
|
+
if (!groups) {
|
|
88
|
+
state.wholes.add(dictionary);
|
|
89
|
+
TranslatorState.replace(lang, dictionary, parts, table);
|
|
90
|
+
return true;
|
|
30
91
|
}
|
|
92
|
+
const base = {};
|
|
93
|
+
TranslatorState.replace(lang, base, parts, table);
|
|
94
|
+
const merged = DictionaryPart.merge(lang, url, dictionary, base);
|
|
95
|
+
if (merged) DictionaryAsset.#markGroups(base, groups);
|
|
96
|
+
return merged;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
static #loading(url: string): Promise<DictionaryModule> {
|
|
100
|
+
const { loads } = DictionaryAsset.#state();
|
|
101
|
+
const known = loads.get(url);
|
|
102
|
+
if (known) return known;
|
|
103
|
+
const loading = importDictionaryModule(url).catch((error: unknown) => {
|
|
104
|
+
loads.delete(url);
|
|
105
|
+
throw error;
|
|
106
|
+
});
|
|
107
|
+
loads.set(url, loading);
|
|
108
|
+
return loading;
|
|
31
109
|
}
|
|
32
110
|
}
|