akanjs 3.2.0-rc.11 → 3.2.0-rc.13
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 +17 -17
- package/CHANGELOG.md +24 -0
- package/base/base.ts +2 -1
- package/client/clientRuntime.ts +1 -0
- package/client/cn.ts +2 -2
- package/client/csrTypes.ts +2 -0
- package/client/frameConfig.ts +1 -0
- package/client/index.ts +249 -26
- package/client/locale.ts +1 -0
- package/client/route/RouteDefinition.ts +24 -7
- package/client/route/routeArgs.ts +7 -0
- package/client/router.ts +12 -2
- package/client/rscNavigation.ts +1 -0
- package/common/CodeTranscript.ts +1 -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/locale.ts +1 -1
- 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/types.ts +1 -1
- package/fetch/client/fetchClient.ts +3 -3
- package/fetch/client/httpClient.ts +2 -0
- package/fetch/client/wsClient.ts +1 -0
- package/package.json +1 -1
- package/server/akanApp.ts +103 -1270
- package/server/akanServer.ts +1 -1
- package/server/console.ts +3 -2
- package/server/gateway/childSupervisor.ts +325 -0
- package/server/gateway/devHostChannel.ts +40 -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 +134 -0
- package/server/gateway/gatewayStatus.ts +116 -0
- package/server/gateway/gatewayStatusPage.ts +54 -0
- package/server/gateway/gatewayWebSocketRelay.ts +149 -0
- package/server/index.ts +257 -17
- package/server/logging/logControlSocket.ts +42 -3
- package/server/mcp/McpDispatcher.ts +6 -24
- package/server/rscClient.tsx +14 -8
- package/server/sitemap.ts +1 -0
- package/service/injectInfo.ts +2 -1
- package/service/predefinedAdaptor/sql/driver/bunSqlite.ts +3 -3
- package/service/predefinedAdaptor/sql/driver/postgres.ts +1 -1
- package/service/serviceRegistry.ts +1 -0
- package/signal/SignalFailure.ts +21 -0
- package/signal/agentTurnStream.ts +5 -2
- package/signal/index.ts +298 -30
- package/signal/resolveFieldContext.ts +34 -0
- package/signal/serializer/fetch.serializer.ts +7 -10
- package/signal/signalContext.ts +4 -31
- package/signal/trace.ts +3 -0
- package/store/baseSt.ts +1 -0
- package/store/index.ts +125 -18
- package/store/stateBuilder.ts +2 -0
- 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 +2 -0
- 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/route/RouteDefinition.d.ts +2 -2
- package/types/client/route/routeArgs.d.ts +6 -0
- package/types/client/router.d.ts +2 -1
- package/types/client/rscNavigation.d.ts +1 -0
- package/types/common/CodeTranscript.d.ts +1 -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/base.dictionary.d.ts +1 -1
- package/types/dictionary/dictionary.d.ts +8 -8
- package/types/dictionary/locale.d.ts +1 -1
- 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/types.d.ts +1 -1
- package/types/fetch/client/fetchClient.d.ts +2 -1
- package/types/fetch/client/httpClient.d.ts +2 -0
- package/types/fetch/client/wsClient.d.ts +1 -0
- package/types/server/akanApp.d.ts +2 -20
- package/types/server/console.d.ts +3 -2
- package/types/server/gateway/childSupervisor.d.ts +33 -0
- package/types/server/gateway/devHostChannel.d.ts +13 -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 +22 -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/index.d.ts +17 -17
- package/types/server/logging/rotatingLogWriter.d.ts +1 -1
- package/types/server/sitemap.d.ts +1 -0
- package/types/service/injectInfo.d.ts +2 -1
- 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/serviceRegistry.d.ts +1 -0
- package/types/signal/SignalFailure.d.ts +1 -0
- package/types/signal/agentTurnStream.d.ts +1 -0
- package/types/signal/index.d.ts +31 -30
- 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/trace.d.ts +3 -0
- package/types/store/baseSt.d.ts +1 -0
- package/types/store/index.d.ts +17 -17
- package/types/store/stateBuilder.d.ts +2 -0
- 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/Reference/origin.d.ts +1 -0
- package/types/ui/overlayLayer.d.ts +6 -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/external-view/src/index.d.ts +14 -10
- package/types/vendor/use-agentic/failureCode.d.ts +4 -0
- package/types/vendor/use-agentic/types.d.ts +6 -0
- package/types/webkit/CsrGuards.d.ts +2 -0
- package/ui/Agent/Chat.tsx +96 -116
- 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/Dialog/LegacyModal.tsx +1 -1
- package/ui/Dialog/Modal.tsx +1 -1
- package/ui/Popconfirm.tsx +1 -1
- package/ui/Reference/origin.ts +1 -0
- package/ui/overlayLayer.ts +22 -1
- package/vendor/@akanjs/native/CHANGELOG.md +6 -1
- 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 +275 -0
- package/vendor/@akanjs/native/native/desktop/src/linux/mod.rs +1 -0
- 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/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 +14 -10
- package/vendor/use-agentic/AgentSession.ts +11 -11
- package/vendor/use-agentic/CHANGELOG.md +6 -0
- package/vendor/use-agentic/Compaction.ts +2 -1
- package/vendor/use-agentic/ToolRunner.ts +3 -15
- package/vendor/use-agentic/Transcript.ts +6 -3
- package/vendor/use-agentic/WIRE.md +12 -1
- package/vendor/use-agentic/failureCode.ts +44 -0
- package/vendor/use-agentic/httpRunner.ts +14 -3
- package/vendor/use-agentic/types.ts +6 -0
- package/webkit/CsrGuards.ts +7 -2
- package/webkit/useLocation.ts +3 -2
package/ARCHITECTURE.md
CHANGED
|
@@ -86,23 +86,23 @@ Declared in [service/ipcTypes.ts](service/ipcTypes.ts).
|
|
|
86
86
|
| --- | --- | --- |
|
|
87
87
|
| `ready` | `AkanServer` | `AkanApp` |
|
|
88
88
|
| `pubsub.publish` | `SolidPubSub` | `AkanApp` |
|
|
89
|
-
| `pubsub.deliver` | `
|
|
89
|
+
| `pubsub.deliver` | `GatewayRooms` | `SolidPubSub` |
|
|
90
90
|
| `pubsub.subscribe` | `SolidPubSub` | `AkanApp` |
|
|
91
91
|
| `pubsub.unsubscribe` | `SolidPubSub` | `AkanApp` |
|
|
92
|
-
| `pubsub.snapshot.request` | `
|
|
92
|
+
| `pubsub.snapshot.request` | `GatewayRooms` | `SolidPubSub` |
|
|
93
93
|
| `pubsub.snapshot` | `SolidPubSub` | `AkanApp` |
|
|
94
94
|
| `live.change` | `SolidPubSub` | `AkanApp`, `SolidPubSub` |
|
|
95
95
|
| `live.models` | `SolidPubSub` | `AkanApp` |
|
|
96
96
|
| `queue.enqueued` | `SolidQueue` | `AkanApp` |
|
|
97
97
|
| `queue.wake` | `AkanApp` | `SolidQueue` |
|
|
98
|
-
| `health.ping` | `
|
|
98
|
+
| `health.ping` | `ChildSupervisor` | `AkanServer` |
|
|
99
99
|
| `health.pong` | `AkanServer` | `AkanApp` |
|
|
100
100
|
| `ws.opened` | — | — |
|
|
101
101
|
| `ws.closed` | — | — |
|
|
102
102
|
| `metrics.report` | `AkanServer` | `AkanApp` |
|
|
103
103
|
| `log.records` | `LogForwarder` | `AkanApp` |
|
|
104
|
-
| `log.level` | `
|
|
105
|
-
| `shutdown` | `
|
|
104
|
+
| `log.level` | `ChildSupervisor`, `GatewayLogging` | `AkanServer` |
|
|
105
|
+
| `shutdown` | `ChildSupervisor` | `AkanServer` |
|
|
106
106
|
| `file.resolve` | `NativeFile` | — |
|
|
107
107
|
| `file.resolved` | — | `NativeFile` |
|
|
108
108
|
| `secret.request` | `NativeSecret` | — |
|
|
@@ -115,22 +115,22 @@ Declared in [server/artifact/ipcTypes.ts](server/artifact/ipcTypes.ts).
|
|
|
115
115
|
|
|
116
116
|
| Message | Sent by | Handled by |
|
|
117
117
|
| --- | --- | --- |
|
|
118
|
-
| `build-route` | `BuilderRpc` | `AkanApp`, `
|
|
119
|
-
| `build-csr` | `BuilderRpc` | `AkanApp`, `
|
|
120
|
-
| `build-graph` | `BuilderRpc` | `AkanApp`, `
|
|
121
|
-
| `build-route-res` | `
|
|
122
|
-
| `build-csr-res` | `
|
|
123
|
-
| `build-graph-res` | `
|
|
118
|
+
| `build-route` | `BuilderRpc` | `AkanApp`, `BuilderRequestRelay`, `DevBackend`, `IncrementalBuilder` |
|
|
119
|
+
| `build-csr` | `BuilderRpc` | `AkanApp`, `BuilderRequestRelay`, `DevBackend`, `IncrementalBuilder` |
|
|
120
|
+
| `build-graph` | `BuilderRpc` | `AkanApp`, `BuilderRequestRelay`, `DevBackend`, `IncrementalBuilder` |
|
|
121
|
+
| `build-route-res` | `BuilderRequestRelay`, `IncrementalBuilder` | `AkanApp`, `AkanAppHost`, `BuilderRpc`, `IncrementalBuilderHost` |
|
|
122
|
+
| `build-csr-res` | `BuilderRequestRelay`, `IncrementalBuilder` | `AkanApp`, `AkanAppHost`, `BuilderRpc`, `IncrementalBuilderHost` |
|
|
123
|
+
| `build-graph-res` | `BuilderRequestRelay`, `IncrementalBuilder` | `AkanApp`, `AkanAppHost`, `BuilderRpc`, `IncrementalBuilderHost` |
|
|
124
124
|
| `builder-shutdown` | `IncrementalBuilderHost` | `IncrementalBuilder` |
|
|
125
125
|
| `builder-ready` | `IncrementalBuilder` | `AkanApp`, `BuilderRpc`, `IncrementalBuilderHost` |
|
|
126
|
-
| `backend-ready` | `
|
|
127
|
-
| `invalidate` | `
|
|
128
|
-
| `css-updated` | `BuildBatch`, `IncrementalBuilder` | `AkanApp`, `AkanAppHost`, `BuilderRpc`, `IncrementalBuilderHost`, `shouldRelayRecycledFrontendState` |
|
|
129
|
-
| `pages-updated` | `BuildBatch`, `IncrementalBuilder` | `AkanApp`, `AkanAppHost`, `BuilderRpc`, `IncrementalBuilderHost`, `shouldRelayRecycledFrontendState` |
|
|
126
|
+
| `backend-ready` | `ChildSupervisor` | `DevBackend` |
|
|
127
|
+
| `invalidate` | `DevRecycler`, `prepareDevWatchBatch` | `AkanApp`, `AkanAppHost`, `BuilderRpc`, `DevBuilder`, `IncrementalBuilderHost` |
|
|
128
|
+
| `css-updated` | `BuildBatch`, `IncrementalBuilder` | `AkanApp`, `AkanAppHost`, `BuilderRpc`, `DevBuilder`, `IncrementalBuilderHost`, `shouldRelayRecycledFrontendState` |
|
|
129
|
+
| `pages-updated` | `BuildBatch`, `IncrementalBuilder` | `AkanApp`, `AkanAppHost`, `BuilderRpc`, `DevBuilder`, `IncrementalBuilderHost`, `shouldRelayRecycledFrontendState` |
|
|
130
130
|
| `csr-updated` | `BuildBatch`, `IncrementalBuilder` | `AkanApp`, `BuilderRpc`, `IncrementalBuilderHost` |
|
|
131
131
|
| `ssr-updated` | `BuildBatch`, `IncrementalBuilder` | `AkanApp`, `BuilderRpc`, `IncrementalBuilderHost` |
|
|
132
|
-
| `build-status` | `
|
|
133
|
-
| `builder-metrics` | `IncrementalBuilder` | `AkanAppHost`, `IncrementalBuilderHost` |
|
|
132
|
+
| `build-status` | `BuildBatch`, `DevBackend`, `DevHostChannel`, `IncrementalBuilder` | `AkanApp`, `AkanAppHost`, `BuildBatchRunner`, `BuilderRpc`, `DevBackend`, `DevBuilder`, `IncrementalBuilderHost` |
|
|
133
|
+
| `builder-metrics` | `IncrementalBuilder` | `AkanAppHost`, `DevBuilder`, `IncrementalBuilderHost` |
|
|
134
134
|
| `boot-armed` | `IncrementalBuilder` | `AkanAppHost`, `IncrementalBuilderHost` |
|
|
135
135
|
|
|
136
136
|
### `InMsg`: server → RSC worker
|
package/CHANGELOG.md
CHANGED
|
@@ -12,6 +12,15 @@
|
|
|
12
12
|
|
|
13
13
|
**Upgrading.** A usage hook receives failed and aborted turns. Before, a streamed turn whose reader left ran to its end and was billed as finished; it now stops early and is billed at its estimate. To bill as before, bill every report except `outcome === "failed"`. Billing only `ok` would leave a stopped turn unbilled while the provider charged for it. Read `estimated` to treat estimated counts differently.
|
|
14
14
|
|
|
15
|
+
- ba81635: A modal opened from inside the floating `Agent.Chat` now stacks above the panel, and the panel's header takes a node for its title and names its parts.
|
|
16
|
+
|
|
17
|
+
- **Overlays opened from the floating panel stack above it.** A `Modal`, `BottomSheet`, `Popconfirm`, `Dropdown`, `Select` or `Tooltip` rendered anywhere inside the panel, the `header` slot included, portals into a layer just above the panel (`overlayZ.agentPanelOverlay`, 160). It used to land under the panel, whose z-index (150) tops a page's modals (120). One the page opens still stays under the panel. An `inline` chat hands down whichever portal it sits in, as before, so a modal around it still hosts what it opens. While the turn waits on an approval, a tool card or a question, a modal, sheet or popconfirm the panel opened sinks under the panel so the answer stays reachable, and comes back once answered; what a card opens stays above.
|
|
18
|
+
- **`title` takes a `ReactNode`**, so a mark can go before the name. A new `label` names the panel for screen readers when `title` is not plain text; without either, the name is `l("base.agent")`, and a string `title` names the panel as before.
|
|
19
|
+
- **The header's parts carry `data-slot` hooks**: `agent-header` on the bar, `agent-title` on the title and `agent-running` on the dot shown while a turn runs. Restyle one through them, for example `panelClassName="[&_[data-slot=agent-running]]:bg-accent"`, rather than through the markup's shape.
|
|
20
|
+
- **The header rule is `border-border`**, as other framework surfaces draw their rules, instead of `border-foreground/5`.
|
|
21
|
+
|
|
22
|
+
**Upgrading.** An `AgentChat` override that types `title` as `string` must take `ReactNode`. A modal an app mounted beside the Chat and opened from the panel's `header` still opens under the panel; mount it inside `header` to bring it above.
|
|
23
|
+
|
|
15
24
|
- e9a2c7f: `this.agentService.loop(request)` runs a model over the `/mcp` tool catalogue in-process until it answers. It needs no browser, so a queued task, a scheduled run or a reply to a mention can use it.
|
|
16
25
|
|
|
17
26
|
- **Events.** It returns an async iterable of `text`, `toolCall`, `toolResult`, `usage`, `compacted` and `awaiting` events. The stream ends with exactly one `done { stop, rounds }` or `error`. `stop` is one of `end`, `maxRounds`, `budget`, `aborted`, `length`, `quota`, `unauthorized` or `awaiting`. The loop waits for the consumer at every event.
|
|
@@ -63,6 +72,12 @@
|
|
|
63
72
|
- **Cache writes reported separately.** `LlmUsage.cacheWriteTokens` is the part of `inputTokens` the provider wrote to its cache, which Anthropic bills above its input rate. `inputTokens` still counts the whole prompt.
|
|
64
73
|
- **`AgentService.runTurn(request, { onDelta, preamble, signal })`.** `preamble` replaces the in-page preamble, and `false` sends none, for a turn with no screen behind it. Passing `onDelta` alone as the second argument still works.
|
|
65
74
|
|
|
75
|
+
- 8c70603: A failed agent turn now names a code a host can branch on, beside the message it already sent, which is unchanged. No upgrade step is needed: the fields are new.
|
|
76
|
+
|
|
77
|
+
- The relay's `error` event and `AgentTurnStream.failure` carry `code`, named the way a failed MCP tool call is. That is the `Err`'s dictionary key, else an `AkanError`'s own code, else the status's name. A guard's 401 or 403 is named by its status alone, and a 5xx never takes a duck-typed body's code. `SignalFailure.codeOf(error, status)` holds that rule, and a failed MCP tool call is now named through it too.
|
|
78
|
+
- `use-agentic`'s `RunnerEvent` error gains an optional `code`. `httpRunner` reads it from a stream's error event and keeps it only when it is a dictionary key or one camelCase token. A failure answered before the stream opens is named by its body's bounded code, else by its status. A 401 or 403 takes no dictionary key there either, so a refusal reads the same before and after the stream opens.
|
|
79
|
+
- The in-page chat keeps the key as `code` after translating the message. The session records it on the failed assistant message as `ChatMessage.errorCode`, which a host reads and the transcript never sends back.
|
|
80
|
+
|
|
66
81
|
- dcb7e61: The signal and service facets throw coded failures instead of a bare `Error`. Each one keeps its message, so a test or a log matching the text still matches. Each one carries a `code` that a caller, an agent or an MCP client can branch on, for example `DocumentStoreError.is(error, "invalidQuery")`.
|
|
67
82
|
|
|
68
83
|
| Class | Codes | Status |
|
|
@@ -100,6 +115,7 @@
|
|
|
100
115
|
|
|
101
116
|
**`Exception.<Status>.is(error)` type-checks.** `StatusException` now declares `is`, so `Exception.BadRequest.is(error)` narrows `error` to an `Exception` and checks its own class.
|
|
102
117
|
|
|
118
|
+
- f314eba: A route guard gets a second argument, `{ path }`: the requested in-app path with its search, in the form `router.push` takes, on the server and in CSR (`undefined` while MCP lists a screen). `signedIn({ path })` from `@libs/shared/webkit` adds `?redirect=<path>` to the sign-in URL, and `signedIn("/login")` still works. Use `path` to build a redirect target only. It must never decide admission: CSR asks a guard again only when the route or an argument it declared changes.
|
|
103
119
|
- d6b3619: Every `Err` is now one class, `Err` from `akanjs/common`. That covers the one an app's or lib's `lib/dict` builds, the one `useClient` returns, `akanjs/dictionary`'s own, and an error restored off the wire. Each is that class typed with its own dictionary's keys, so `Err.is` and the status classes behave the same in the browser and on the server. `instanceof Err` holds within one copy of the module. A page bundle and the framework each carry one, so check across them with `Err.is`.
|
|
104
120
|
|
|
105
121
|
- **`Err` is an `AkanError`.** `AkanError.is(err)` is true for every `Err`, and `err.forwarded` is true unless it was restored with a `code`, so the request path still sends its `toJSON()` as it is.
|
|
@@ -339,11 +355,14 @@
|
|
|
339
355
|
`akan lint`'s `akan.service.call-in-loop` fix and the agent guidelines name `create<Model>Many` as the way to write a set once.
|
|
340
356
|
|
|
341
357
|
- 73f8830: An error an endpoint declares in `errors` and throws with that status under 500 is now logged at debug, as a returned call is, rather than as an ERROR line. A public endpoint that answers a bad token with a declared 404 no longer sends every probe, token scan or mistyped webhook URL to real-error alerts. Undeclared errors, a declared key thrown with another status, and every 5xx still log as errors.
|
|
358
|
+
- 5691327: `setErrorConstructor` on `FetchClient`, `HttpClient` and `WsClient`, `HttpClientOptions.ErrorCls` and `FetchClient.build`'s `Err` option are deprecated. Every dictionary's `Err` is `akanjs/common`'s `Err`, which a restored error already is, so they change nothing. They keep working. A generated `lib/sig.ts` no longer calls `fetch.setErrorConstructor(Err)`, and a generated `lib/useClient.ts` no longer passes `{ Err: pageProto.Err }`; `akan sync` rewrites both. No upgrade step is needed.
|
|
342
359
|
- 958f175: A dev server now answers only the host names it can be reached under locally. Under `akan start`, or on a local dev runtime, with `AKAN_ALLOWED_HOSTS` unset, it answers `localhost` and `*.localhost`, IPv4 and IPv6 addresses (a phone on the LAN included), and the app's own hosts: its route domains and `<app>-<environment>.<serveDomain>`. A request under any other `Host`, the HMR socket and the `/_akan/*` dev routes included, gets a 403 that names `AKAN_ALLOWED_HOSTS`. To open a dev server under another name, such as a container's service name or a forwarded editor URL, list every `host:port` it should answer there; a set list replaces the default, as before. A deployed server with the variable unset still answers every `Host`.
|
|
343
360
|
|
|
344
361
|
`akan tunnel` and `akan start --share` keep working: the tunnel agent now dials the local app under the app's own address and leaves the public host name in `x-forwarded-host`, which is where the app already reads it. A redirect a page raises during SSR now sends a same-origin target as a relative `Location`, so a tunnel or proxy caller lands on the host it used rather than the one the server was dialed as; a target on another origin stays absolute.
|
|
345
362
|
|
|
346
363
|
- 9f30e93: A dev page no longer loses its styles after a stylesheet change arrives together with a pages rebuild. The most common case was the first save after `akan start` released its builder for being idle: the waking builder announces a new pages bundle and a new stylesheet at once, and the SSR worker that had started importing the bundle put the old stylesheet back when the import finished. Pages kept linking that stylesheet, whose file the dev server had already deleted, so they rendered unstyled with a 404 until `akan start` was restarted. The same update also reaches an SSR worker that is still booting after a recycle, which used to keep the stylesheet it was started with.
|
|
364
|
+
- ad09fac: Exports that nothing in akanjs, its tests or a consumer workspace uses are now marked. Thirteen that no code calls at all are `@deprecated` and leave in a later minor: `MAX_INT` (write `2 ** 31 - 1`), `isFilterModel` (`getFilterMeta(ref, { allowEmpty: true }) !== undefined`), `setFilterInfoByKey` (declare the query with `from(model, (filter) => …)`), `getDefaultSchemaOptions` (`new DocumentSchema()`), `runWithTrace` (`runTraced`, only where the caller owns the trace, since it finalizes it), `traceDbQuery` (`getCurrentTrace()?.countDbQuery(ms)`), `isSitemapPath` (`getSitemapBasePath(pathname, basePaths, headerBasePath) !== undefined`), `useRscNavigation` (`navigateRsc`, `clearRscNavigationCache`, `isRscNavigationFromCache`), `getSearchParam` and `getBaseSearchParam` (read `searchParams[key]`, taking the first value of an array), `dictionaryContext`, `groupByOwner` and `ServiceRegistry`. Eleven that only their own file uses, such as the console helpers in `akanjs/server` and `getClientRuntime` in `akanjs/client`, are `@internal`: they are not meant for use outside akanjs and may stop being exported in a later minor.
|
|
365
|
+
- ae045d8: No non-test file in an `akanjs` facet imports its own facet's barrel any more; each imports the sibling file that declares what it uses. Four value imports in `constant/` went through its barrel, so loading one of those files loaded the whole facet first. `ResolveFieldContext` moved to `signal/resolveFieldContext.ts`, and `akanjs/signal` still exports it. Every public import is unchanged.
|
|
347
366
|
- d9eaacc: A query takes `signal` in its `FetchPolicy`, joined with its deadline: an abort rejects the call with the signal's reason, stops the request, and ends the retries, including one waiting between tries. A signal already aborted sends nothing, over HTTP, inside a server render or through an MCP App view's host. A signal from `AbortSignal.timeout` rejects with the slow-server error (`base.error.gatewayTimeout`, 408), as the query's own deadline does. A mutation ignores it, since one already sent may have run. In an MCP App view an abort, or the query's own deadline running out, also asks the host to cancel the call it relayed (`notifications/cancelled`); a mutation that runs out of time is only given up on. A custom `FetchBridge` receives the signal as `signal`.
|
|
348
367
|
|
|
349
368
|
A slice's list loads (`init`, `refresh`, `setPage`, `setLimit`, `setSort`, `setQueryArgs`, `loadMore`) abort the request a newer load of the same slice supersedes, instead of letting it run to the end and dropping its answer. The superseded load writes nothing and shows no error, and so does one aborted by a `signal` its caller passed, which resolves; `init` still applies its `default` at once unless the signal was already aborted, and an `init` aborted mid-flight, or one with nothing to change, leaves a loaded-more list whole, so the next refresh still reloads every row shown. A caller's `AbortSignal.timeout` is the exception: the load rejects with the slow-server error and shows it, as a query does. A store action that rejects with the abort of a signal it was given no longer shows an error toast, whatever reason that signal was aborted with, except an app or server error (one with a dictionary key or a status) and a timeout, which still show.
|
|
@@ -433,6 +452,8 @@
|
|
|
433
452
|
- **Native and CSR boots keep their locale paths.** Their routes match on the `/:lang` segment, so a `?csr=true` request without one is redirected to the default locale's prefixed path. An Android app link limited to a basePath lists the default locale's unprefixed path as well as its prefixed one, so links from before the switch still open the app.
|
|
434
453
|
- `akan preview` keeps an unprefixed path unprefixed under `"as-needed"`, except with `--csr`. The value reaches bundles as `AKAN_PUBLIC_LOCALE_PREFIX`, and the image env carries it when it is `"as-needed"`. `LocalePath` (`akanjs/common`) and a fourth `localePrefix` argument to `getPathInfo` build the same URLs in app code.
|
|
435
454
|
|
|
455
|
+
- dfc3564: A server stopped while its log control socket was still starting no longer leaves that socket listening. `akan logs` then found a socket nothing owned, and it kept serving a closed log hub until the process exited. Starts and stops on one control socket path now take turns, so a start whose log hub was closed meanwhile binds nothing or closes what it bound before a restart's open looks, and the restarted server gets its own socket. A socket that fails after binding is closed before the error surfaces. Stopping a control socket that never bound no longer unlinks the live socket of another server in the same runtime folder.
|
|
456
|
+
- d12f556: `akanjs/signal`, `akanjs/client`, `akanjs/server`, `akanjs/constant` and `akanjs/store` now list every export by name instead of re-exporting whole files with `export *`. They export exactly the names they did before. A new export in one of those facets' files is no longer exported from `akanjs/<facet>` until its facet's `index.ts` names it. Files under `server/` and `client/native/` stay importable by their own subpath, as before.
|
|
436
457
|
- 9b5bcee: Every SSR page now loads 72K less framework JavaScript (22K less after Brotli).
|
|
437
458
|
|
|
438
459
|
- **`akan build` narrows the vendor entries to the names the page code imports.** The `akanjs/*` and `tailwind-merge` entries in the page's import map used to re-export a whole facet. Each one now exports only the names the built route bundles import, lazy chunks included. On the minimal app, the framework floor, meaning the runtime plus the vendor entries every page loads, drops from 630.2K raw / 189.4K br to 558.4K raw / 167.4K br. `akan start` keeps whole facets, so a newly saved import never misses a name.
|
|
@@ -526,6 +547,7 @@
|
|
|
526
547
|
- `invalidConfig`: a `transformEnv` callback returns something other than the env object.
|
|
527
548
|
- `notRegistered`: no WebSocket adaptor is registered.
|
|
528
549
|
|
|
550
|
+
- b0ccf6f: The browser's RSC client now throws coded errors instead of bare `Error`s, so a caller can branch on `error.code`. A route the server has no page for is `routeNotFound` (404), as a missing WebSocket route already is. A response with no RSC payload is `rscFetchFailed` (502). A patch missing its parts, or a full fallback that answers with a patch, is `invalidRscResponse`, the code `rscClientFetch` already throws for the latter. The redirect marker, which only a log line receives, is `rscRedirectStarted`. Each error keeps its `name` and its message, except the fallback's message, which is now `[rscClient] fallback is a patch`. The error-code reference lists the new codes.
|
|
529
551
|
- 9055634: Partial RSC commit can now patch a real page, and it patches cleanly. It is still off by default behind `AKAN_PUBLIC_RSC_PARTIAL_COMMIT=1`. With the flag on:
|
|
530
552
|
|
|
531
553
|
- **Which pages render their head through `AkanRouteHead`.** Every page whose head is plain `title`, `meta` and `link` tags now renders it through a client component instead of plain head tags. That way any page can be the one a patch starts from. Patches still only land on pages that set `.config({ rscPatchHeadSafe: true })`.
|
|
@@ -739,6 +761,7 @@
|
|
|
739
761
|
- **A new `akanApi` guideline** lists every import path and the exact signatures of the route stages, `router`, `Link`, `serve`, `adapt`, the endpoint builders, `SignalOption`, `serviceDictionary`, and the keys of `akan.config.ts` with the `web` and `i18n` shapes. It is generated from the akanjs types of the same release, and a test fails when the two drift apart. `akan agent install` ships it as a reference of both skills, and `get_guideline` / `akan guideline show akanApi` print it.
|
|
740
762
|
- **`ServiceOptions.serverMode`** carries a doc comment, so an editor shows the same explanation on hover.
|
|
741
763
|
|
|
764
|
+
- 2bf769f: Internal: the `AkanApp` gateway is composed from one collaborator per concern under `server/gateway/` instead of one 155-member class. Child supervision and restarts, the HTTP and WebSocket relays, rooms, status endpoints, logging and the dev-host channel behave as before, and `AkanApp` and `AkanAppOptions` are unchanged.
|
|
742
765
|
- 91ccf38: Internal: `makeActions` and `useCsrValues` are composed from one file per action set and hook instead of two monoliths. Store actions, hook order, effects and their dependencies are unchanged.
|
|
743
766
|
- c2af76a: Internal: the web router's route table is built by one collaborator per route family instead of one 437-line method. Routes, their order, headers, caching and error answers are unchanged. The framework map now follows a send through a field that hands out its receiver (`this.#hub()?.broadcast(...)`), so `ARCHITECTURE.md` still names who sends each HMR message.
|
|
744
767
|
- df32c46: On SQLite, work outside an open `this.transaction()` no longer sees it or joins it. A read from another request ran on the one shared connection, inside the transaction, so it returned rows the transaction had not committed, including rows it then rolled back. It now runs on a second, read-only connection to the same WAL file and sees what is committed, as on Postgres, without waiting for the transaction; code inside the transaction still reads its own writes. A write from another request already waited for the open transaction, but when a second transaction began as the first committed, the waiting write could run inside the second one and be rolled back with it after its caller was told it had succeeded. It now runs between the two.
|
|
@@ -752,6 +775,7 @@
|
|
|
752
775
|
- **`ssr: "block"` writes every boundary in place,** so a blocking page never shows its `.loading()` fallback.
|
|
753
776
|
- **Fragments land on their target.** A document opened at a fragment scrolls to the target when React reveals it, if the target was not on the page yet and the visitor has not scrolled; a reload or a back/forward visit keeps the offset the browser restored. A client navigation to another page's fragment lands on the target instead of the top.
|
|
754
777
|
|
|
778
|
+
- a5c476a: A gateway stopped while `AkanApp.start()` was still preparing its runtime folder, logs or ops route no longer spawns replicas or listens afterwards, and its `start()` now returns instead of waiting for a stop that has already happened. A server without a gateway stopped while `AkanServer.start({ listen: false })` was opening its log control socket no longer runs its init schedules afterwards.
|
|
755
779
|
- 76705dd: `StoreRegistry.build` now reads a root store's state, actions and slices from the merged type rather than inferring them back out of it. That inference grew quadratically with the number of stores. In an app merging about 70 stores, `build` took most of the typecheck, and adding a few more stores failed it with TS2589 ("Type instantiation is excessively deep"). With this change the typecheck cost grows linearly with the store count, and the `st` type is unchanged.
|
|
756
780
|
- 206bb69: A store write now costs about one copy of the state, whatever else the root holds. Before, every `set` copied the state twice, compared every key, re-read every `search()` value, and walked every persisted key and every model form. That came to 173 µs at 1,740 keys and 364 µs at 3,480. Now `set` works out the changed keys from the patch and copies the state once. It then recomputes only the `search()` values (when `searchParams` changed) and the `computed()` values whose dependencies changed, and syncs only the persisted keys and form drafts the write touched. That is 38 µs at 1,740 keys and 78 µs at 3,480, the cost of the copy itself.
|
|
757
781
|
|
package/base/base.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { CLIENT_VALUE, Cls, DEFAULT_VALUE, PURIFIED_VALUE, SERVER_VALUE } from ".";
|
|
2
1
|
import { Float, Int } from "./primitiveRegistry";
|
|
2
|
+
import type { CLIENT_VALUE, DEFAULT_VALUE, PURIFIED_VALUE, SERVER_VALUE } from "./symbols";
|
|
3
|
+
import type { Cls } from "./types";
|
|
3
4
|
|
|
4
5
|
class EnumPrototype {}
|
|
5
6
|
export type EnumInstance<RefName extends string = string, T = string | number> = Cls<
|
package/client/clientRuntime.ts
CHANGED
package/client/cn.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ClassNameValue, extendTailwindMerge } from "tailwind-merge";
|
|
2
2
|
|
|
3
|
-
/** Registered with tailwind-merge so `cn("bg-primary", "bg-open")` resolves to `"bg-open"` instead of keeping both. */
|
|
3
|
+
/** @internal Registered with tailwind-merge so `cn("bg-primary", "bg-open")` resolves to `"bg-open"` instead of keeping both. */
|
|
4
4
|
export const colorTokens = [
|
|
5
5
|
"background",
|
|
6
6
|
"foreground",
|
|
@@ -33,7 +33,7 @@ export const colorTokens = [
|
|
|
33
33
|
"ring",
|
|
34
34
|
];
|
|
35
35
|
|
|
36
|
-
/** `--radius-box` / `--radius-field`; unregistered, `cn("rounded-field", "rounded-full")` would keep both. */
|
|
36
|
+
/** @internal `--radius-box` / `--radius-field`; unregistered, `cn("rounded-field", "rounded-full")` would keep both. */
|
|
37
37
|
export const radiusTokens = ["box", "field"];
|
|
38
38
|
|
|
39
39
|
const twMerge = extendTailwindMerge({
|
package/client/csrTypes.ts
CHANGED
|
@@ -121,6 +121,8 @@ export interface RouteGuardProps {
|
|
|
121
121
|
searchParams: Record<string, string | string[]>;
|
|
122
122
|
/** MCP is listing the screen, so no argument is known: a guard reading one throws `RouteArgPending`. */
|
|
123
123
|
listing?: boolean;
|
|
124
|
+
/** The CSR target's in-app path; a server request's own URL gives it when this is left off. */
|
|
125
|
+
path?: string;
|
|
124
126
|
}
|
|
125
127
|
export type RouteGuard = (props: RouteGuardProps) => Promise<void>;
|
|
126
128
|
export interface RouteRender {
|
package/client/frameConfig.ts
CHANGED
|
@@ -91,6 +91,7 @@ const isValidInsetValue = (value: unknown): value is NonNullable<PageConfig["top
|
|
|
91
91
|
return Object.entries(value).every(([key, px]) => responsiveInsetKeys.has(key) && isInsetPx(px));
|
|
92
92
|
};
|
|
93
93
|
|
|
94
|
+
/** @internal */
|
|
94
95
|
export const isResponsiveInset = (inset: PageConfig["topInset"]): inset is ResponsiveInset => isRecord(inset);
|
|
95
96
|
|
|
96
97
|
/** The inset at each breakpoint, each one the nearest declared value at or below it. */
|
package/client/index.ts
CHANGED
|
@@ -1,32 +1,255 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export
|
|
13
|
-
export
|
|
14
|
-
|
|
1
|
+
export {
|
|
2
|
+
type ClientRuntime,
|
|
3
|
+
Err,
|
|
4
|
+
fetch,
|
|
5
|
+
getClientRuntime,
|
|
6
|
+
isClientRuntimeRegistered,
|
|
7
|
+
msg,
|
|
8
|
+
registerClientRuntime,
|
|
9
|
+
sig,
|
|
10
|
+
usePage,
|
|
11
|
+
} from "./clientRuntime";
|
|
12
|
+
export { cn, colorTokens, radiusTokens } from "./cn";
|
|
13
|
+
export {
|
|
14
|
+
authTokenKey,
|
|
15
|
+
cookieJar,
|
|
16
|
+
cookies,
|
|
17
|
+
type GetOption,
|
|
18
|
+
getAccount,
|
|
19
|
+
getAuthToken,
|
|
20
|
+
getCookie,
|
|
21
|
+
getHeader,
|
|
22
|
+
getSessionClaims,
|
|
23
|
+
getStoredAuthToken,
|
|
24
|
+
headers,
|
|
25
|
+
initAuth,
|
|
26
|
+
removeCookie,
|
|
27
|
+
resetAuth,
|
|
28
|
+
setAuth,
|
|
29
|
+
setCookie,
|
|
30
|
+
} from "./cookie";
|
|
31
|
+
export { createFont, Inter, Nanum_Gothic_Coding, Noto_Sans_KR, Roboto } from "./createFont";
|
|
32
|
+
export { CsrLocation, csrLocation } from "./csrLocation";
|
|
33
|
+
export {
|
|
34
|
+
type AkanHeadSnapshotNode,
|
|
35
|
+
type AkanHeadSnapshotV1,
|
|
36
|
+
type AnimatedDivProps,
|
|
37
|
+
type ContainerTransition,
|
|
38
|
+
type CsrContextType,
|
|
39
|
+
type CsrNavigationKind,
|
|
40
|
+
type CsrNavigationPhase,
|
|
41
|
+
type CsrPageType,
|
|
42
|
+
type CsrStackAccount,
|
|
43
|
+
type CsrStackEntry,
|
|
44
|
+
type CsrState,
|
|
45
|
+
type CsrTransitionStyles,
|
|
46
|
+
csrContext,
|
|
47
|
+
DEFAULT_BOTTOM_INSET,
|
|
48
|
+
DEFAULT_TOP_INSET,
|
|
49
|
+
type FrameContentViewportState,
|
|
50
|
+
type FrameLayer,
|
|
51
|
+
type FrameLayerZIndex,
|
|
52
|
+
type FrameLayoutState,
|
|
53
|
+
type FramePlatformProfile,
|
|
54
|
+
type FrameSlotBucket,
|
|
55
|
+
type FrameSlotRegistration,
|
|
56
|
+
type FrameSlotRole,
|
|
57
|
+
type FrameSlotScope,
|
|
58
|
+
type FrameSlotType,
|
|
59
|
+
type FrameSnapshot,
|
|
60
|
+
type FrameViewportState,
|
|
61
|
+
type GenerateHead,
|
|
62
|
+
type Head,
|
|
63
|
+
type HeadProps,
|
|
64
|
+
type History,
|
|
65
|
+
type KeyboardAccessoryFrameState,
|
|
66
|
+
type KeyboardFrameState,
|
|
67
|
+
type LayoutErrorProps,
|
|
68
|
+
type LayoutErrorRender,
|
|
69
|
+
type LayoutFallbackRoute,
|
|
70
|
+
type LayoutLoadingProps,
|
|
71
|
+
type LayoutLoadingRender,
|
|
72
|
+
type LayoutModule,
|
|
73
|
+
type LayoutNotFoundProps,
|
|
74
|
+
type LayoutNotFoundRender,
|
|
75
|
+
type LayoutProps,
|
|
76
|
+
type LayoutRender,
|
|
77
|
+
type Location,
|
|
78
|
+
type LocationState,
|
|
79
|
+
type NavigationIntent,
|
|
80
|
+
type PageActivity,
|
|
81
|
+
type PageActivityState,
|
|
82
|
+
type PageConfig,
|
|
83
|
+
type PageLoadingProps,
|
|
84
|
+
type PageLoadingRender,
|
|
85
|
+
type PageModule,
|
|
86
|
+
type PageProps,
|
|
87
|
+
type PageRender,
|
|
88
|
+
type PageSafeAreaConfig,
|
|
89
|
+
type PageState,
|
|
90
|
+
type PageTransition,
|
|
91
|
+
type PathContextType,
|
|
92
|
+
type PathRoute,
|
|
93
|
+
pageActivityContext,
|
|
94
|
+
pathContext,
|
|
95
|
+
type ResolvedHead,
|
|
96
|
+
type ResolveHead,
|
|
97
|
+
type ResolveHeadResult,
|
|
98
|
+
type ResponsiveInset,
|
|
99
|
+
type Route,
|
|
100
|
+
type RouteGuard,
|
|
101
|
+
type RouteGuardProps,
|
|
102
|
+
type RouteGuide,
|
|
103
|
+
type RouteModule,
|
|
104
|
+
type RouteRender,
|
|
105
|
+
type RouterProps,
|
|
106
|
+
type RouteState,
|
|
107
|
+
type RouteViewport,
|
|
108
|
+
type SafeAreaTransition,
|
|
109
|
+
type SsrRenderMode,
|
|
110
|
+
type TransitionAction,
|
|
111
|
+
type TransitionActionContext,
|
|
112
|
+
type TransitionPlan,
|
|
113
|
+
type TransitionStyle,
|
|
114
|
+
type UseCsrTransition,
|
|
115
|
+
useCsr,
|
|
116
|
+
usePathCtx,
|
|
117
|
+
type WebAppManifest,
|
|
118
|
+
type WebAppManifestIcon,
|
|
119
|
+
} from "./csrTypes";
|
|
120
|
+
export { Toast } from "./decorators";
|
|
121
|
+
export { Device, debugFrame, isMobileDevice, isNativeTarget } from "./device";
|
|
122
|
+
export {
|
|
123
|
+
breakpointQuery,
|
|
124
|
+
type DevicePlatform,
|
|
125
|
+
defaultPageState,
|
|
126
|
+
getExplicitPageConfigKeys,
|
|
127
|
+
type InsetBreakpoint,
|
|
128
|
+
insetAt,
|
|
129
|
+
insetBreakpoints,
|
|
130
|
+
insetsByBreakpoint,
|
|
131
|
+
isResponsiveInset,
|
|
132
|
+
mergePageConfigs,
|
|
133
|
+
type ResolvePageStateOptions,
|
|
134
|
+
readCssSafeAreaInsets,
|
|
135
|
+
resolvePageState,
|
|
136
|
+
type SafeAreaInsets,
|
|
137
|
+
type TailwindBreakpoint,
|
|
138
|
+
validatePageConfig,
|
|
139
|
+
} from "./frameConfig";
|
|
140
|
+
export { Href } from "./href";
|
|
141
|
+
export { dictionaryContext } from "./locale";
|
|
142
|
+
export {
|
|
143
|
+
type ErrPayload,
|
|
144
|
+
makePageProto,
|
|
145
|
+
type PageErrConstructor,
|
|
146
|
+
type PageErrInstance,
|
|
147
|
+
type TransMessageOption,
|
|
148
|
+
} from "./makePageProto";
|
|
149
|
+
export { isMcpView } from "./mcpView";
|
|
150
|
+
export { desktopPlatform, isNativeApp, isNativeShell, nativePlatform, openExternalUrl } from "./nativeHost";
|
|
15
151
|
export {
|
|
16
152
|
type NavigationAttempt,
|
|
17
153
|
type NavigationGuard,
|
|
18
154
|
type NavigationKind,
|
|
19
155
|
NavigationRefused,
|
|
20
156
|
} from "./navigationGuards";
|
|
21
|
-
export
|
|
22
|
-
export
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
157
|
+
export { resolveServerUrl } from "./resolveServerUrl";
|
|
158
|
+
export {
|
|
159
|
+
assertGuardOnChain,
|
|
160
|
+
isRouteDefinition,
|
|
161
|
+
LayoutDefinition,
|
|
162
|
+
type LayoutExtra,
|
|
163
|
+
layout,
|
|
164
|
+
PageDefinition,
|
|
165
|
+
page,
|
|
166
|
+
type ResolvedRouteModule,
|
|
167
|
+
type ResolveRouteModuleOption,
|
|
168
|
+
RootLayoutDefinition,
|
|
169
|
+
RouteArgError,
|
|
170
|
+
type RouteArgInfo,
|
|
171
|
+
type RouteArgInput,
|
|
172
|
+
type RouteArgOption,
|
|
173
|
+
RouteArgPending,
|
|
174
|
+
type RouteArgResolveOption,
|
|
175
|
+
type RouteArgsShape,
|
|
176
|
+
type RouteArgType,
|
|
177
|
+
type RouteArgValue,
|
|
178
|
+
type RouteBaseArgs,
|
|
179
|
+
RouteDefinition,
|
|
180
|
+
type RouteGuardRequest,
|
|
181
|
+
RouteGuards,
|
|
182
|
+
RouteHead,
|
|
183
|
+
type RouteKind,
|
|
184
|
+
type RouteModuleSource,
|
|
185
|
+
type RoutePromptArgument,
|
|
186
|
+
type RoutePromptMeta,
|
|
187
|
+
type RouteSearchType,
|
|
188
|
+
resolveRouteModule,
|
|
189
|
+
rootLayout,
|
|
190
|
+
routeArgsMarker,
|
|
191
|
+
routeDefinitionMarker,
|
|
192
|
+
} from "./route";
|
|
193
|
+
export {
|
|
194
|
+
AkanNotFoundError,
|
|
195
|
+
AkanRedirectError,
|
|
196
|
+
type DeepLinkOptions,
|
|
197
|
+
getPathInfo,
|
|
198
|
+
isRouteControl,
|
|
199
|
+
normalizeDeepLinkHref,
|
|
200
|
+
type RedirectMethod,
|
|
201
|
+
type RedirectOptions,
|
|
202
|
+
type RedirectStatus,
|
|
203
|
+
type RouteManifest,
|
|
204
|
+
type RouteOptions,
|
|
205
|
+
type RouterInstance,
|
|
206
|
+
router,
|
|
207
|
+
} from "./router";
|
|
208
|
+
export {
|
|
209
|
+
clearRscNavigationCache,
|
|
210
|
+
isRscNavigationFromCache,
|
|
211
|
+
navigateRsc,
|
|
212
|
+
type PrefetchPriority,
|
|
213
|
+
prefetchRsc,
|
|
214
|
+
refreshRsc,
|
|
215
|
+
useRscNavigation,
|
|
216
|
+
} from "./rscNavigation";
|
|
217
|
+
export { sharedContext } from "./sharedContext";
|
|
218
|
+
export { secretStorage, storage } from "./storage";
|
|
219
|
+
export { type TransitionType, transitionTypes } from "./transitionTypes";
|
|
220
|
+
export { type AllDictionary, type Dictionary, Translator } from "./translator";
|
|
221
|
+
export {
|
|
222
|
+
type DataAction,
|
|
223
|
+
type DataColumn,
|
|
224
|
+
type DataMenu,
|
|
225
|
+
type DataMenuItem,
|
|
226
|
+
type DataTool,
|
|
227
|
+
type Font,
|
|
228
|
+
getFontFaces,
|
|
229
|
+
getFontFallbackName,
|
|
230
|
+
getFontStyles,
|
|
231
|
+
getFontVariableName,
|
|
232
|
+
getOptimizedFontSrc,
|
|
233
|
+
isFontOptimizationEnabled,
|
|
234
|
+
isFontPreloadEnabled,
|
|
235
|
+
loadFonts,
|
|
236
|
+
type MenuItem,
|
|
237
|
+
type ModelDashboardProps,
|
|
238
|
+
type ModelEditProps,
|
|
239
|
+
type ModelInsightProps,
|
|
240
|
+
type ModelProps,
|
|
241
|
+
type ModelsProps,
|
|
242
|
+
type ModelViewProps,
|
|
243
|
+
type ReactFont,
|
|
244
|
+
type ReactFontCategory,
|
|
245
|
+
type ReactFontDeclaration,
|
|
246
|
+
type ReactFontDisplay,
|
|
247
|
+
type ReactFontFace,
|
|
248
|
+
type ReactFontPath,
|
|
249
|
+
type ReactFontStyle,
|
|
250
|
+
type ReactFontSubset,
|
|
251
|
+
type RootLayoutProps,
|
|
252
|
+
type UserMenuItem,
|
|
253
|
+
} from "./types";
|
|
254
|
+
export { type ThemeColorTag, ViewportMeta } from "./viewportMeta";
|
|
255
|
+
export { getWebManifestBasePath, toManifestJson, webManifestHref } from "./webManifest";
|
package/client/locale.ts
CHANGED
|
@@ -11,9 +11,16 @@ import { deserialize } from "akanjs/constant";
|
|
|
11
11
|
import { RenderScope } from "akanjs/fetch";
|
|
12
12
|
import type { ReactNode } from "react";
|
|
13
13
|
import type { Head, LayoutModule, PageConfig, PageModule, RouteGuardProps } from "../csrTypes";
|
|
14
|
-
import { AkanNotFoundError } from "../router";
|
|
14
|
+
import { AkanNotFoundError, getRequestRoutePath } from "../router";
|
|
15
15
|
import { Translator } from "../translator";
|
|
16
|
-
import {
|
|
16
|
+
import {
|
|
17
|
+
RouteArgError,
|
|
18
|
+
type RouteArgInfo,
|
|
19
|
+
type RouteArgInput,
|
|
20
|
+
RouteArgPending,
|
|
21
|
+
type RouteBaseArgs,
|
|
22
|
+
type RouteGuardRequest,
|
|
23
|
+
} from "./routeArgs";
|
|
17
24
|
|
|
18
25
|
export type RouteArgsShape = Record<string, unknown>;
|
|
19
26
|
export type RouteKind = "page" | "layout" | "rootLayout";
|
|
@@ -23,6 +30,7 @@ export const routeDefinitionMarker = Symbol.for("akan.routeDefinition");
|
|
|
23
30
|
export const routeArgsMarker = Symbol.for("akan.routeArgs");
|
|
24
31
|
|
|
25
32
|
type HeadStage<Args> = Head | ((args: Args) => PromiseOrObject<Head | null | undefined>);
|
|
33
|
+
type GuardStage<Args> = (args: Args, request: RouteGuardRequest) => void | Promise<void>;
|
|
26
34
|
|
|
27
35
|
interface RouteRenderProps {
|
|
28
36
|
params: Record<string, string>;
|
|
@@ -46,7 +54,7 @@ export abstract class RouteDefinition<
|
|
|
46
54
|
#config?: PageConfig;
|
|
47
55
|
|
|
48
56
|
#head?: HeadStage<never>;
|
|
49
|
-
#guard?:
|
|
57
|
+
#guard?: GuardStage<never>;
|
|
50
58
|
#loading?: (args: never) => PromiseOrObject<ReactNode>;
|
|
51
59
|
#render?: (args: never) => PromiseOrObject<ReactNode>;
|
|
52
60
|
#renderRoute?: {
|
|
@@ -64,10 +72,10 @@ export abstract class RouteDefinition<
|
|
|
64
72
|
return this;
|
|
65
73
|
}
|
|
66
74
|
/** Runs before any layout body; refuses with `router.redirect()` or `router.notFound()`. */
|
|
67
|
-
guard(guard: (args: RouteBaseArgs & Args) => void | Promise<void>) {
|
|
75
|
+
guard(guard: (args: RouteBaseArgs & Args, request: RouteGuardRequest) => void | Promise<void>) {
|
|
68
76
|
if (this.#guard)
|
|
69
77
|
throw new Error(`[route-convention] ${this.kind}() declares .guard() twice; run every check from one guard`);
|
|
70
|
-
this.#guard = guard as
|
|
78
|
+
this.#guard = guard as GuardStage<never>;
|
|
71
79
|
return this;
|
|
72
80
|
}
|
|
73
81
|
loading(render: (args: RouteBaseArgs & Args & Extra) => PromiseOrObject<ReactNode>) {
|
|
@@ -170,9 +178,18 @@ export abstract class RouteDefinition<
|
|
|
170
178
|
return args;
|
|
171
179
|
}
|
|
172
180
|
|
|
173
|
-
#guardRouteOf(guard:
|
|
181
|
+
#guardRouteOf(guard: GuardStage<never>) {
|
|
174
182
|
const route = async (props: RouteGuardProps) =>
|
|
175
|
-
await RenderScope.run(() =>
|
|
183
|
+
await RenderScope.run(() => {
|
|
184
|
+
const args = this.#guardArgsOf(props);
|
|
185
|
+
|
|
186
|
+
const request: RouteGuardRequest = {
|
|
187
|
+
get path() {
|
|
188
|
+
return props.listing ? undefined : (props.path ?? getRequestRoutePath(args.lang));
|
|
189
|
+
},
|
|
190
|
+
};
|
|
191
|
+
return guard(args as never, request);
|
|
192
|
+
});
|
|
176
193
|
Object.defineProperty(route, routeArgsMarker, { value: this.args.map(({ kind, name }) => ({ kind, name })) });
|
|
177
194
|
return route;
|
|
178
195
|
}
|
|
@@ -16,6 +16,13 @@ export interface RouteBaseArgs {
|
|
|
16
16
|
lang: string;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
/** A guard's second argument. `path` is a target to send the visitor back to, never a reason to let them in: CSR asks
|
|
20
|
+
* a guard again only when the route or an arg it declared moves, so a query it did not declare can move on. */
|
|
21
|
+
export interface RouteGuardRequest {
|
|
22
|
+
/** The requested in-app path with its search, as `router.push` takes it; `undefined` while MCP lists the screen. */
|
|
23
|
+
path?: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
19
26
|
export interface RouteArgInfo {
|
|
20
27
|
kind: "param" | "search";
|
|
21
28
|
name: string;
|
package/client/router.ts
CHANGED
|
@@ -115,6 +115,16 @@ const getServerPublicOrigin = () => {
|
|
|
115
115
|
|
|
116
116
|
const getConfiguredBasePaths = () => new Set(parseBasePaths(process.env.AKAN_PUBLIC_BASE_PATHS));
|
|
117
117
|
|
|
118
|
+
export const getRequestRoutePath = (lang: string): string | undefined => {
|
|
119
|
+
const request = getEnv().side === "server" ? getServerRequestContext().getRequest() : undefined;
|
|
120
|
+
if (!request) return undefined;
|
|
121
|
+
const { pathname, search } = new URL(request.url);
|
|
122
|
+
const headers = getServerRequestContext().headers();
|
|
123
|
+
const locale = headers.get("x-locale") ?? lang;
|
|
124
|
+
const basePath = getServerBasePath(pathname, locale, headers.get("x-base-path") ?? undefined, "");
|
|
125
|
+
return `${getPathInfo(pathname, locale, basePath).path}${search}`;
|
|
126
|
+
};
|
|
127
|
+
|
|
118
128
|
const shouldExposeBasePath = () => getEnv().operationMode === "local";
|
|
119
129
|
const CSR_RUNTIME_SEARCH_PARAMS = ["csr", "akanMobileTarget", "akanMobileBasePath", "akanMobileIndexPath"] as const;
|
|
120
130
|
|
|
@@ -727,8 +737,8 @@ class Router {
|
|
|
727
737
|
return undefined as never;
|
|
728
738
|
}
|
|
729
739
|
/** A pathname without its locale and base-path segments; unlike `getPath`, it needs no browser. */
|
|
730
|
-
routeOf(pathname: string) {
|
|
731
|
-
return getPathInfo(pathname,
|
|
740
|
+
routeOf(pathname: string, lang = this.#lang) {
|
|
741
|
+
return getPathInfo(pathname, lang, this.#prefix).path;
|
|
732
742
|
}
|
|
733
743
|
getPath(pathname = csrLocation.pathname) {
|
|
734
744
|
if (getEnv().side === "server") throw new Error("getPath is only available in client side");
|
package/client/rscNavigation.ts
CHANGED
|
@@ -38,6 +38,7 @@ export const refreshRsc = () => {
|
|
|
38
38
|
return globalThis.__AKAN_RSC_REFRESH__?.();
|
|
39
39
|
};
|
|
40
40
|
|
|
41
|
+
/** @deprecated Not a hook; import `navigateRsc`, `clearRscNavigationCache` and `isRscNavigationFromCache`. */
|
|
41
42
|
export const useRscNavigation = () => ({
|
|
42
43
|
clearCache: clearRscNavigationCache,
|
|
43
44
|
isFromCache: isRscNavigationFromCache,
|
package/common/CodeTranscript.ts
CHANGED