akanjs 2.3.0 → 2.3.1-rc.0
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/client/csrTypes.ts +16 -0
- package/constant/fieldInfo.ts +11 -9
- package/constant/getDefault.ts +1 -1
- package/fetch/requestStorage.ts +5 -0
- package/package.json +4 -4
- package/server/akanApp.ts +26 -3
- package/server/akanServer.ts +5 -1
- package/server/cachePolicy.ts +99 -5
- package/server/imageOptimizer.ts +14 -1
- package/server/metadata.tsx +117 -33
- package/server/resolver/database.resolver.ts +4 -4
- package/server/routeElementComposer.tsx +46 -14
- package/server/routeState.ts +379 -0
- package/server/routeTreeBuilder.ts +3 -2
- package/server/rscClient.tsx +316 -46
- package/server/rscClientFetch.ts +57 -0
- package/server/rscClientPatch.ts +157 -0
- package/server/rscHeadPatch.ts +80 -0
- package/server/rscNavigationState.ts +315 -0
- package/server/rscPartialCommit.ts +3 -0
- package/server/rscPatchSafety.ts +57 -0
- package/server/rscSegmentOutlet.tsx +69 -0
- package/server/rscSegmentOutletReference.ts +24 -0
- package/server/rscWorker.tsx +380 -53
- package/server/rscWorkerCache.ts +180 -0
- package/server/rscWorkerHost.ts +40 -12
- package/server/rscWorkerReplay.ts +11 -2
- package/server/ssrFromRscRenderer.tsx +15 -10
- package/server/ssrTypes.ts +18 -0
- package/server/types.tsx +4 -0
- package/server/webRouter.ts +198 -42
- package/service/predefinedAdaptor/database.adaptor.ts +72 -25
- package/signal/signalContext.ts +1 -1
- package/types/client/csrTypes.d.ts +16 -0
- package/types/constant/fieldInfo.d.ts +8 -7
- package/types/fetch/requestStorage.d.ts +2 -0
- package/types/server/cachePolicy.d.ts +36 -0
- package/types/server/metadata.d.ts +10 -1
- package/types/server/routeElementComposer.d.ts +9 -1
- package/types/server/routeState.d.ts +94 -0
- package/types/server/rscClient.d.ts +1 -0
- package/types/server/rscClientFetch.d.ts +24 -0
- package/types/server/rscClientPatch.d.ts +21 -0
- package/types/server/rscHeadPatch.d.ts +12 -0
- package/types/server/rscNavigationState.d.ts +78 -0
- package/types/server/rscPartialCommit.d.ts +1 -0
- package/types/server/rscPatchSafety.d.ts +8 -0
- package/types/server/rscSegmentOutlet.d.ts +17 -0
- package/types/server/rscSegmentOutletReference.d.ts +2 -0
- package/types/server/rscWorker.d.ts +5 -0
- package/types/server/rscWorkerCache.d.ts +63 -0
- package/types/server/rscWorkerHost.d.ts +8 -4
- package/types/server/rscWorkerReplay.d.ts +3 -0
- package/types/server/ssrFromRscRenderer.d.ts +1 -0
- package/types/server/ssrTypes.d.ts +17 -0
- package/types/server/types.d.ts +4 -0
- package/types/server/webRouter.d.ts +7 -3
- package/types/service/predefinedAdaptor/database.adaptor.d.ts +6 -0
- package/types/ui/Button.d.ts +1 -1
- package/types/ui/ClientSide.d.ts +1 -1
- package/types/ui/Constant/Doc.d.ts +6 -6
- package/types/ui/Constant/Mermaid.d.ts +1 -1
- package/types/ui/Constant/index.d.ts +1 -1
- package/types/ui/Constant/schemaDoc.d.ts +1 -1
- package/types/ui/Copy.d.ts +1 -1
- package/types/ui/CsrImage.d.ts +1 -1
- package/types/ui/Data/CardList.d.ts +1 -1
- package/types/ui/Data/Dashboard.d.ts +1 -1
- package/types/ui/Data/Insight.d.ts +1 -1
- package/types/ui/Data/Item.d.ts +6 -6
- package/types/ui/Data/ListContainer.d.ts +1 -1
- package/types/ui/Data/Pagination.d.ts +1 -1
- package/types/ui/Data/TableList.d.ts +1 -1
- package/types/ui/DatePicker.d.ts +3 -3
- package/types/ui/Dialog/Close.d.ts +1 -1
- package/types/ui/Dialog/Content.d.ts +1 -1
- package/types/ui/Dialog/Provider.d.ts +1 -1
- package/types/ui/Dialog/Trigger.d.ts +1 -1
- package/types/ui/Dialog/index.d.ts +3 -3
- package/types/ui/DragAction.d.ts +4 -4
- package/types/ui/DraggableList.d.ts +3 -3
- package/types/ui/Dropdown.d.ts +1 -1
- package/types/ui/Empty.d.ts +1 -1
- package/types/ui/Field.d.ts +22 -22
- package/types/ui/Image.d.ts +1 -1
- package/types/ui/InfiniteScroll.d.ts +1 -1
- package/types/ui/Input.d.ts +6 -6
- package/types/ui/KeyboardAvoiding.d.ts +1 -1
- package/types/ui/Layout/BottomAction.d.ts +1 -1
- package/types/ui/Layout/BottomInset.d.ts +1 -1
- package/types/ui/Layout/BottomTab.d.ts +1 -1
- package/types/ui/Layout/Header.d.ts +1 -1
- package/types/ui/Layout/LeftSider.d.ts +1 -1
- package/types/ui/Layout/Navbar.d.ts +1 -1
- package/types/ui/Layout/RightSider.d.ts +1 -1
- package/types/ui/Layout/Sider.d.ts +1 -1
- package/types/ui/Layout/Template.d.ts +1 -1
- package/types/ui/Layout/TopLeftAction.d.ts +1 -1
- package/types/ui/Layout/Unit.d.ts +1 -1
- package/types/ui/Layout/View.d.ts +1 -1
- package/types/ui/Layout/Zone.d.ts +1 -1
- package/types/ui/Layout/index.d.ts +12 -12
- package/types/ui/Link/Back.d.ts +1 -1
- package/types/ui/Link/Close.d.ts +1 -1
- package/types/ui/Link/CsrLink.d.ts +1 -1
- package/types/ui/Link/Lang.d.ts +1 -1
- package/types/ui/Link/SsrLink.d.ts +1 -1
- package/types/ui/Link/index.d.ts +1 -1
- package/types/ui/Load/Edit.d.ts +1 -1
- package/types/ui/Load/Edit_Client.d.ts +1 -1
- package/types/ui/Load/PageCSR.d.ts +1 -1
- package/types/ui/Load/Pagination.d.ts +1 -1
- package/types/ui/Load/Units.d.ts +1 -1
- package/types/ui/Load/View.d.ts +1 -1
- package/types/ui/Loading/Area.d.ts +1 -1
- package/types/ui/Loading/Button.d.ts +1 -1
- package/types/ui/Loading/Input.d.ts +1 -1
- package/types/ui/Loading/ProgressBar.d.ts +1 -1
- package/types/ui/Loading/Skeleton.d.ts +1 -1
- package/types/ui/Loading/Spin.d.ts +1 -1
- package/types/ui/Loading/index.d.ts +6 -6
- package/types/ui/Menu.d.ts +1 -1
- package/types/ui/Modal.d.ts +1 -1
- package/types/ui/Model/AdminPanel.d.ts +1 -1
- package/types/ui/Model/Edit.d.ts +1 -1
- package/types/ui/Model/EditModal.d.ts +1 -1
- package/types/ui/Model/EditWrapper.d.ts +1 -1
- package/types/ui/Model/LoadInit.d.ts +1 -1
- package/types/ui/Model/New.d.ts +1 -1
- package/types/ui/Model/NewWrapper.d.ts +1 -1
- package/types/ui/Model/NewWrapper_Client.d.ts +1 -1
- package/types/ui/Model/Remove.d.ts +1 -1
- package/types/ui/Model/RemoveWrapper.d.ts +1 -1
- package/types/ui/Model/SureToRemove.d.ts +1 -1
- package/types/ui/Model/View.d.ts +1 -1
- package/types/ui/Model/ViewEditModal.d.ts +1 -1
- package/types/ui/Model/ViewModal.d.ts +1 -1
- package/types/ui/Model/ViewWrapper.d.ts +1 -1
- package/types/ui/More.d.ts +1 -1
- package/types/ui/ObjectId.d.ts +1 -1
- package/types/ui/Popconfirm.d.ts +1 -1
- package/types/ui/Radio.d.ts +2 -2
- package/types/ui/RecentTime.d.ts +1 -1
- package/types/ui/Refresh.d.ts +1 -1
- package/types/ui/ScreenNavigator.d.ts +3 -3
- package/types/ui/Select.d.ts +1 -1
- package/types/ui/Signal/Arg.d.ts +13 -13
- package/types/ui/Signal/Doc.d.ts +6 -6
- package/types/ui/Signal/Listener.d.ts +2 -2
- package/types/ui/Signal/Message.d.ts +4 -4
- package/types/ui/Signal/Object.d.ts +4 -4
- package/types/ui/Signal/PubSub.d.ts +4 -4
- package/types/ui/Signal/Request.d.ts +2 -2
- package/types/ui/Signal/Response.d.ts +3 -3
- package/types/ui/Signal/RestApi.d.ts +5 -5
- package/types/ui/Signal/WebSocket.d.ts +2 -2
- package/types/ui/System/CSR.d.ts +5 -5
- package/types/ui/System/Client.d.ts +8 -8
- package/types/ui/System/Common.d.ts +2 -2
- package/types/ui/System/DevModeToggle.d.ts +1 -1
- package/types/ui/System/Gtag.d.ts +1 -1
- package/types/ui/System/Messages.d.ts +1 -1
- package/types/ui/System/Reconnect.d.ts +1 -1
- package/types/ui/System/Root.d.ts +1 -1
- package/types/ui/System/SSR.d.ts +4 -4
- package/types/ui/System/SelectLanguage.d.ts +1 -1
- package/types/ui/System/ThemeToggle.d.ts +1 -1
- package/types/ui/System/index.d.ts +7 -7
- package/types/ui/Tab/Menu.d.ts +1 -1
- package/types/ui/Tab/Menus.d.ts +1 -1
- package/types/ui/Tab/Panel.d.ts +1 -1
- package/types/ui/Tab/Provider.d.ts +1 -1
- package/types/ui/Tab/index.d.ts +4 -4
- package/types/ui/Table.d.ts +1 -1
- package/types/ui/ToggleSelect.d.ts +2 -2
- package/types/ui/Unauthorized.d.ts +1 -1
- package/ui/Constant/schemaDoc.ts +1 -1
- package/server/resolver/resolver.contract.fixture.ts +0 -222
|
@@ -14,7 +14,8 @@ export interface FieldInfoObject {
|
|
|
14
14
|
export type ExtractFieldInfoObject<Obj extends FieldInfoObject> = {
|
|
15
15
|
[K in keyof Obj]: Obj[K] extends FieldInfo<any, infer FieldValue, infer ExplicitType, infer MapValue> ? unknown extends ExplicitType ? FieldToValue<FieldValue, MapValue> : ExplicitType : never;
|
|
16
16
|
};
|
|
17
|
-
export
|
|
17
|
+
export type ConstantFieldKind = "property" | "hidden" | "secret" | "resolve";
|
|
18
|
+
export interface ConstantFieldProps<FieldType extends ConstantFieldKind = ConstantFieldKind, FieldValue = any, MapValue = any, Metadata = {
|
|
18
19
|
[key: string]: any;
|
|
19
20
|
}> {
|
|
20
21
|
nullable?: boolean;
|
|
@@ -42,7 +43,7 @@ export interface ConstantFieldProps<FieldType extends "property" | "hidden" | "r
|
|
|
42
43
|
}
|
|
43
44
|
export declare const fieldPresets: readonly ["email", "password", "url"];
|
|
44
45
|
export type FieldPreset = (typeof fieldPresets)[number];
|
|
45
|
-
declare class FieldInfo<FieldType extends
|
|
46
|
+
declare class FieldInfo<FieldType extends ConstantFieldKind = any, Value extends ConstantFieldTypeInput | null = null, ExplicitType = unknown, MapValue = Value extends MapConstructor ? typeof PrimitiveScalar : never> {
|
|
46
47
|
readonly value: Value;
|
|
47
48
|
readonly type: ConstantFieldTypeInput;
|
|
48
49
|
readonly option: ConstantFieldProps;
|
|
@@ -54,7 +55,7 @@ declare class FieldInfo<FieldType extends "property" | "hidden" | "resolve" = an
|
|
|
54
55
|
[key: string]: any;
|
|
55
56
|
}>;
|
|
56
57
|
}
|
|
57
|
-
interface ConstantFieldBuildProps<FieldType extends
|
|
58
|
+
interface ConstantFieldBuildProps<FieldType extends ConstantFieldKind = any, FieldValue = any, MapValue = any, Metadata = any, Nullable extends boolean = boolean> {
|
|
58
59
|
nullable: Nullable;
|
|
59
60
|
ref?: string;
|
|
60
61
|
refPath?: string;
|
|
@@ -91,7 +92,7 @@ export type FieldInfoObjectToFieldObject<Obj extends FieldInfoObject> = {
|
|
|
91
92
|
[K in keyof Obj]: Obj[K] extends FieldInfo<infer FieldType, infer Value, infer ExplicitType, infer MapValue> ? ConstantField<FieldType, Value, unknown extends ExplicitType ? FieldToValue<Value, MapValue> : ExplicitType, MapValue> : never;
|
|
92
93
|
};
|
|
93
94
|
/** Runtime metadata for a single Akan constant field. */
|
|
94
|
-
export declare class ConstantField<FieldType extends
|
|
95
|
+
export declare class ConstantField<FieldType extends ConstantFieldKind = ConstantFieldKind, Value extends ConstantFieldTypeInput | null = any, FieldValue = any, MapValue = any, Nullable extends boolean = false, Metadata = {
|
|
95
96
|
[key: string]: any;
|
|
96
97
|
}> implements ConstantFieldBuildProps<FieldType, FieldValue, MapValue, Metadata> {
|
|
97
98
|
static getBaseModelField(): FieldObject;
|
|
@@ -122,7 +123,7 @@ export declare class ConstantField<FieldType extends "property" | "hidden" | "re
|
|
|
122
123
|
readonly optArrDepth: number;
|
|
123
124
|
readonly meta: Metadata;
|
|
124
125
|
constructor(props: ConstantFieldBuildProps<FieldType, FieldValue, MapValue, Metadata>);
|
|
125
|
-
static fromFieldInfo<FieldType extends
|
|
126
|
+
static fromFieldInfo<FieldType extends ConstantFieldKind = any, Value extends ConstantFieldTypeInput | null = null, FieldValue = any, MapValue = any, Nullable extends boolean = false, Metadata = {
|
|
126
127
|
[key: string]: any;
|
|
127
128
|
}>(fieldInfo: FieldInfo<FieldType, Value, FieldValue, MapValue>): ConstantField<FieldType, Value, FieldValue, MapValue, Nullable, Metadata>;
|
|
128
129
|
get isClass(): boolean;
|
|
@@ -138,13 +139,13 @@ type FieldOption<Value extends ConstantFieldTypeInput, MapValue = Value extends
|
|
|
138
139
|
[key: string]: any;
|
|
139
140
|
} = {
|
|
140
141
|
[key: string]: any;
|
|
141
|
-
}, _FieldToValue = FieldToValue<Value, MapValue> | null | undefined> = Omit<ConstantFieldProps<
|
|
142
|
+
}, _FieldToValue = FieldToValue<Value, MapValue> | null | undefined> = Omit<ConstantFieldProps<ConstantFieldKind, _FieldToValue, MapValue, Metadata>, "enum" | "meta" | "nullable" | "fieldType" | "select"> | Omit<ConstantFieldProps<ConstantFieldKind, SingleValue<_FieldToValue>, MapValue, Metadata>, "enum" | "meta" | "nullable" | "fieldType" | "select">[];
|
|
142
143
|
export type PlainTypeToFieldType<PlainType> = PlainType extends [infer First, ...infer Rest] ? PlainTypeToFieldType<First>[] : PlainType extends number ? typeof Int | typeof Float : PlainType extends string ? StringConstructor : typeof Any;
|
|
143
144
|
/** Builds a stored property field with optional validation, default, ref, text, and metadata options. */
|
|
144
145
|
export declare const field: {
|
|
145
146
|
<ExplicitType, Value extends ConstantFieldTypeInput = PlainTypeToFieldType<ExplicitType>, MapValue = Value extends MapConstructor ? typeof PrimitiveScalar : never>(value: Value, option?: FieldOption<Value, MapValue>): FieldInfo<"property", Value, ExplicitType, MapValue>;
|
|
146
147
|
hidden<ExplicitType, Value extends ConstantFieldTypeInput = PlainTypeToFieldType<ExplicitType>, MapValue = Value extends MapConstructor ? typeof PrimitiveScalar : never>(value: Value, option?: FieldOption<Value, MapValue>): FieldInfo<"hidden", Value | null, ExplicitType | null, MapValue>;
|
|
147
|
-
secret<ExplicitType, Value extends ConstantFieldTypeInput = PlainTypeToFieldType<ExplicitType>, MapValue = Value extends MapConstructor ? typeof PrimitiveScalar : never>(value: Value, option?: FieldOption<Value, MapValue>): FieldInfo<"
|
|
148
|
+
secret<ExplicitType, Value extends ConstantFieldTypeInput = PlainTypeToFieldType<ExplicitType>, MapValue = Value extends MapConstructor ? typeof PrimitiveScalar : never>(value: Value, option?: FieldOption<Value, MapValue>): FieldInfo<"secret", Value | null, ExplicitType | null, MapValue>;
|
|
148
149
|
};
|
|
149
150
|
/** Builds a resolved field that is derived rather than treated as a stored property. */
|
|
150
151
|
export declare const resolve: <ExplicitType, Value extends ConstantFieldTypeInput = PlainTypeToFieldType<ExplicitType>, MapValue = Value extends MapConstructor ? typeof PrimitiveScalar : never>(value: Value, option?: FieldOption<Value, MapValue>) => FieldInfo<"resolve", Value, ExplicitType, MapValue>;
|
|
@@ -42,6 +42,8 @@ export declare function getRequestPolicy(): AkanRequestPolicy | undefined;
|
|
|
42
42
|
export declare function updateRequestPolicy(patch: Partial<Omit<AkanRequestPolicy, "tags">> & {
|
|
43
43
|
tags?: Iterable<string>;
|
|
44
44
|
}): AkanRequestPolicy | undefined;
|
|
45
|
+
/** @internal Route cache tag collection is reserved for framework-owned cache policy experiments. */
|
|
46
|
+
export declare function cacheTag(...tags: string[]): AkanRequestPolicy | undefined;
|
|
45
47
|
export declare function getRequestDynamicUsage(): AkanDynamicUsage | undefined;
|
|
46
48
|
/** Deduplicates a promise-producing query within the active request. */
|
|
47
49
|
export declare function memoizeRequestQuery<T>(key: string, factory: () => Promise<T>): Promise<T>;
|
|
@@ -7,15 +7,45 @@ export interface RouteCacheKeyInput {
|
|
|
7
7
|
}
|
|
8
8
|
export interface RouteCacheRenderState {
|
|
9
9
|
cacheable: boolean;
|
|
10
|
+
routeId?: string;
|
|
10
11
|
revalidate?: number | false;
|
|
11
12
|
tags?: string[];
|
|
12
13
|
dynamicUsage?: AkanDynamicUsage;
|
|
13
14
|
reason?: string;
|
|
14
15
|
}
|
|
16
|
+
export interface RouteCacheMetadata {
|
|
17
|
+
pathname: string;
|
|
18
|
+
routeId?: string;
|
|
19
|
+
tags?: string[];
|
|
20
|
+
}
|
|
21
|
+
export interface RouteCacheInvalidation {
|
|
22
|
+
tags?: string[];
|
|
23
|
+
paths?: string[];
|
|
24
|
+
reason?: string;
|
|
25
|
+
}
|
|
15
26
|
export interface RouteCacheEntry {
|
|
16
27
|
key: string;
|
|
17
28
|
ttl: number;
|
|
18
29
|
}
|
|
30
|
+
export interface PublicRouteCacheEntryInput extends RouteCacheKeyInput {
|
|
31
|
+
env: {
|
|
32
|
+
enabled?: string | null;
|
|
33
|
+
ttl?: string | null;
|
|
34
|
+
allow?: string | null;
|
|
35
|
+
deny?: string | null;
|
|
36
|
+
};
|
|
37
|
+
defaultTtl?: number;
|
|
38
|
+
defaultEnabled?: boolean;
|
|
39
|
+
defaultAllow?: boolean;
|
|
40
|
+
}
|
|
41
|
+
export type RouteCacheBypassReason = "env-opt-out" | "dev-default-off" | "ttl-disabled" | "path-excluded" | "request-not-public";
|
|
42
|
+
export type RouteCacheEntryDecision = {
|
|
43
|
+
entry: RouteCacheEntry;
|
|
44
|
+
reason?: undefined;
|
|
45
|
+
} | {
|
|
46
|
+
entry: null;
|
|
47
|
+
reason: RouteCacheBypassReason;
|
|
48
|
+
};
|
|
19
49
|
export type RouteCacheRenderControlType = "redirect" | "not-found" | "error";
|
|
20
50
|
export declare function parsePositiveInt(value: string | undefined | null): number | null;
|
|
21
51
|
export declare function normalizeRouteCacheTtl(value: unknown, fallback?: number): number | null;
|
|
@@ -23,6 +53,7 @@ export declare function resolveAutoRouteCacheTtl(input: {
|
|
|
23
53
|
enabled?: string | null;
|
|
24
54
|
ttl?: string | null;
|
|
25
55
|
defaultTtl?: number;
|
|
56
|
+
defaultEnabled?: boolean;
|
|
26
57
|
}): number | null;
|
|
27
58
|
export declare function combineMinRevalidate(...values: Array<number | false | null | undefined>): number | false | undefined;
|
|
28
59
|
export declare function getClientFacingOrigin(request: Request, url?: URL): string;
|
|
@@ -30,11 +61,14 @@ export declare function isPublicRouteCacheableRequest(request: Request): boolean
|
|
|
30
61
|
export declare function isRouteCachePathAllowed(pathname: string, options?: {
|
|
31
62
|
allow?: string | null;
|
|
32
63
|
deny?: string | null;
|
|
64
|
+
defaultAllow?: boolean;
|
|
33
65
|
}): boolean;
|
|
34
66
|
export declare function createRouteCacheKey({ request, url, theme }: RouteCacheKeyInput): string;
|
|
35
67
|
export declare function createRouteCacheEntry(input: RouteCacheKeyInput & {
|
|
36
68
|
ttl: number;
|
|
37
69
|
}): RouteCacheEntry;
|
|
70
|
+
export declare function resolvePublicRouteCacheEntryDecision(input: PublicRouteCacheEntryInput): RouteCacheEntryDecision;
|
|
71
|
+
export declare function resolvePublicRouteCacheEntry(input: PublicRouteCacheEntryInput): RouteCacheEntry | null;
|
|
38
72
|
export declare function resolveRouteCacheStoreTtl(baseTtl: number, state: RouteCacheRenderState): number | null;
|
|
39
73
|
export declare function shouldStoreRouteCache(input: {
|
|
40
74
|
policy?: AkanRequestPolicy;
|
|
@@ -42,6 +76,8 @@ export declare function shouldStoreRouteCache(input: {
|
|
|
42
76
|
renderControlType?: RouteCacheRenderControlType;
|
|
43
77
|
lateRedirect?: boolean;
|
|
44
78
|
}): RouteCacheRenderState;
|
|
79
|
+
export declare function hasRouteCacheInvalidationScope(invalidation?: RouteCacheInvalidation): boolean;
|
|
80
|
+
export declare function shouldInvalidateRouteCacheEntry(metadata: RouteCacheMetadata, invalidation: RouteCacheInvalidation): boolean;
|
|
45
81
|
export declare class LruTtlCache<T> {
|
|
46
82
|
#private;
|
|
47
83
|
readonly maxEntries: number;
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import type { AkanMetadata, Head, ResolvedHead, ResolveHeadResult } from "akanjs/client";
|
|
2
|
+
import { type AkanHeadSnapshotV1 } from "./routeState.d.ts";
|
|
2
3
|
export declare function isAkanMetadata(value: unknown): value is AkanMetadata;
|
|
4
|
+
export declare function createAkanMetadataHeadSnapshot(metadata: AkanMetadata): AkanHeadSnapshotV1;
|
|
5
|
+
export declare function createAkanLocaleAlternateHeadSnapshot(languages: Record<string, string>): AkanHeadSnapshotV1;
|
|
6
|
+
export declare function mergeAkanHeadSnapshots(...snapshots: Array<AkanHeadSnapshotV1 | null | undefined>): AkanHeadSnapshotV1 | undefined;
|
|
7
|
+
export declare function renderAkanHeadSnapshot(snapshot: AkanHeadSnapshotV1, options?: {
|
|
8
|
+
markRouteOwned?: boolean;
|
|
9
|
+
}): Head;
|
|
3
10
|
export declare function renderMetadata(metadata: AkanMetadata): Head;
|
|
4
11
|
export declare function hasExplicitLanguageAlternates(metadata: AkanMetadata | null | undefined): boolean;
|
|
5
12
|
export declare function shouldRenderLocaleAlternates(options: {
|
|
@@ -8,6 +15,8 @@ export declare function shouldRenderLocaleAlternates(options: {
|
|
|
8
15
|
}): boolean;
|
|
9
16
|
export declare function isResolvedHead(value: unknown): value is ResolvedHead;
|
|
10
17
|
export declare function resolveMetadataHead(metadata: AkanMetadata): ResolvedHead;
|
|
11
|
-
export declare function resolveHeadExport(value: Head | AkanMetadata | null | undefined
|
|
18
|
+
export declare function resolveHeadExport(value: Head | AkanMetadata | null | undefined, options?: {
|
|
19
|
+
includeHeadSnapshot?: boolean;
|
|
20
|
+
}): ResolvedHead;
|
|
12
21
|
export declare function resolveHeadResult(value: ResolveHeadResult): ResolvedHead;
|
|
13
22
|
export declare function normalizeHead(value: Head | AkanMetadata | null | undefined): Head | null | undefined;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Head, LayoutFallbackRoute, PathRoute, ResolvedHead, RouteRender } from "akanjs/client";
|
|
2
2
|
import { type ReactElement, type ReactNode } from "react";
|
|
3
|
+
import { type AkanRouteSegmentState } from "./routeState.d.ts";
|
|
3
4
|
export declare class RouteElementComposer {
|
|
4
5
|
#private;
|
|
5
6
|
static compose({ pathRoute, params, searchParams, }: {
|
|
@@ -7,6 +8,12 @@ export declare class RouteElementComposer {
|
|
|
7
8
|
params: Record<string, string>;
|
|
8
9
|
searchParams: Record<string, string | string[]>;
|
|
9
10
|
}): ReactNode;
|
|
11
|
+
static composeSuffix({ pathRoute, params, searchParams, patchStartIndex, }: {
|
|
12
|
+
pathRoute: PathRoute;
|
|
13
|
+
params: Record<string, string>;
|
|
14
|
+
searchParams: Record<string, string | string[]>;
|
|
15
|
+
patchStartIndex: number;
|
|
16
|
+
}): ReactNode | null;
|
|
10
17
|
static resolveHead({ pathRoute, params, searchParams, }: {
|
|
11
18
|
pathRoute: PathRoute;
|
|
12
19
|
params: Record<string, string>;
|
|
@@ -26,8 +33,9 @@ export declare class RouteElementComposer {
|
|
|
26
33
|
error?: unknown;
|
|
27
34
|
digest?: string;
|
|
28
35
|
}): Promise<ReactNode | null>;
|
|
29
|
-
static composeRenders({ renders, params, searchParams, }: {
|
|
36
|
+
static composeRenders({ renders, segments, params, searchParams, }: {
|
|
30
37
|
renders: RouteRender[];
|
|
38
|
+
segments?: AkanRouteSegmentState[];
|
|
31
39
|
params: Record<string, string>;
|
|
32
40
|
searchParams: Record<string, string | string[]>;
|
|
33
41
|
}): ReactNode;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import type { PathRoute } from "akanjs/client";
|
|
2
|
+
export declare const AKAN_RSC_STATE_VERSION = 1;
|
|
3
|
+
export declare const AKAN_RSC_STATE_VERSION_HEADER = "X-Akan-Rsc-State-Version";
|
|
4
|
+
export declare const AKAN_RSC_CURRENT_ROUTE_HEADER = "X-Akan-Rsc-Current-Route";
|
|
5
|
+
export declare const AKAN_RSC_CURRENT_STATE_HEADER = "X-Akan-Rsc-Current-State";
|
|
6
|
+
export declare const AKAN_RSC_RESPONSE_STATE_HEADER = "X-Akan-Rsc-State";
|
|
7
|
+
export declare const AKAN_RSC_PATCH_START_INDEX_HEADER = "X-Akan-Rsc-Patch-Start-Index";
|
|
8
|
+
export declare const AKAN_RSC_PATCH_SEGMENT_PATH_HEADER = "X-Akan-Rsc-Patch-Segment-Path";
|
|
9
|
+
export declare const AKAN_RSC_PATCH_START_SEGMENT_HEADER = "X-Akan-Rsc-Patch-Start-Segment";
|
|
10
|
+
export declare const AKAN_RSC_PATCH_HEAD_SAFE_HEADER = "X-Akan-Rsc-Patch-Head-Safe";
|
|
11
|
+
export declare const AKAN_RSC_PATCH_HEAD_SNAPSHOT_HEADER = "X-Akan-Rsc-Patch-Head-Snapshot";
|
|
12
|
+
export declare const AKAN_RSC_HEAD_SNAPSHOT_VERSION = 1;
|
|
13
|
+
export declare const AKAN_RSC_HEAD_SNAPSHOT_MAX_HEADER_BYTES: number;
|
|
14
|
+
export type AkanRscPartialStatus = "full" | "candidate" | "patch" | "fallback";
|
|
15
|
+
export interface AkanRouteSegmentState {
|
|
16
|
+
key: string;
|
|
17
|
+
path: string;
|
|
18
|
+
kind: "root-layout" | "layout" | "page";
|
|
19
|
+
}
|
|
20
|
+
export interface AkanRouterStateV1 {
|
|
21
|
+
version: typeof AKAN_RSC_STATE_VERSION;
|
|
22
|
+
buildId?: number;
|
|
23
|
+
href: string;
|
|
24
|
+
routeId: string;
|
|
25
|
+
segments: AkanRouteSegmentState[];
|
|
26
|
+
}
|
|
27
|
+
export type AkanHeadSnapshotTag = "title" | "meta" | "link";
|
|
28
|
+
export interface AkanHeadSnapshotNode {
|
|
29
|
+
tag: AkanHeadSnapshotTag;
|
|
30
|
+
attrs?: Record<string, string>;
|
|
31
|
+
text?: string;
|
|
32
|
+
}
|
|
33
|
+
export interface AkanHeadSnapshotV1 {
|
|
34
|
+
version: typeof AKAN_RSC_HEAD_SNAPSHOT_VERSION;
|
|
35
|
+
nodes: AkanHeadSnapshotNode[];
|
|
36
|
+
}
|
|
37
|
+
export type AkanHeadSnapshotDecodeResult = {
|
|
38
|
+
status: "ok";
|
|
39
|
+
snapshot: AkanHeadSnapshotV1;
|
|
40
|
+
} | {
|
|
41
|
+
status: "missing" | "invalid" | "too-large";
|
|
42
|
+
};
|
|
43
|
+
export interface AkanRscPartialDecision {
|
|
44
|
+
status: AkanRscPartialStatus;
|
|
45
|
+
reason?: string;
|
|
46
|
+
commonPrefixLength: number;
|
|
47
|
+
}
|
|
48
|
+
export interface AkanRscPatchMetadata {
|
|
49
|
+
patchStartIndex: number;
|
|
50
|
+
patchStartSegmentKey: string;
|
|
51
|
+
segmentPath: string[];
|
|
52
|
+
headSafe?: boolean;
|
|
53
|
+
headSnapshot?: AkanHeadSnapshotV1;
|
|
54
|
+
headSnapshotFailure?: "head-invalid" | "head-too-large";
|
|
55
|
+
}
|
|
56
|
+
export interface AkanRscPatchDecision extends AkanRscPartialDecision {
|
|
57
|
+
status: "full" | "patch" | "fallback";
|
|
58
|
+
patch?: AkanRscPatchMetadata;
|
|
59
|
+
}
|
|
60
|
+
export declare function isAkanHeadSnapshotV1(value: unknown): value is AkanHeadSnapshotV1;
|
|
61
|
+
export declare function isAkanRouterStateV1(value: unknown): value is AkanRouterStateV1;
|
|
62
|
+
export declare function encodeAkanRouterState(state: AkanRouterStateV1): string;
|
|
63
|
+
export declare function encodeAkanHeadSnapshot(snapshot: AkanHeadSnapshotV1): string | null;
|
|
64
|
+
export declare function decodeAkanHeadSnapshot(value: string | null | undefined): AkanHeadSnapshotDecodeResult;
|
|
65
|
+
export declare function readAkanHeadSnapshotResponseHeader(headers: Headers): AkanHeadSnapshotDecodeResult;
|
|
66
|
+
export declare function decodeAkanRouterState(value: string | null | undefined): AkanRouterStateV1 | null;
|
|
67
|
+
export declare function appendAkanRouterStateRequestHeaders(headers: Headers, state: AkanRouterStateV1 | null | undefined): void;
|
|
68
|
+
export declare function readAkanRouterStateResponseHeader(headers: Headers): AkanRouterStateV1 | null;
|
|
69
|
+
export declare function encodeAkanRscPatchSegmentPath(segmentPath: string[]): string;
|
|
70
|
+
export declare function decodeAkanRscPatchSegmentPath(value: string | null | undefined): string[] | null;
|
|
71
|
+
export declare function readAkanRscPatchMetadataResponseHeaders(headers: Headers): AkanRscPatchMetadata | null;
|
|
72
|
+
export declare function createAkanRouterState({ pathRoute, href, buildId, }: {
|
|
73
|
+
pathRoute: PathRoute;
|
|
74
|
+
href: string;
|
|
75
|
+
buildId?: number;
|
|
76
|
+
}): AkanRouterStateV1;
|
|
77
|
+
export declare function createAkanRouteSegments(pathRoute: PathRoute): AkanRouteSegmentState[];
|
|
78
|
+
export declare function createAkanSegmentOutletKey(segmentPath: string[], segmentIndex: number): string | null;
|
|
79
|
+
export declare function readAkanRouterStateRequest(headers: Headers): {
|
|
80
|
+
state: AkanRouterStateV1 | null;
|
|
81
|
+
currentRoute?: string;
|
|
82
|
+
reason?: string;
|
|
83
|
+
};
|
|
84
|
+
export declare function resolveAkanRscPartialDecision({ currentState, currentRoute, targetState, }: {
|
|
85
|
+
currentState: AkanRouterStateV1 | null;
|
|
86
|
+
currentRoute?: string;
|
|
87
|
+
targetState: AkanRouterStateV1;
|
|
88
|
+
}): AkanRscPartialDecision;
|
|
89
|
+
export declare function resolveAkanRscPatchDecision({ currentState, targetState, partialDecision, }: {
|
|
90
|
+
currentState: AkanRouterStateV1 | null;
|
|
91
|
+
targetState: AkanRouterStateV1;
|
|
92
|
+
partialDecision: AkanRscPartialDecision;
|
|
93
|
+
}): AkanRscPatchDecision;
|
|
94
|
+
export declare function countCommonRouteSegments(currentSegments: AkanRouteSegmentState[], targetSegments: AkanRouteSegmentState[]): number;
|
|
@@ -4,6 +4,7 @@ declare global {
|
|
|
4
4
|
var __RSC_CLOSED__: boolean | undefined;
|
|
5
5
|
var __RSC_PUSH__: ((type: InlineRscChunk[0], data: string) => void) | undefined;
|
|
6
6
|
var __RSC_CLOSE__: (() => void) | undefined;
|
|
7
|
+
var __AKAN_RSC_INITIAL_STATE__: string | undefined;
|
|
7
8
|
var __AKAN_RSC_NAVIGATE__: ((href: string, options?: {
|
|
8
9
|
replace?: boolean;
|
|
9
10
|
scrollToTop?: boolean;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type AkanRouterStateV1, type AkanRscPatchMetadata } from "./routeState.d.ts";
|
|
2
|
+
type RscNavigate = (href: string, options?: {
|
|
3
|
+
replace?: boolean;
|
|
4
|
+
scrollToTop?: boolean;
|
|
5
|
+
}) => Promise<void> | void;
|
|
6
|
+
export type RscClientFetchResponseResult = {
|
|
7
|
+
type: "response";
|
|
8
|
+
response: Response;
|
|
9
|
+
} | {
|
|
10
|
+
type: "patch";
|
|
11
|
+
response: Response;
|
|
12
|
+
patch: AkanRscPatchMetadata;
|
|
13
|
+
} | {
|
|
14
|
+
type: "redirected";
|
|
15
|
+
status?: number;
|
|
16
|
+
};
|
|
17
|
+
export declare function fetchRscNavigationResponse(href: string, options: {
|
|
18
|
+
buildId?: number;
|
|
19
|
+
currentRouterState: AkanRouterStateV1 | null;
|
|
20
|
+
navigate?: RscNavigate;
|
|
21
|
+
sendRouterState?: boolean;
|
|
22
|
+
shouldApplyNavigation?: () => boolean;
|
|
23
|
+
}): Promise<RscClientFetchResponseResult>;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type AkanHeadSnapshotV1, type AkanRscPatchMetadata } from "./routeState.d.ts";
|
|
2
|
+
import { type AkanSegmentCacheNode, type AkanSegmentPatchFailureReason, type AkanSegmentPatchResult } from "./rscNavigationState.d.ts";
|
|
3
|
+
interface ValidateRscSegmentPatchInput<T extends PromiseLike<unknown>> {
|
|
4
|
+
href: string;
|
|
5
|
+
response: Response;
|
|
6
|
+
patch: AkanRscPatchMetadata;
|
|
7
|
+
currentTree: AkanSegmentCacheNode<T> | null;
|
|
8
|
+
createThenable: (stream: ReadableStream<Uint8Array>) => T;
|
|
9
|
+
navId?: number;
|
|
10
|
+
getCurrentNavId?: () => number;
|
|
11
|
+
getHeadSnapshotPatchFailureReason?: (snapshot: AkanHeadSnapshotV1) => AkanSegmentPatchFailureReason | null;
|
|
12
|
+
}
|
|
13
|
+
export declare function validateRscPatchAndRequestFullFallback<T extends PromiseLike<unknown>>({ href, response, patch, currentTree, createThenable, navId, getCurrentNavId, }: ValidateRscSegmentPatchInput<T>): Promise<{
|
|
14
|
+
sendRouterState: false;
|
|
15
|
+
patchResult: AkanSegmentPatchResult<T>;
|
|
16
|
+
}>;
|
|
17
|
+
export declare function validateRscSegmentPatch<T extends PromiseLike<unknown>>({ href, response, patch, currentTree, createThenable, navId, getCurrentNavId, }: ValidateRscSegmentPatchInput<T>): Promise<AkanSegmentPatchResult<T>>;
|
|
18
|
+
export declare function validateRscPatchForGuardedCommit<T extends PromiseLike<unknown>>({ partialCommitEnabled, ...input }: ValidateRscSegmentPatchInput<T> & {
|
|
19
|
+
partialCommitEnabled: boolean;
|
|
20
|
+
}): Promise<AkanSegmentPatchResult<T>>;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { AkanHeadSnapshotV1 } from "./routeState.d.ts";
|
|
2
|
+
import type { AkanSegmentPatchFailureReason } from "./rscNavigationState.d.ts";
|
|
3
|
+
export interface PreparedAkanHeadSnapshotPatch {
|
|
4
|
+
existing: HTMLElement[];
|
|
5
|
+
replacement: HTMLElement[];
|
|
6
|
+
}
|
|
7
|
+
export declare function getAkanHeadSnapshotPatchFailureReason(snapshot: AkanHeadSnapshotV1): Extract<AkanSegmentPatchFailureReason, "head-missing" | "head-invalid"> | null;
|
|
8
|
+
export declare function canApplyAkanHeadSnapshotPatch(snapshot: AkanHeadSnapshotV1): boolean;
|
|
9
|
+
export declare function prepareAkanHeadSnapshotPatch(snapshot: AkanHeadSnapshotV1): PreparedAkanHeadSnapshotPatch | null;
|
|
10
|
+
export declare function commitPreparedAkanHeadSnapshotPatch(prepared: PreparedAkanHeadSnapshotPatch): boolean;
|
|
11
|
+
export declare function rollbackPreparedAkanHeadSnapshotPatch(prepared: PreparedAkanHeadSnapshotPatch): void;
|
|
12
|
+
export declare function applyAkanHeadSnapshotPatch(snapshot: AkanHeadSnapshotV1): boolean;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type AkanHeadSnapshotV1, type AkanRouterStateV1, type AkanRouteSegmentState, type AkanRscPatchMetadata } from "./routeState.d.ts";
|
|
1
2
|
export interface RscNavigationCache<T> {
|
|
2
3
|
get(key: string): T | undefined;
|
|
3
4
|
set(key: string, value: T): void;
|
|
@@ -5,8 +6,77 @@ export interface RscNavigationCache<T> {
|
|
|
5
6
|
keys(): IterableIterator<string>;
|
|
6
7
|
readonly size: number;
|
|
7
8
|
}
|
|
9
|
+
export interface RscNavigationCacheNode<T> {
|
|
10
|
+
href: string;
|
|
11
|
+
thenable: T;
|
|
12
|
+
routerState: AkanRouterStateV1 | null;
|
|
13
|
+
}
|
|
14
|
+
export interface RscPatchNavigationCacheNode<T> {
|
|
15
|
+
href: string;
|
|
16
|
+
thenable: T;
|
|
17
|
+
routerState: AkanRouterStateV1;
|
|
18
|
+
patch: AkanRscPatchMetadata;
|
|
19
|
+
outletKey: string;
|
|
20
|
+
headSnapshot: AkanHeadSnapshotV1;
|
|
21
|
+
}
|
|
22
|
+
export interface AkanSegmentCacheNode<T> {
|
|
23
|
+
segment: AkanRouteSegmentState;
|
|
24
|
+
href: string;
|
|
25
|
+
routerState: AkanRouterStateV1;
|
|
26
|
+
thenable?: T;
|
|
27
|
+
children: AkanSegmentCacheNode<T>[];
|
|
28
|
+
}
|
|
29
|
+
export type AkanSegmentPatchFailureReason = "missing-current-tree" | "segment-path-mismatch" | "stale" | "unsupported-suffix" | "decode-error" | "guard-disabled" | "outlet-missing" | "redirect-in-patch" | "error-in-patch" | "head-unsafe" | "head-missing" | "head-invalid" | "head-too-large";
|
|
30
|
+
export type AkanSegmentPatchResult<T> = {
|
|
31
|
+
status: "patched";
|
|
32
|
+
tree: AkanSegmentCacheNode<T>;
|
|
33
|
+
patchedNode: AkanSegmentCacheNode<T>;
|
|
34
|
+
outletKey: string;
|
|
35
|
+
headSnapshot?: AkanHeadSnapshotV1;
|
|
36
|
+
} | {
|
|
37
|
+
status: "rejected";
|
|
38
|
+
reason: AkanSegmentPatchFailureReason;
|
|
39
|
+
};
|
|
40
|
+
export type RscPatchNavigationCacheResult<T> = {
|
|
41
|
+
status: "patched";
|
|
42
|
+
tree: AkanSegmentCacheNode<T>;
|
|
43
|
+
patchedNode: AkanSegmentCacheNode<T>;
|
|
44
|
+
outletKey: string;
|
|
45
|
+
headSnapshot: AkanHeadSnapshotV1;
|
|
46
|
+
} | {
|
|
47
|
+
status: "rejected";
|
|
48
|
+
reason: AkanSegmentPatchFailureReason;
|
|
49
|
+
};
|
|
50
|
+
export declare function createRscNavigationCacheNode<T>({ href, thenable, routerState, }: RscNavigationCacheNode<T>): RscNavigationCacheNode<T>;
|
|
51
|
+
export declare function createRscPatchNavigationCacheNode<T>({ href, patch, patchedNode, outletKey, headSnapshot, }: {
|
|
52
|
+
href: string;
|
|
53
|
+
patch: AkanRscPatchMetadata;
|
|
54
|
+
patchedNode: AkanSegmentCacheNode<T>;
|
|
55
|
+
outletKey: string;
|
|
56
|
+
headSnapshot: AkanHeadSnapshotV1;
|
|
57
|
+
}): RscPatchNavigationCacheNode<T> | null;
|
|
58
|
+
export declare function createAkanSegmentCacheTree<T>(node: RscNavigationCacheNode<T>): AkanSegmentCacheNode<T> | null;
|
|
59
|
+
export declare function applyAkanSegmentCachePatch<T>({ currentTree, targetRouterState, patch, href, thenable, navId, getCurrentNavId, decodeFailed, }: {
|
|
60
|
+
currentTree: AkanSegmentCacheNode<T> | null;
|
|
61
|
+
targetRouterState: AkanRouterStateV1 | null;
|
|
62
|
+
patch: AkanRscPatchMetadata;
|
|
63
|
+
href: string;
|
|
64
|
+
thenable?: T;
|
|
65
|
+
navId?: number;
|
|
66
|
+
getCurrentNavId?: () => number;
|
|
67
|
+
decodeFailed?: boolean;
|
|
68
|
+
}): AkanSegmentPatchResult<T>;
|
|
8
69
|
export declare function rememberRscCacheEntry<T>(cache: RscNavigationCache<T>, href: string, thenable: T, maxEntries: number): void;
|
|
9
70
|
export declare function deleteRscCacheEntryIfCurrent<T>(cache: RscNavigationCache<T>, href: string, thenable: T): boolean;
|
|
71
|
+
export declare function rememberRscCacheNode<T>(cache: RscNavigationCache<RscNavigationCacheNode<T>>, node: RscNavigationCacheNode<T>, maxEntries: number): void;
|
|
72
|
+
export declare function rememberRscPatchCacheNode<T>(cache: RscNavigationCache<RscPatchNavigationCacheNode<T>>, node: RscPatchNavigationCacheNode<T>, maxEntries: number): void;
|
|
73
|
+
export declare function resolveCachedRscPatchNavigation<T>({ currentTree, node, partialCommitEnabled, navId, getCurrentNavId, }: {
|
|
74
|
+
currentTree: AkanSegmentCacheNode<T> | null;
|
|
75
|
+
node: RscPatchNavigationCacheNode<T>;
|
|
76
|
+
partialCommitEnabled: boolean;
|
|
77
|
+
navId?: number;
|
|
78
|
+
getCurrentNavId?: () => number;
|
|
79
|
+
}): RscPatchNavigationCacheResult<T>;
|
|
10
80
|
interface CommitRscNavigationInput<T> {
|
|
11
81
|
cache: RscNavigationCache<T>;
|
|
12
82
|
href: string;
|
|
@@ -32,4 +102,12 @@ export declare function observeRscNavigation<T extends PromiseLike<unknown>>({ c
|
|
|
32
102
|
isExpectedNavigationError?: (error: unknown) => boolean;
|
|
33
103
|
onLatestError: (error: unknown) => void;
|
|
34
104
|
}): void;
|
|
105
|
+
export declare function observeRscNavigationNode<T extends PromiseLike<unknown>>({ cache, node, navId, getCurrentNavId, isExpectedNavigationError, onLatestError, }: {
|
|
106
|
+
cache: RscNavigationCache<RscNavigationCacheNode<T>>;
|
|
107
|
+
node: RscNavigationCacheNode<T>;
|
|
108
|
+
navId: number;
|
|
109
|
+
getCurrentNavId: () => number;
|
|
110
|
+
isExpectedNavigationError?: (error: unknown) => boolean;
|
|
111
|
+
onLatestError: (error: unknown) => void;
|
|
112
|
+
}): void;
|
|
35
113
|
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isAkanRscPartialCommitEnabled(): boolean;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { PageConfig } from "akanjs/client";
|
|
2
|
+
import { type AkanHeadSnapshotV1, type AkanRscPatchDecision } from "./routeState.d.ts";
|
|
3
|
+
export declare function resolveAkanRscHeadSafePatchDecision({ partialCommitEnabled, patchDecision, pageConfig, headSnapshot, }: {
|
|
4
|
+
partialCommitEnabled: boolean;
|
|
5
|
+
patchDecision: AkanRscPatchDecision;
|
|
6
|
+
pageConfig?: PageConfig;
|
|
7
|
+
headSnapshot?: AkanHeadSnapshotV1;
|
|
8
|
+
}): AkanRscPatchDecision;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
type RscSegmentThenable = PromiseLike<ReactNode>;
|
|
3
|
+
interface RscSegmentOutletStore {
|
|
4
|
+
entries: Map<string, RscSegmentThenable>;
|
|
5
|
+
listeners: Map<string, Set<() => void>>;
|
|
6
|
+
}
|
|
7
|
+
declare global {
|
|
8
|
+
var __AKAN_RSC_SEGMENT_OUTLET_STORE__: RscSegmentOutletStore | undefined;
|
|
9
|
+
}
|
|
10
|
+
export declare function hasAkanSegmentOutlet(segmentKey: string): boolean;
|
|
11
|
+
export declare function commitAkanSegmentOutletPatch(segmentKey: string, thenable: RscSegmentThenable): boolean;
|
|
12
|
+
export declare function resetAkanSegmentOutletPatches(): void;
|
|
13
|
+
export declare function AkanSegmentOutlet({ segmentKey, children }: {
|
|
14
|
+
segmentKey: string;
|
|
15
|
+
children: ReactNode;
|
|
16
|
+
}): ReactNode;
|
|
17
|
+
export {};
|
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
import type { AkanNotFoundError, AkanRedirectError } from "akanjs/client";
|
|
2
2
|
export declare function isAkanRedirectError(error: unknown): error is AkanRedirectError;
|
|
3
3
|
export declare function isAkanNotFoundError(error: unknown): error is AkanNotFoundError;
|
|
4
|
+
export declare class RscRenderer {
|
|
5
|
+
#private;
|
|
6
|
+
constructor();
|
|
7
|
+
start(): void;
|
|
8
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { type LruTtlCache, type RouteCacheEntry, type RouteCacheInvalidation, type RouteCacheRenderState } from "./cachePolicy.d.ts";
|
|
2
|
+
import type { AkanRouterStateV1, AkanRscPatchDecision, AkanRscPatchMetadata } from "./routeState.d.ts";
|
|
3
|
+
export interface CachedRscResult {
|
|
4
|
+
chunks: Uint8Array[];
|
|
5
|
+
bytes: number;
|
|
6
|
+
chunksCount: number;
|
|
7
|
+
pathname: string;
|
|
8
|
+
routeId?: string;
|
|
9
|
+
tags?: string[];
|
|
10
|
+
theme?: string;
|
|
11
|
+
cacheState: RouteCacheRenderState;
|
|
12
|
+
patch?: CachedRscPatchMetadata;
|
|
13
|
+
}
|
|
14
|
+
export interface CachedRscPatchMetadata {
|
|
15
|
+
targetRouterState: AkanRouterStateV1;
|
|
16
|
+
patch: AkanRscPatchMetadata;
|
|
17
|
+
}
|
|
18
|
+
export interface RscPatchCacheKeyInput {
|
|
19
|
+
baseEntry: RouteCacheEntry;
|
|
20
|
+
targetRouterState: AkanRouterStateV1;
|
|
21
|
+
patch: AkanRscPatchMetadata;
|
|
22
|
+
}
|
|
23
|
+
export declare function createRscPatchCacheKey({ baseEntry, targetRouterState, patch }: RscPatchCacheKeyInput): string;
|
|
24
|
+
export declare function createRscPatchCacheEntry(input: RscPatchCacheKeyInput): RouteCacheEntry;
|
|
25
|
+
export declare function isRscPatchResultCacheEligible(input: {
|
|
26
|
+
partialCommitEnabled: boolean;
|
|
27
|
+
patch?: AkanRscPatchMetadata;
|
|
28
|
+
}): boolean;
|
|
29
|
+
export declare function createCachedRscPatchMetadata(input: {
|
|
30
|
+
targetRouterState: AkanRouterStateV1;
|
|
31
|
+
patch: AkanRscPatchMetadata;
|
|
32
|
+
}): CachedRscPatchMetadata;
|
|
33
|
+
export declare function isCachedRscPatchMetadataCompatible(input: {
|
|
34
|
+
cached?: CachedRscPatchMetadata;
|
|
35
|
+
targetRouterState: AkanRouterStateV1 | null;
|
|
36
|
+
safePatchDecision: AkanRscPatchDecision;
|
|
37
|
+
}): boolean;
|
|
38
|
+
export declare function createRscWorkerCachedPatchReplayDecision(input: {
|
|
39
|
+
cached: CachedRscPatchMetadata;
|
|
40
|
+
safePatchDecision: AkanRscPatchDecision;
|
|
41
|
+
}): AkanRscPatchDecision;
|
|
42
|
+
export declare function resolveRscWorkerPatchCacheEntry(input: {
|
|
43
|
+
cacheEntry: RouteCacheEntry | null;
|
|
44
|
+
targetRouterState: AkanRouterStateV1 | null;
|
|
45
|
+
safePatchDecision: AkanRscPatchDecision;
|
|
46
|
+
partialCommitEnabled: boolean;
|
|
47
|
+
}): RouteCacheEntry | null;
|
|
48
|
+
export declare function shouldCollectRscWorkerRenderChunks(input: {
|
|
49
|
+
cacheEntry: RouteCacheEntry | null;
|
|
50
|
+
effectivePatchDecision: AkanRscPatchDecision;
|
|
51
|
+
patchCacheEntry: RouteCacheEntry | null;
|
|
52
|
+
}): boolean;
|
|
53
|
+
export declare function shouldStoreRscWorkerPatchResult(input: {
|
|
54
|
+
cacheEntry: RouteCacheEntry | null;
|
|
55
|
+
patchCacheEntry: RouteCacheEntry | null;
|
|
56
|
+
effectivePatchDecision: AkanRscPatchDecision;
|
|
57
|
+
storeTtl: number | null;
|
|
58
|
+
}): boolean;
|
|
59
|
+
export declare function shouldUseRscWorkerFullResultCache(input: {
|
|
60
|
+
cacheEntry: RouteCacheEntry | null;
|
|
61
|
+
patchCacheEntry: RouteCacheEntry | null;
|
|
62
|
+
}): boolean;
|
|
63
|
+
export declare function invalidateCachedRscResults(cache: LruTtlCache<CachedRscResult>, invalidation: RouteCacheInvalidation): void;
|
|
@@ -2,8 +2,8 @@ import { type AkanI18nConfig } from "akanjs/common";
|
|
|
2
2
|
import type { AkanTheme } from "akanjs/fetch";
|
|
3
3
|
import type { AkanMetricsReport } from "akanjs/service";
|
|
4
4
|
import type { ClientManifest } from "./artifact.d.ts";
|
|
5
|
-
import type { RouteCacheRenderState } from "./cachePolicy.d.ts";
|
|
6
|
-
import type { SsrLateRedirect } from "./ssrTypes.d.ts";
|
|
5
|
+
import type { RouteCacheInvalidation, RouteCacheRenderState } from "./cachePolicy.d.ts";
|
|
6
|
+
import type { RscTraceMetadata, SsrLateRedirect } from "./ssrTypes.d.ts";
|
|
7
7
|
import type { BaseBuildArtifact, CssAsset } from "./types.d.ts";
|
|
8
8
|
export interface RscPending {
|
|
9
9
|
onChunk: (data: Uint8Array) => void;
|
|
@@ -12,6 +12,7 @@ export interface RscPending {
|
|
|
12
12
|
onMeta?: (meta: {
|
|
13
13
|
theme?: AkanTheme;
|
|
14
14
|
status?: number;
|
|
15
|
+
trace?: RscTraceMetadata;
|
|
15
16
|
}) => void;
|
|
16
17
|
onCacheState?: (state: RouteCacheRenderState) => void;
|
|
17
18
|
onRedirect?: (location: string, method: RscRedirectMethod, status: RscRedirectStatus) => void;
|
|
@@ -23,12 +24,15 @@ export type RscRedirectStatus = 303 | 307 | 308;
|
|
|
23
24
|
export interface RscWorkerInvalidateCacheMessage {
|
|
24
25
|
type: "invalidate-cache";
|
|
25
26
|
reason?: string;
|
|
27
|
+
tags?: string[];
|
|
28
|
+
paths?: string[];
|
|
26
29
|
}
|
|
27
30
|
export type RscRenderResult = {
|
|
28
31
|
type: "stream";
|
|
29
32
|
stream: ReadableStream<Uint8Array>;
|
|
30
33
|
theme?: AkanTheme;
|
|
31
34
|
status?: number;
|
|
35
|
+
trace?: RscTraceMetadata;
|
|
32
36
|
lateControl: Promise<SsrLateRedirect | null>;
|
|
33
37
|
cacheState: Promise<RouteCacheRenderState>;
|
|
34
38
|
cancel: (reason?: unknown) => void;
|
|
@@ -44,7 +48,7 @@ export declare function getRscHostMaxPendingChunks(value?: string | undefined):
|
|
|
44
48
|
export declare function nextRscHostPendingChunkCount(currentPendingChunks: number, desiredSize: number | null): number;
|
|
45
49
|
export declare function isRscHostPendingChunkOverflow(pendingChunks: number, maxPendingChunks: number): boolean;
|
|
46
50
|
export declare function createIdempotentRscRenderCancel(onCancel: (reason?: unknown) => void): (reason?: unknown) => void;
|
|
47
|
-
export declare function createRscWorkerInvalidateCacheMessage(
|
|
51
|
+
export declare function createRscWorkerInvalidateCacheMessage(invalidation?: string | RouteCacheInvalidation): RscWorkerInvalidateCacheMessage;
|
|
48
52
|
export declare function createRscHostRenderStream(input: {
|
|
49
53
|
setPending: (pending: RscPending) => void;
|
|
50
54
|
deletePending: () => void;
|
|
@@ -102,7 +106,7 @@ export declare class RscWorker {
|
|
|
102
106
|
clientManifest?: ClientManifest;
|
|
103
107
|
signal?: AbortSignal;
|
|
104
108
|
}): Promise<RscRenderResult>;
|
|
105
|
-
invalidateRouteResultCache(
|
|
109
|
+
invalidateRouteResultCache(invalidation?: string | RouteCacheInvalidation): void;
|
|
106
110
|
kill(): void;
|
|
107
111
|
getMetrics(): AkanMetricsReport;
|
|
108
112
|
restartWhenIdle(reason: string): boolean;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { RouteCacheRenderState } from "./cachePolicy.d.ts";
|
|
2
|
+
import type { RscTraceMetadata } from "./ssrTypes.d.ts";
|
|
2
3
|
export type CachedRscReplayMessage = {
|
|
3
4
|
type: "meta";
|
|
4
5
|
requestId: string;
|
|
5
6
|
theme?: string;
|
|
6
7
|
status?: number;
|
|
8
|
+
trace?: RscTraceMetadata;
|
|
7
9
|
} | {
|
|
8
10
|
type: "cache-state";
|
|
9
11
|
requestId: string;
|
|
@@ -21,6 +23,7 @@ export declare function replayCachedRscResult(input: {
|
|
|
21
23
|
chunks: readonly Uint8Array[];
|
|
22
24
|
theme?: string;
|
|
23
25
|
status?: number;
|
|
26
|
+
trace?: RscTraceMetadata;
|
|
24
27
|
cacheState?: RouteCacheRenderState;
|
|
25
28
|
send: (message: CachedRscReplayMessage) => void;
|
|
26
29
|
isCancelled: () => boolean;
|