akanjs 3.3.0-rc.5 → 3.3.0-rc.7
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/CHANGELOG.md +2 -0
- package/client/appOpenedTab.ts +12 -0
- package/client/device.ts +17 -0
- package/client/index.ts +8 -1
- package/client/router.ts +2 -0
- package/package.json +1 -1
- package/types/client/appOpenedTab.d.ts +1 -0
- package/types/client/device.d.ts +3 -0
- package/types/client/index.d.ts +1 -1
- package/types/ui/Link/Action.d.ts +2 -1
- package/types/ui/recipe/badgeRecipe.d.ts +2 -2
- package/types/ui/recipe/buttonRecipe.d.ts +2 -2
- package/types/ui/recipe/inputRecipe.d.ts +2 -2
- package/types/webkit/useCsrRefs.d.ts +1 -1
- package/types/webkit/useFrameRuntime.d.ts +2 -2
- package/types/webkit/useVisualViewportFrame.d.ts +2 -2
- package/ui/Link/Action.tsx +2 -1
- package/webkit/useCsrKeyboard.ts +7 -1
- package/webkit/useCsrTransitions.ts +24 -17
- package/webkit/useCsrValues.ts +7 -3
- package/webkit/useFrameRuntime.ts +3 -4
- package/webkit/useVisualViewportFrame.tsx +2 -4
package/CHANGELOG.md
CHANGED
|
@@ -19,8 +19,10 @@
|
|
|
19
19
|
### Patch Changes
|
|
20
20
|
|
|
21
21
|
- c44d068: A coding agent reads less to build its first app: the `akanjs` README keeps the path to a first app and links the rest on akanjs.com (17 KB to 7 KB), the `akan-page` and `akan-service` skills ship the API reference one section at a time with every entry named in the skill's index (`Link` now lists the anchor attributes it takes and `Link.Back`, `Link.Close` and `Link.Lang`), the `akan-page` skill holds what a first page looks up while `pageRule` keeps the deeper contract, and each rule is stated once across AGENTS.md, the path rules and the skills. Run `akan agent install` in a workspace to pick up the new files.
|
|
22
|
+
- af09c4f: `router.backOrFallback()` and `Link.Back` with a `fallback` close a browser tab the app itself opened instead of replacing to the fallback, when there is nothing to go back to. The tab counts as opened by the app when it holds one history entry and has an opener or a same-origin referrer, so a `window.open(href, "_blank", "noopener")` or `target="_blank"` link qualifies. A tab the person opened (a bookmark, a typed URL), one another site opened, and an iOS, Android or desktop shell keep going to the fallback, as does a tab the browser refuses to close.
|
|
22
23
|
- 24315d1: A page asks for its stylesheet before its client chunks. The preload tags for the chunks a page's first screen imports are written at the end of `<head>` instead of at its top, so the stylesheet link comes first; the bootstrap module, the dictionary and the import map stay at the top. On a throttled mobile connection (Lighthouse's slow 4G applied in the browser, over HTTP/2) a 56-chunk page first paints about 160 ms sooner (1.83 s to 1.67 s), and a page whose largest element is a small image shows it about 140 ms sooner; a large image still shares the connection with the chunks and arrives when it did. Every chunk still starts loading with the document, so the page hydrates when it did.
|
|
23
24
|
- bf582c1: A page stored in the HTML cache is kept as the bytes it streamed, instead of being decoded to text and encoded again before compression. Storing a 600 KB page takes about a fifth of the main-thread time it did, and the stored page and every response from it are unchanged.
|
|
25
|
+
- e9598f3: Under an iOS shell that leaves the keyboard to the page, the page box now starts moving with the keys on their first frame. It followed a store update and React's render of the frame, which on a phone started the move about 100 ms after the keys, then jumped to catch up. `Device` now sets `--akan-keyboard-cover`, `--akan-keyboard-duration`, `--akan-keyboard-easing` and `data-akan-keyboard` on the root in the shell's keyboard event itself, and the page box's height and bottom padding follow `--akan-keyboard-cover` in CSS, so the transition starts before any render. `isPageKeyboardAvoidance` and `IOS_KEYBOARD_ANIMATION_EASING` now come from `akanjs/client` too.
|
|
24
26
|
- c10f7cf: A loader sends its store at most 500 distinct keys per query and splits a larger batch into several queries that run together. A `load<Model>Many` or a nested list with more ids than a database takes in one statement now loads instead of failing: Postgres refused more than 65,534 values, and SQLite refused a `byQuery` batch of about 1,000 keys.
|
|
25
27
|
- c10f7cf: A loader asks its store for each key once per batch: loads of the same key in one batch share one lookup, and each caller still gets its own document wherever the loader has `copy`, as every model and declared loader does. A `new DataLoader(...)` without `copy` now hands the callers of a repeated key one result object, where a batch function that built a fresh object per position gave each its own: pass `copy` to keep them apart. A batch function that throws, or resolves to something that is not an array, now rejects its callers instead of leaving them waiting.
|
|
26
28
|
- 045699c: The `create-akan-workspace` README shows how to run it on a host with only Node and npm (`npx -y bun@1.4.4 x create-akan-workspace@latest`) and the `npm run build` / `npm start` scripts it then writes, and `akanjs`, `@akanjs/cli` and `create-akan-workspace` each carry a one-line `description`, so `npm view` says what the package is and how to start.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Href } from "./href";
|
|
2
|
+
import { isNativeShell } from "./nativeHost";
|
|
3
|
+
|
|
4
|
+
export const closeAppOpenedTab = (): boolean => {
|
|
5
|
+
const win = globalThis.window;
|
|
6
|
+
if (!win || isNativeShell() || win.history?.length !== 1 || typeof win.close !== "function") return false;
|
|
7
|
+
|
|
8
|
+
const referrer = globalThis.document?.referrer ?? "";
|
|
9
|
+
if (!win.opener && (!referrer || Href.leavesOrigin(referrer, win.location.href))) return false;
|
|
10
|
+
win.close();
|
|
11
|
+
return win.closed === true;
|
|
12
|
+
};
|
package/client/device.ts
CHANGED
|
@@ -11,6 +11,12 @@ type DebugPayload = Record<string, unknown>;
|
|
|
11
11
|
|
|
12
12
|
const globalWithProcess = globalThis as typeof globalThis & { process?: ProcessEnvLike };
|
|
13
13
|
|
|
14
|
+
/** Whether the iOS shell left the keyboard to the page; an older shell still pans to the field, so the page must not. */
|
|
15
|
+
export const isPageKeyboardAvoidance = () =>
|
|
16
|
+
(globalThis as { __AKAN_NATIVE__?: { keyboardAvoidance?: string } }).__AKAN_NATIVE__?.keyboardAvoidance === "page";
|
|
17
|
+
|
|
18
|
+
export const IOS_KEYBOARD_ANIMATION_EASING = "cubic-bezier(0.38, 0.7, 0.125, 1)";
|
|
19
|
+
|
|
14
20
|
const debugSessionId = crypto.getRandomValues(new Uint32Array(1))[0].toString(36);
|
|
15
21
|
let debugSeq = 0;
|
|
16
22
|
|
|
@@ -187,11 +193,22 @@ export class Device {
|
|
|
187
193
|
...(["willShow", "didShow", "willHide", "didHide"] as const).map((event) =>
|
|
188
194
|
keyboard.listen(event, ({ height, duration }) => {
|
|
189
195
|
if (duration > 0) this.keyboardAnimationMs = duration;
|
|
196
|
+
if (isPageKeyboardAvoidance()) this.#moveRootWithKeyboard(height);
|
|
190
197
|
emitKeyboardHeight(event, height);
|
|
191
198
|
}),
|
|
192
199
|
),
|
|
193
200
|
);
|
|
194
201
|
}
|
|
202
|
+
|
|
203
|
+
#moveRootWithKeyboard(height: number) {
|
|
204
|
+
const root = document.documentElement;
|
|
205
|
+
if (this.keyboardAnimationMs > 0) {
|
|
206
|
+
root.style.setProperty("--akan-keyboard-duration", `${this.keyboardAnimationMs}ms`);
|
|
207
|
+
root.style.setProperty("--akan-keyboard-easing", IOS_KEYBOARD_ANIMATION_EASING);
|
|
208
|
+
}
|
|
209
|
+
root.style.setProperty("--akan-keyboard-cover", `${height}px`);
|
|
210
|
+
root.toggleAttribute("data-akan-keyboard", height > 0);
|
|
211
|
+
}
|
|
195
212
|
subscribeKeyboard(onKeyboardChanged: (height: number) => void) {
|
|
196
213
|
this.#keyboardSubscribers.add(onKeyboardChanged);
|
|
197
214
|
return () => {
|
package/client/index.ts
CHANGED
|
@@ -119,7 +119,14 @@ export {
|
|
|
119
119
|
type WebAppManifestIcon,
|
|
120
120
|
} from "./csrTypes";
|
|
121
121
|
export { Toast } from "./decorators";
|
|
122
|
-
export {
|
|
122
|
+
export {
|
|
123
|
+
Device,
|
|
124
|
+
debugFrame,
|
|
125
|
+
IOS_KEYBOARD_ANIMATION_EASING,
|
|
126
|
+
isMobileDevice,
|
|
127
|
+
isNativeTarget,
|
|
128
|
+
isPageKeyboardAvoidance,
|
|
129
|
+
} from "./device";
|
|
123
130
|
export {
|
|
124
131
|
breakpointQuery,
|
|
125
132
|
type DevicePlatform,
|
package/client/router.ts
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
parseBasePaths,
|
|
10
10
|
trimSlashes,
|
|
11
11
|
} from "akanjs/common";
|
|
12
|
+
import { closeAppOpenedTab } from "./appOpenedTab";
|
|
12
13
|
import { CsrLocation, csrLocation } from "./csrLocation";
|
|
13
14
|
import { Href } from "./href";
|
|
14
15
|
import { isMcpView } from "./mcpView";
|
|
@@ -654,6 +655,7 @@ class Router {
|
|
|
654
655
|
this.back(routeOptions);
|
|
655
656
|
return undefined as never;
|
|
656
657
|
}
|
|
658
|
+
if (closeAppOpenedTab()) return undefined as never;
|
|
657
659
|
this.replace(fallbackHref, routeOptions);
|
|
658
660
|
return undefined as never;
|
|
659
661
|
}
|
package/package.json
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const closeAppOpenedTab: () => boolean;
|
package/types/client/device.d.ts
CHANGED
|
@@ -3,6 +3,9 @@ import type { DeviceInfo } from "./native.d.ts";
|
|
|
3
3
|
type NativeModule = typeof import("./native.d.ts");
|
|
4
4
|
type NativeControls = Pick<NativeModule, "haptics" | "keyboard">;
|
|
5
5
|
type DebugPayload = Record<string, unknown>;
|
|
6
|
+
/** Whether the iOS shell left the keyboard to the page; an older shell still pans to the field, so the page must not. */
|
|
7
|
+
export declare const isPageKeyboardAvoidance: () => boolean;
|
|
8
|
+
export declare const IOS_KEYBOARD_ANIMATION_EASING = "cubic-bezier(0.38, 0.7, 0.125, 1)";
|
|
6
9
|
export declare function debugFrame(event: string, payload?: DebugPayload): void;
|
|
7
10
|
interface DeviceInitOption {
|
|
8
11
|
lang: string;
|
package/types/client/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export { createFont, Inter, Nanum_Gothic_Coding, Noto_Sans_KR, Roboto } from "./
|
|
|
5
5
|
export { CsrLocation, csrLocation } from "./csrLocation.d.ts";
|
|
6
6
|
export { type AkanHeadSnapshotNode, type AkanHeadSnapshotV1, type AnimatedDivProps, type ContainerTransition, type CsrContextType, type CsrNavigationKind, type CsrNavigationPhase, type CsrPageType, type CsrStackAccount, type CsrStackEntry, type CsrState, type CsrTransitionStyles, csrContext, DEFAULT_BOTTOM_INSET, DEFAULT_TOP_INSET, type FrameContentViewportState, type FrameLayer, type FrameLayerZIndex, type FrameLayoutState, type FramePlatformProfile, type FrameSlotBucket, type FrameSlotRegistration, type FrameSlotRole, type FrameSlotScope, type FrameSlotType, type FrameSnapshot, type FrameViewportState, type GenerateHead, type Head, type HeadProps, type History, type KeyboardAccessoryFrameState, type KeyboardFrameState, type LayoutErrorProps, type LayoutErrorRender, type LayoutFallbackRoute, type LayoutLoadingProps, type LayoutLoadingRender, type LayoutModule, type LayoutNotFoundProps, type LayoutNotFoundRender, type LayoutProps, type LayoutRender, type Location, type LocationState, type NavigationIntent, type PageActivity, type PageActivityState, type PageConfig, type PageLoadingProps, type PageLoadingRender, type PageModule, type PageOverlayConfig, type PageProps, type PageRender, type PageSafeAreaConfig, type PageState, type PageTransition, type PathContextType, type PathRoute, pageActivityContext, pathContext, type ResolvedHead, type ResolveHead, type ResolveHeadResult, type ResponsiveInset, type Route, type RouteGuard, type RouteGuardProps, type RouteGuide, type RouteModule, type RouteRender, type RouterProps, type RouteState, type RouteViewport, type SafeAreaTransition, type SsrRenderMode, type TransitionAction, type TransitionActionContext, type TransitionPlan, type TransitionStyle, type UseCsrTransition, useCsr, usePathCtx, type WebAppManifest, type WebAppManifestIcon, } from "./csrTypes.d.ts";
|
|
7
7
|
export { Toast } from "./decorators.d.ts";
|
|
8
|
-
export { Device, debugFrame, isMobileDevice, isNativeTarget } from "./device.d.ts";
|
|
8
|
+
export { Device, debugFrame, IOS_KEYBOARD_ANIMATION_EASING, isMobileDevice, isNativeTarget, isPageKeyboardAvoidance, } from "./device.d.ts";
|
|
9
9
|
export { breakpointQuery, type DevicePlatform, defaultPageState, getExplicitPageConfigKeys, type InsetBreakpoint, insetAt, insetBreakpoints, insetsByBreakpoint, isResponsiveInset, mergePageConfigs, type ResolvePageStateOptions, readCssSafeAreaInsets, resolvePageState, type SafeAreaInsets, type TailwindBreakpoint, validatePageConfig, } from "./frameConfig.d.ts";
|
|
10
10
|
export { Href } from "./href.d.ts";
|
|
11
11
|
export { dictionaryContext } from "./locale.d.ts";
|
|
@@ -4,7 +4,8 @@ export interface ActionProps {
|
|
|
4
4
|
children?: ReactNode;
|
|
5
5
|
}
|
|
6
6
|
export interface BackProps extends ActionProps {
|
|
7
|
-
/** Where to go when there is no history to go back to, as on a deep link or a freshly opened app
|
|
7
|
+
/** Where to go when there is no history to go back to, as on a deep link or a freshly opened app; a browser tab this
|
|
8
|
+
* app opened closes instead. */
|
|
8
9
|
fallback?: string;
|
|
9
10
|
}
|
|
10
11
|
export declare const Back: ({ className, children, fallback }: BackProps) => import("react").JSX.Element;
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
export declare const badgeRecipe: (variants?: Omit<({
|
|
3
3
|
size?: "lg" | "md" | "sm" | "xs" | undefined;
|
|
4
4
|
outline?: boolean | undefined;
|
|
5
|
-
variant?: "
|
|
5
|
+
variant?: "error" | "default" | "info" | "warning" | "success" | "primary" | "outline" | "secondary" | "accent" | "neutral" | undefined;
|
|
6
6
|
} & {
|
|
7
7
|
class?: import("tailwind-variants/lite").ClassValue;
|
|
8
8
|
className?: never;
|
|
9
9
|
}) | ({
|
|
10
10
|
size?: "lg" | "md" | "sm" | "xs" | undefined;
|
|
11
11
|
outline?: boolean | undefined;
|
|
12
|
-
variant?: "
|
|
12
|
+
variant?: "error" | "default" | "info" | "warning" | "success" | "primary" | "outline" | "secondary" | "accent" | "neutral" | undefined;
|
|
13
13
|
} & {
|
|
14
14
|
class?: never;
|
|
15
15
|
className?: import("tailwind-variants/lite").ClassValue;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
export declare const buttonRecipe: (variants?: Omit<({
|
|
3
3
|
size?: "xl" | "lg" | "md" | "sm" | "xs" | "icon" | undefined;
|
|
4
4
|
outline?: boolean | undefined;
|
|
5
|
-
variant?: "
|
|
5
|
+
variant?: "link" | "default" | "info" | "warning" | "success" | "destructive" | "primary" | "outline" | "secondary" | "accent" | "neutral" | "ghost" | undefined;
|
|
6
6
|
shape?: "default" | "circle" | "square" | undefined;
|
|
7
7
|
} & {
|
|
8
8
|
class?: import("tailwind-variants/lite").ClassValue;
|
|
@@ -10,7 +10,7 @@ export declare const buttonRecipe: (variants?: Omit<({
|
|
|
10
10
|
}) | ({
|
|
11
11
|
size?: "xl" | "lg" | "md" | "sm" | "xs" | "icon" | undefined;
|
|
12
12
|
outline?: boolean | undefined;
|
|
13
|
-
variant?: "
|
|
13
|
+
variant?: "link" | "default" | "info" | "warning" | "success" | "destructive" | "primary" | "outline" | "secondary" | "accent" | "neutral" | "ghost" | undefined;
|
|
14
14
|
shape?: "default" | "circle" | "square" | undefined;
|
|
15
15
|
} & {
|
|
16
16
|
class?: never;
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
export declare const inputRecipe: (variants?: Omit<({
|
|
3
3
|
kind?: "field" | "select" | "area" | undefined;
|
|
4
4
|
size?: "xl" | "lg" | "md" | "sm" | "xs" | undefined;
|
|
5
|
-
tone?: "
|
|
5
|
+
tone?: "error" | "default" | "primary" | undefined;
|
|
6
6
|
} & {
|
|
7
7
|
class?: import("tailwind-variants/lite").ClassValue;
|
|
8
8
|
className?: never;
|
|
9
9
|
}) | ({
|
|
10
10
|
kind?: "field" | "select" | "area" | undefined;
|
|
11
11
|
size?: "xl" | "lg" | "md" | "sm" | "xs" | undefined;
|
|
12
|
-
tone?: "
|
|
12
|
+
tone?: "error" | "default" | "primary" | undefined;
|
|
13
13
|
} & {
|
|
14
14
|
class?: never;
|
|
15
15
|
className?: import("tailwind-variants/lite").ClassValue;
|
|
@@ -17,8 +17,8 @@ export declare const useCsrRefs: () => {
|
|
|
17
17
|
pageContentRef: import("react").RefObject<HTMLDivElement | null>;
|
|
18
18
|
prevPageContentRef: import("react").RefObject<HTMLDivElement | null>;
|
|
19
19
|
onBack: import("react").RefObject<{
|
|
20
|
-
none?: (() => Promise<void>) | undefined;
|
|
21
20
|
stack?: (() => Promise<void>) | undefined;
|
|
21
|
+
none?: (() => Promise<void>) | undefined;
|
|
22
22
|
fade?: (() => Promise<void>) | undefined;
|
|
23
23
|
bottomUp?: (() => Promise<void>) | undefined;
|
|
24
24
|
scaleOut?: (() => Promise<void>) | undefined;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type FrameLayoutState, type FramePlatformProfile, type FrameSlotRegistration, type FrameSnapshot, type KeyboardFrameState, type Location, type NavigationIntent, type PageState, type PathRoute, type TransitionPlan, type TransitionType } from "akanjs/client";
|
|
1
|
+
import { type FrameLayoutState, type FramePlatformProfile, type FrameSlotRegistration, type FrameSnapshot, IOS_KEYBOARD_ANIMATION_EASING, type KeyboardFrameState, type Location, type NavigationIntent, type PageState, type PathRoute, type TransitionPlan, type TransitionType } from "akanjs/client";
|
|
2
2
|
export type FrameSlotMap = Record<string, Record<string, FrameSlotRegistration>>;
|
|
3
3
|
export type FrameSlotBucket = "active" | "pending";
|
|
4
4
|
export type FrameSlotMapByBucket = Record<FrameSlotBucket, FrameSlotMap>;
|
|
@@ -8,7 +8,7 @@ export declare const KEYBOARD_SHOW_ANIMATION_DURATION_MS = 420;
|
|
|
8
8
|
export declare const KEYBOARD_HIDE_ANIMATION_DURATION_MS = 90;
|
|
9
9
|
export declare const KEYBOARD_SHOW_ANIMATION_EASING = "cubic-bezier(0.16, 1, 0.3, 1)";
|
|
10
10
|
export declare const KEYBOARD_HIDE_ANIMATION_EASING = "cubic-bezier(0.7, 0, 0.84, 0)";
|
|
11
|
-
export
|
|
11
|
+
export { IOS_KEYBOARD_ANIMATION_EASING };
|
|
12
12
|
export declare const FRAME_Z_INDEX: {
|
|
13
13
|
readonly page: 10;
|
|
14
14
|
readonly previousPage: 0;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isPageKeyboardAvoidance } from "akanjs/client";
|
|
1
2
|
export interface VisualViewportFrame {
|
|
2
3
|
/** The on-screen keyboard's height over the layout viewport's bottom; 0 while it is closed. */
|
|
3
4
|
keyboardHeight: number;
|
|
@@ -5,8 +6,7 @@ export interface VisualViewportFrame {
|
|
|
5
6
|
height: number;
|
|
6
7
|
offsetTop: number;
|
|
7
8
|
}
|
|
8
|
-
|
|
9
|
-
export declare const isPageKeyboardAvoidance: () => boolean;
|
|
9
|
+
export { isPageKeyboardAvoidance };
|
|
10
10
|
/**
|
|
11
11
|
* The visible part of the page while the on-screen keyboard is up, on the web. Only `visualViewport` reports the
|
|
12
12
|
* keyboard: `dvh` tracks the browser's own chrome, and iOS pans the visual viewport to the field instead of shrinking
|
package/ui/Link/Action.tsx
CHANGED
|
@@ -8,7 +8,8 @@ export interface ActionProps {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export interface BackProps extends ActionProps {
|
|
11
|
-
/** Where to go when there is no history to go back to, as on a deep link or a freshly opened app
|
|
11
|
+
/** Where to go when there is no history to go back to, as on a deep link or a freshly opened app; a browser tab this
|
|
12
|
+
* app opened closes instead. */
|
|
12
13
|
fallback?: string;
|
|
13
14
|
}
|
|
14
15
|
|
package/webkit/useCsrKeyboard.ts
CHANGED
|
@@ -158,11 +158,17 @@ export type CsrKeyboard = ReturnType<typeof useCsrKeyboard>;
|
|
|
158
158
|
|
|
159
159
|
const useKeyboardRoot = (keyboardFrame: KeyboardFrameState) => {
|
|
160
160
|
useLayoutEffect(() => {
|
|
161
|
+
if (keyboardFrame.avoidsContent) return;
|
|
161
162
|
const root = document.documentElement;
|
|
162
163
|
root.style.setProperty("--akan-keyboard-duration", `${keyboardFrame.animationDuration ?? 0}ms`);
|
|
163
164
|
root.style.setProperty("--akan-keyboard-easing", keyboardFrame.animationEasing ?? "ease");
|
|
164
165
|
root.toggleAttribute("data-akan-keyboard", keyboardFrame.visible);
|
|
165
|
-
}, [
|
|
166
|
+
}, [
|
|
167
|
+
keyboardFrame.avoidsContent,
|
|
168
|
+
keyboardFrame.animationDuration,
|
|
169
|
+
keyboardFrame.animationEasing,
|
|
170
|
+
keyboardFrame.visible,
|
|
171
|
+
]);
|
|
166
172
|
};
|
|
167
173
|
|
|
168
174
|
const useRevealCoveredField = (pageContentRef: CsrRefs["pageContentRef"], keyboardFrame: KeyboardFrameState) => {
|
|
@@ -42,9 +42,6 @@ const tween = (progress: Progress, from: number, to: number) => progress.to([0,
|
|
|
42
42
|
const fadeIn = (progress: Progress) => ({ opacity: progress.to((value) => value) });
|
|
43
43
|
const fadeOut = (progress: Progress) => ({ opacity: progress.to((value) => 1 - value) });
|
|
44
44
|
|
|
45
|
-
const isKeyboardOverContent = ({ keyboard }: RouteState["frameLayout"]) =>
|
|
46
|
-
!!keyboard.avoidsContent && keyboard.visible && !keyboard.sticky;
|
|
47
|
-
|
|
48
45
|
const chromePadding = (pageState: FramePageState, top: number, bottom: number) => ({
|
|
49
46
|
paddingTop: pageState.overlay?.top ? 0 : top,
|
|
50
47
|
paddingBottom: pageState.overlay?.bottom ? 0 : bottom,
|
|
@@ -52,22 +49,32 @@ const chromePadding = (pageState: FramePageState, top: number, bottom: number) =
|
|
|
52
49
|
"--akan-overlay-bottom": `${pageState.overlay?.bottom ? bottom : 0}px`,
|
|
53
50
|
});
|
|
54
51
|
|
|
55
|
-
const
|
|
56
|
-
...
|
|
52
|
+
const keyboardRide = (frameLayout: RouteState["frameLayout"], paddingBottom: number | string) => ({
|
|
53
|
+
...(typeof paddingBottom === "number" && paddingBottom > 0
|
|
54
|
+
? { paddingBottom: `calc(${paddingBottom}px - min(${paddingBottom}px, var(--akan-keyboard-cover, 0px)))` }
|
|
55
|
+
: {}),
|
|
56
|
+
height: `calc(${frameLayout.viewport.height}px - var(--akan-keyboard-cover, 0px))`,
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
const pageContentStyle = ({ frameLayout }: RouteState, pageState: FramePageState) => {
|
|
60
|
+
const padding = chromePadding(
|
|
57
61
|
pageState,
|
|
58
62
|
pageState.topSafeArea + pageState.topInset,
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
})
|
|
63
|
+
Math.max(
|
|
64
|
+
pageState.bottomSafeArea,
|
|
65
|
+
pageState.bottomInset +
|
|
66
|
+
pageState.bottomSafeArea -
|
|
67
|
+
(frameLayout.keyboard.sticky ? frameLayout.keyboardAccessory.height : 0),
|
|
68
|
+
),
|
|
69
|
+
);
|
|
70
|
+
const rides = !!frameLayout.keyboard.avoidsContent && !frameLayout.keyboard.sticky;
|
|
71
|
+
return {
|
|
72
|
+
...padding,
|
|
73
|
+
height: frameLayout.contentViewport.height,
|
|
74
|
+
...(rides ? keyboardRide(frameLayout, padding.paddingBottom) : {}),
|
|
75
|
+
"--akan-content-height": `${frameLayout.contentViewport.height}px`,
|
|
76
|
+
};
|
|
77
|
+
};
|
|
71
78
|
|
|
72
79
|
const prevPageContentStyle = (clientHeight: number, prevPageState: FramePageState) => ({
|
|
73
80
|
...chromePadding(
|
package/webkit/useCsrValues.ts
CHANGED
|
@@ -225,10 +225,14 @@ export const useCsrValues = (rootRouteGuide: RouteGuide, pathRoutes: PathRoute[]
|
|
|
225
225
|
|
|
226
226
|
const contentResizeStyle = useMemo(() => {
|
|
227
227
|
if (!keyboardFrame.avoidsContent && (!shouldAnchorContentBottom || !keyboardFrame.sticky)) return null;
|
|
228
|
-
const duration = keyboardFrame.
|
|
229
|
-
|
|
228
|
+
const duration = keyboardFrame.avoidsContent
|
|
229
|
+
? "var(--akan-keyboard-duration, 250ms)"
|
|
230
|
+
: `${keyboardFrame.animationDuration ?? 420}ms`;
|
|
231
|
+
const easing = keyboardFrame.avoidsContent
|
|
232
|
+
? "var(--akan-keyboard-easing, ease)"
|
|
233
|
+
: (keyboardFrame.animationEasing ?? "cubic-bezier(0.16, 1, 0.3, 1)");
|
|
230
234
|
return {
|
|
231
|
-
transition: `height ${duration}
|
|
235
|
+
transition: `height ${duration} ${easing}, padding-bottom ${duration} ${easing}`,
|
|
232
236
|
willChange: "height, padding-bottom",
|
|
233
237
|
};
|
|
234
238
|
}, [
|
|
@@ -7,6 +7,8 @@ import {
|
|
|
7
7
|
type FramePlatformProfile,
|
|
8
8
|
type FrameSlotRegistration,
|
|
9
9
|
type FrameSnapshot,
|
|
10
|
+
IOS_KEYBOARD_ANIMATION_EASING,
|
|
11
|
+
isPageKeyboardAvoidance,
|
|
10
12
|
type KeyboardAccessoryFrameState,
|
|
11
13
|
type KeyboardFrameState,
|
|
12
14
|
type Location,
|
|
@@ -20,8 +22,6 @@ import {
|
|
|
20
22
|
import { st } from "akanjs/store";
|
|
21
23
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
22
24
|
|
|
23
|
-
import { isPageKeyboardAvoidance } from "./useVisualViewportFrame";
|
|
24
|
-
|
|
25
25
|
export type FrameSlotMap = Record<string, Record<string, FrameSlotRegistration>>;
|
|
26
26
|
export type FrameSlotBucket = "active" | "pending";
|
|
27
27
|
export type FrameSlotMapByBucket = Record<FrameSlotBucket, FrameSlotMap>;
|
|
@@ -31,8 +31,7 @@ export const KEYBOARD_SHOW_ANIMATION_DURATION_MS = 420;
|
|
|
31
31
|
export const KEYBOARD_HIDE_ANIMATION_DURATION_MS = 90;
|
|
32
32
|
export const KEYBOARD_SHOW_ANIMATION_EASING = "cubic-bezier(0.16, 1, 0.3, 1)";
|
|
33
33
|
export const KEYBOARD_HIDE_ANIMATION_EASING = "cubic-bezier(0.7, 0, 0.84, 0)";
|
|
34
|
-
|
|
35
|
-
export const IOS_KEYBOARD_ANIMATION_EASING = "cubic-bezier(0.38, 0.7, 0.125, 1)";
|
|
34
|
+
export { IOS_KEYBOARD_ANIMATION_EASING };
|
|
36
35
|
|
|
37
36
|
export const FRAME_Z_INDEX = {
|
|
38
37
|
page: 10,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { Device } from "akanjs/client";
|
|
2
|
+
import { Device, isPageKeyboardAvoidance } from "akanjs/client";
|
|
3
3
|
import { useEffect, useState } from "react";
|
|
4
4
|
|
|
5
5
|
export interface VisualViewportFrame {
|
|
@@ -10,9 +10,7 @@ export interface VisualViewportFrame {
|
|
|
10
10
|
offsetTop: number;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
export const isPageKeyboardAvoidance = () =>
|
|
15
|
-
(globalThis as { __AKAN_NATIVE__?: { keyboardAvoidance?: string } }).__AKAN_NATIVE__?.keyboardAvoidance === "page";
|
|
13
|
+
export { isPageKeyboardAvoidance };
|
|
16
14
|
|
|
17
15
|
const currentDevice = () => {
|
|
18
16
|
try {
|