akanjs 3.3.0-rc.13 → 3.3.0-rc.14

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 CHANGED
@@ -348,6 +348,7 @@
348
348
  ### Patch Changes
349
349
 
350
350
  - 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.
351
+ - 43b44ca: An Android app's page now meets the keyboard the way the iOS app's does: the keys rise over the page and only what the page moves rides up with them. In keyboard mode "none" (what akan apps ship) the Android WebView still heard of the keyboard through the window insets, shrank its visual viewport to the space above the keys and panned the whole page so the focused field showed, which lifted a chat composer far above the keys, dragged whatever sat under it (a tab bar's room) up too, and slid the top of the page under the status bar. The Android shell now hands the WebView its insets with the keyboard taken out in "none" (and its animation callbacks too), keeps the bottom safe area while the keys are up, reports the keys' whole overlap with the screen as the iOS shell does, and tells the page through `__AKAN_NATIVE__.keyboardAvoidance = "page"`. Under such a shell the frame ends the content at the keys and `KeyboardRide` carries what is marked `data-akan-keyboard-ride` with them, on the duration the shell reports and Android's IME curve (`ANDROID_KEYBOARD_ANIMATION_EASING`, added to `akanjs/client`). A page under an older shell, which still pans, keeps today's behavior; an Android app gets the new behavior once it is built with this shell.
351
352
  - 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.
352
353
  - 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.
353
354
  - 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.
package/client/device.ts CHANGED
@@ -12,12 +12,18 @@ type DebugPayload = Record<string, unknown>;
12
12
 
13
13
  const globalWithProcess = globalThis as typeof globalThis & { process?: ProcessEnvLike };
14
14
 
15
- /** Whether the iOS shell left the keyboard to the page; an older shell still pans to the field, so the page must not. */
15
+ /** Whether the shell left the keyboard to the page; an older shell still pans to the field, so the page must not. */
16
16
  export const isPageKeyboardAvoidance = () =>
17
17
  (globalThis as { __AKAN_NATIVE__?: { keyboardAvoidance?: string } }).__AKAN_NATIVE__?.keyboardAvoidance === "page";
18
18
 
19
19
  export const IOS_KEYBOARD_ANIMATION_EASING = "cubic-bezier(0.38, 0.7, 0.125, 1)";
20
20
 
21
+ export const ANDROID_KEYBOARD_ANIMATION_EASING = "cubic-bezier(0.2, 0, 0, 1)";
22
+ export const nativeKeyboardEasing = () =>
23
+ (globalThis as { __AKAN_NATIVE__?: { platform?: string } }).__AKAN_NATIVE__?.platform === "android"
24
+ ? ANDROID_KEYBOARD_ANIMATION_EASING
25
+ : IOS_KEYBOARD_ANIMATION_EASING;
26
+
21
27
  const debugSessionId = crypto.getRandomValues(new Uint32Array(1))[0].toString(36);
22
28
  let debugSeq = 0;
23
29
 
package/client/index.ts CHANGED
@@ -119,6 +119,7 @@ export {
119
119
  } from "./csrTypes";
120
120
  export { Toast } from "./decorators";
121
121
  export {
122
+ ANDROID_KEYBOARD_ANIMATION_EASING,
122
123
  Device,
123
124
  debugFrame,
124
125
  IOS_KEYBOARD_ANIMATION_EASING,
@@ -1,4 +1,4 @@
1
- import { IOS_KEYBOARD_ANIMATION_EASING } from "./device";
1
+ import { nativeKeyboardEasing } from "./device";
2
2
 
3
3
  const RIDE_SELECTOR = "[data-akan-keyboard-ride]";
4
4
  const OVERLAY_SELECTOR = "[data-akan-keyboard-overlay]";
@@ -8,7 +8,7 @@ const bottomOf = (element: HTMLElement) => element.getBoundingClientRect().botto
8
8
  const isInset = (rider: HTMLElement) => rider.dataset.akanKeyboardRide === "inset";
9
9
 
10
10
  /**
11
- * Moves the page with an iOS keyboard the shell left to it. A layout change on every frame drops frames on a phone, so
11
+ * Moves the page with a phone keyboard the shell left to it. A layout change on every frame drops frames on a phone, so
12
12
  * the layout changes once and what is marked `data-akan-keyboard-ride` travels the way there as a transform, which
13
13
  * WebKit hands to Core Animation. A scroller resting at its end stays there, as a chat list does.
14
14
  *
@@ -32,7 +32,7 @@ export class KeyboardRide {
32
32
  const root = document.documentElement;
33
33
  if (durationMs > 0) {
34
34
  root.style.setProperty("--akan-keyboard-duration", `${durationMs}ms`);
35
- root.style.setProperty("--akan-keyboard-easing", IOS_KEYBOARD_ANIMATION_EASING);
35
+ root.style.setProperty("--akan-keyboard-easing", nativeKeyboardEasing());
36
36
  }
37
37
  const isOverlay =
38
38
  height > 0
@@ -65,7 +65,7 @@ export class KeyboardRide {
65
65
  rider.style.transform = `translateY(${drawn[idx] - laid[idx]}px)`;
66
66
  });
67
67
  void root.offsetHeight;
68
- const transition = `transform ${durationMs}ms ${IOS_KEYBOARD_ANIMATION_EASING}`;
68
+ const transition = `transform ${durationMs}ms ${nativeKeyboardEasing()}`;
69
69
  riders.forEach((rider, idx) => {
70
70
  rider.style.transition = transition;
71
71
  rider.style.transform = `translateY(${settled[idx] - laid[idx]}px)`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "akanjs",
3
- "version": "3.3.0-rc.13",
3
+ "version": "3.3.0-rc.14",
4
4
  "sourceType": "module",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -3,9 +3,11 @@ 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. */
6
+ /** Whether the shell left the keyboard to the page; an older shell still pans to the field, so the page must not. */
7
7
  export declare const isPageKeyboardAvoidance: () => boolean;
8
8
  export declare const IOS_KEYBOARD_ANIMATION_EASING = "cubic-bezier(0.38, 0.7, 0.125, 1)";
9
+ export declare const ANDROID_KEYBOARD_ANIMATION_EASING = "cubic-bezier(0.2, 0, 0, 1)";
10
+ export declare const nativeKeyboardEasing: () => "cubic-bezier(0.2, 0, 0, 1)" | "cubic-bezier(0.38, 0.7, 0.125, 1)";
9
11
  export declare function debugFrame(event: string, payload?: DebugPayload): void;
10
12
  interface DeviceInitOption {
11
13
  lang: string;
@@ -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, IOS_KEYBOARD_ANIMATION_EASING, isMobileDevice, isNativeTarget, isPageKeyboardAvoidance, } from "./device.d.ts";
8
+ export { ANDROID_KEYBOARD_ANIMATION_EASING, 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, 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 { type ErrPayload, makePageProto, type PageErrConstructor, type PageErrInstance, type TransMessageOption, } from "./makePageProto.d.ts";
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Moves the page with an iOS keyboard the shell left to it. A layout change on every frame drops frames on a phone, so
2
+ * Moves the page with a phone keyboard the shell left to it. A layout change on every frame drops frames on a phone, so
3
3
  * the layout changes once and what is marked `data-akan-keyboard-ride` travels the way there as a transform, which
4
4
  * WebKit hands to Core Animation. A scroller resting at its end stays there, as a chat list does.
5
5
  *
@@ -51,8 +51,8 @@ export interface AkanNativeBoot {
51
51
  engine?: string;
52
52
  engineVersion?: string;
53
53
  /**
54
- * iOS: "page" when the shell took the WebView's own keyboard avoidance away (keyboard mode "none"), so nothing
55
- * pans the page to a focused field and the page lays itself out from the keyboard plugin's events.
54
+ * "page" when the shell took the WebView's own keyboard avoidance away (keyboard mode "none", iOS and Android), so
55
+ * nothing pans the page to a focused field and the page lays itself out from the keyboard plugin's events.
56
56
  */
57
57
  keyboardAvoidance?: "page";
58
58
  }
@@ -7,8 +7,9 @@ export interface KeyboardState {
7
7
  * What the keyboard does to the page (akanjs readiness O6-1):
8
8
  * - "resize" (default, or the app config's keyboard.resize): the page's viewport shrinks by the keyboard, so bottom-fixed UI stays above it
9
9
  * (Android pads the WebView's container, iOS shortens the web view with the keyboard's animation).
10
- * - "none": the page keeps its full size and the keyboard covers its bottom; the app moves its UI
11
- * itself with the heights of the events. iOS still scrolls a focused field into view.
10
+ * - "none": the page keeps its full size and the keyboard covers its bottom (the whole overlap, Android's navigation
11
+ * bar included); the app moves its UI itself with the heights of the events, and neither WebView pans to a focused
12
+ * field (`__AKAN_NATIVE__.keyboardAvoidance` is "page").
12
13
  */
13
14
  export type KeyboardResizeMode = "resize" | "none";
14
15
  /** A keyboard transition: its height in CSS pixels once it ends (0 when hiding) and its animation length in ms. */
@@ -1,4 +1,4 @@
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";
1
+ import { ANDROID_KEYBOARD_ANIMATION_EASING, 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 { IOS_KEYBOARD_ANIMATION_EASING };
11
+ export { ANDROID_KEYBOARD_ANIMATION_EASING, IOS_KEYBOARD_ANIMATION_EASING };
12
12
  export declare const FRAME_Z_INDEX: {
13
13
  readonly page: 10;
14
14
  readonly previousPage: 0;
@@ -27,6 +27,7 @@
27
27
 
28
28
  ### Patch Changes
29
29
 
30
+ - 43b44ca: An Android app's page now meets the keyboard the way the iOS app's does: the keys rise over the page and only what the page moves rides up with them. In keyboard mode "none" (what akan apps ship) the Android WebView still heard of the keyboard through the window insets, shrank its visual viewport to the space above the keys and panned the whole page so the focused field showed, which lifted a chat composer far above the keys, dragged whatever sat under it (a tab bar's room) up too, and slid the top of the page under the status bar. The Android shell now hands the WebView its insets with the keyboard taken out in "none" (and its animation callbacks too), keeps the bottom safe area while the keys are up, reports the keys' whole overlap with the screen as the iOS shell does, and tells the page through `__AKAN_NATIVE__.keyboardAvoidance = "page"`. Under such a shell the frame ends the content at the keys and `KeyboardRide` carries what is marked `data-akan-keyboard-ride` with them, on the duration the shell reports and Android's IME curve (`ANDROID_KEYBOARD_ANIMATION_EASING`, added to `akanjs/client`). A page under an older shell, which still pans, keeps today's behavior; an Android app gets the new behavior once it is built with this shell.
30
31
  - 3032627: An iOS app's page now meets the keyboard the way a native screen does: its content ends at the keys and moves with them, and a header stays where it is. In keyboard mode "none" (what akan apps ship) WKWebView still met the keyboard on its own, insetting its scroll view and panning the whole page until the focused field cleared the keys, so the header went off screen, the page showed under the status bar, and whatever the frame did for the keyboard came on top of the pan. The iOS shell now takes the keyboard notifications away from WKWebView in "none", as Capacitor's Keyboard plugin does, and tells the page through `__AKAN_NATIVE__.keyboardAvoidance = "page"`. Under such a shell the frame ends every page's content at the keys (not only a page with a keyboard accessory), drops the bottom safe area and inset the keys cover, animates on the duration the shell reports with UIKit's keyboard curve (`IOS_KEYBOARD_ANIMATION_EASING`), and scrolls a field the keys cover back into view; a dialog ends at the keys too, `useVisualViewportFrame` reports the keys from the shell, `KeyboardAvoiding` steps aside, and `--akan-keyboard-duration` / `--akan-keyboard-easing` plus `data-akan-keyboard` (while the keys are up) on the root let a page move its own parts with the keys. A page under an older shell, which still pans, keeps today's behavior.
31
32
 
32
33
  The api report lists additions only: `Device.keyboardAnimationMs`, `Device.keyboardHeight` and `Device.subscribeKeyboard`, the optional `KeyboardFrameState.avoidsContent` and `isPageKeyboardAvoidance` from `akanjs/webkit`; no upgrade step is needed. An iOS app gets the new behavior once it is built with this shell; a page that lifted its own composer by the keyboard's height under the old pan should drop that lift.
@@ -358,8 +358,9 @@ class AkanNativeActivity : Activity(), AkanNativePluginContext.Host {
358
358
  // The shell's origin and engine: one value every origin comparison uses (`__AKAN_NATIVE__.origin`).
359
359
  val version = JSONObject.quote(WebView.getCurrentWebViewPackage()?.versionName ?: "")
360
360
  val engine = "window.__AKAN_NATIVE__.origin=\"${AkanNativeAssetServer.ORIGIN}\";window.__AKAN_NATIVE__.engine=\"android-webview\";window.__AKAN_NATIVE__.engineVersion=$version;\n"
361
+ val keyboard = if (imeResize) "" else "window.__AKAN_NATIVE__.keyboardAvoidance=\"page\";\n"
361
362
  // A new document starts with the current safe area (N14); later changes are pushed.
362
- return INIT_PREFIX + AkanNativeBridge.jsSafe(bootJson) + "," + AkanNativeBridge.jsSafe(env) + INIT_SUFFIX + engine + cssInsets(currentInsets)
363
+ return INIT_PREFIX + AkanNativeBridge.jsSafe(bootJson) + "," + AkanNativeBridge.jsSafe(env) + INIT_SUFFIX + engine + keyboard + cssInsets(currentInsets)
363
364
  }
364
365
 
365
366
  private fun readAsset(path: String): String = assets.open(path).bufferedReader().use { it.readText() }
@@ -605,8 +606,9 @@ class AkanNativeActivity : Activity(), AkanNativePluginContext.Host {
605
606
  val m = if (Build.VERSION.SDK_INT >= 30) Api30.measure(insets) else legacyMeasure(insets)
606
607
  val sys = m.bars
607
608
  val density = resources.displayMetrics.density
608
- // Keyboard height above the navigation bar, like react-native ReactRootView.
609
- val keyboard = if (m.imeVisible) maxOf(0, m.imeBottom - sys.bottom) else 0
609
+ // Keyboard height above the navigation bar, like react-native ReactRootView; a page that meets the keyboard
610
+ // itself spans the screen, so it gets the whole overlap, as on iOS.
611
+ val keyboard = if (!m.imeVisible) 0 else if (imeResize) maxOf(0, m.imeBottom - sys.bottom) else m.imeBottom
610
612
  val next = AkanNativeInsets(sys.top / density, sys.right / density, sys.bottom / density, sys.left / density, m.imeVisible, keyboard / density)
611
613
  if (next != currentInsets) {
612
614
  val wasVisible = currentInsets.imeVisible
@@ -625,11 +627,13 @@ class AkanNativeActivity : Activity(), AkanNativePluginContext.Host {
625
627
  // "Resize" keyboard mode: shrink the WebView container by the IME so fixed bottom UI stays
626
628
  // visible (WebView ignores interactive-widget). Do not consume the insets (crbug 461332423).
627
629
  view.setPadding(0, 0, 0, if (m.imeVisible && imeResize) m.imeBottom else 0)
628
- val bars = Insets.of(sys.left, sys.top, sys.right, if (m.imeVisible) 0 else sys.bottom)
629
- if (Build.VERSION.SDK_INT >= 30) Api30.withBars(insets, bars)
630
+ // Keyboard mode "none": the WebView never hears of the keyboard, or it shrinks its visual viewport and pans the
631
+ // page to the focused field on top of what the page does (`keyboardAvoidance`).
632
+ val bars = Insets.of(sys.left, sys.top, sys.right, if (m.imeVisible && imeResize) 0 else sys.bottom)
633
+ if (Build.VERSION.SDK_INT >= 30) Api30.withBars(insets, bars, hidesIme = !imeResize)
630
634
  else @Suppress("DEPRECATION") WindowInsets.Builder(insets).setSystemWindowInsets(bars).build()
631
635
  }
632
- if (Build.VERSION.SDK_INT >= 30) Api30.watchImeAnimation(root) { show, heightPx, duration, done ->
636
+ if (Build.VERSION.SDK_INT >= 30) Api30.watchImeAnimation(root, { !imeResize }) { show, heightPx, duration, done ->
633
637
  val phase = if (done) (if (show) "didShow" else "didHide") else (if (show) "willShow" else "willHide")
634
638
  keyboardTransition(phase, if (show) heightPx / resources.displayMetrics.density else 0f, duration)
635
639
  }
@@ -658,9 +662,9 @@ class AkanNativeActivity : Activity(), AkanNativePluginContext.Host {
658
662
  return Measured(bars, if (imeVisible) sw.bottom else 0, imeVisible)
659
663
  }
660
664
 
661
- /** The CSS variables for these insets, in CSS px; bottom is 0 while the keyboard shows (as WebView's env() does). */
665
+ /** The CSS variables for these insets, in CSS px; bottom is 0 while the keyboard shows over a resized WebView (as WebView's env() does). */
662
666
  private fun cssInsets(i: AkanNativeInsets): String {
663
- val bottom = if (i.imeVisible) 0f else i.bottom
667
+ val bottom = if (i.imeVisible && imeResize) 0f else i.bottom
664
668
  return "document.documentElement&&(function(s){s.setProperty('--akan-native-safe-area-top','${i.top}px');" +
665
669
  "s.setProperty('--akan-native-safe-area-right','${i.right}px');s.setProperty('--akan-native-safe-area-bottom','${bottom}px');" +
666
670
  "s.setProperty('--akan-native-safe-area-left','${i.left}px')})(document.documentElement.style);\n"
@@ -947,19 +951,27 @@ class AkanNativeActivity : Activity(), AkanNativePluginContext.Host {
947
951
  return Measured(insets.getInsets(bars), if (visible) insets.getInsets(ime).bottom else 0, visible)
948
952
  }
949
953
 
950
- fun withBars(insets: WindowInsets, value: Insets): WindowInsets = WindowInsets.Builder(insets).setInsets(bars, value).build()
954
+ fun withBars(insets: WindowInsets, value: Insets, hidesIme: Boolean): WindowInsets =
955
+ WindowInsets.Builder(insets).setInsets(bars, value).build().let { if (hidesIme) withoutIme(it) else it }
956
+
957
+ fun withoutIme(insets: WindowInsets): WindowInsets {
958
+ val ime = WindowInsets.Type.ime()
959
+ return WindowInsets.Builder(insets).setInsets(ime, Insets.NONE).setVisible(ime, false).build()
960
+ }
951
961
 
952
962
  /**
953
963
  * The IME's show and hide animations: [report] (show, height px above the bars once it ends,
954
- * duration ms, ended) at the start and at the end. At the start the view's root insets are
955
- * already the end state.
964
+ * or the whole overlap when [isPage], duration ms, ended) at the start and at the end. At the
965
+ * start the view's root insets are already the end state. With [isPage] the WebView's own
966
+ * animation callbacks see no IME either.
956
967
  */
957
- fun watchImeAnimation(view: View, report: (Boolean, Float, Long, Boolean) -> Unit) {
968
+ fun watchImeAnimation(view: View, isPage: () -> Boolean, report: (Boolean, Float, Long, Boolean) -> Unit) {
958
969
  val ime = WindowInsets.Type.ime()
959
970
  fun target(): Pair<Boolean, Float> {
960
971
  val insets = view.rootWindowInsets ?: return false to 0f
961
972
  val show = insets.isVisible(ime)
962
- val height = maxOf(0, insets.getInsets(ime).bottom - insets.getInsets(WindowInsets.Type.systemBars()).bottom)
973
+ val bottom = insets.getInsets(ime).bottom
974
+ val height = if (isPage()) bottom else maxOf(0, bottom - insets.getInsets(WindowInsets.Type.systemBars()).bottom)
963
975
  return show to height.toFloat()
964
976
  }
965
977
  view.setWindowInsetsAnimationCallback(object : android.view.WindowInsetsAnimation.Callback(DISPATCH_MODE_CONTINUE_ON_SUBTREE) {
@@ -968,7 +980,8 @@ class AkanNativeActivity : Activity(), AkanNativePluginContext.Host {
968
980
  return bounds
969
981
  }
970
982
 
971
- override fun onProgress(insets: WindowInsets, running: MutableList<android.view.WindowInsetsAnimation>): WindowInsets = insets
983
+ override fun onProgress(insets: WindowInsets, running: MutableList<android.view.WindowInsetsAnimation>): WindowInsets =
984
+ if (isPage()) withoutIme(insets) else insets
972
985
 
973
986
  override fun onEnd(animation: android.view.WindowInsetsAnimation) {
974
987
  if (animation.typeMask and ime != 0) target().let { (show, height) -> report(show, height, animation.durationMillis, true) }
@@ -50,8 +50,8 @@ export interface AkanNativeBoot {
50
50
  engine?: string;
51
51
  engineVersion?: string;
52
52
  /**
53
- * iOS: "page" when the shell took the WebView's own keyboard avoidance away (keyboard mode "none"), so nothing
54
- * pans the page to a focused field and the page lays itself out from the keyboard plugin's events.
53
+ * "page" when the shell took the WebView's own keyboard avoidance away (keyboard mode "none", iOS and Android), so
54
+ * nothing pans the page to a focused field and the page lays itself out from the keyboard plugin's events.
55
55
  */
56
56
  keyboardAvoidance?: "page";
57
57
  }
@@ -12,8 +12,9 @@ export interface KeyboardState {
12
12
  * What the keyboard does to the page (akanjs readiness O6-1):
13
13
  * - "resize" (default, or the app config's keyboard.resize): the page's viewport shrinks by the keyboard, so bottom-fixed UI stays above it
14
14
  * (Android pads the WebView's container, iOS shortens the web view with the keyboard's animation).
15
- * - "none": the page keeps its full size and the keyboard covers its bottom; the app moves its UI
16
- * itself with the heights of the events. iOS still scrolls a focused field into view.
15
+ * - "none": the page keeps its full size and the keyboard covers its bottom (the whole overlap, Android's navigation
16
+ * bar included); the app moves its UI itself with the heights of the events, and neither WebView pans to a focused
17
+ * field (`__AKAN_NATIVE__.keyboardAvoidance` is "page").
17
18
  */
18
19
  export type KeyboardResizeMode = "resize" | "none";
19
20
 
@@ -1,5 +1,6 @@
1
1
  "use client";
2
2
  import {
3
+ ANDROID_KEYBOARD_ANIMATION_EASING,
3
4
  Device,
4
5
  debugFrame,
5
6
  defaultPageState,
@@ -31,7 +32,7 @@ export const KEYBOARD_SHOW_ANIMATION_DURATION_MS = 420;
31
32
  export const KEYBOARD_HIDE_ANIMATION_DURATION_MS = 90;
32
33
  export const KEYBOARD_SHOW_ANIMATION_EASING = "cubic-bezier(0.16, 1, 0.3, 1)";
33
34
  export const KEYBOARD_HIDE_ANIMATION_EASING = "cubic-bezier(0.7, 0, 0.84, 0)";
34
- export { IOS_KEYBOARD_ANIMATION_EASING };
35
+ export { ANDROID_KEYBOARD_ANIMATION_EASING, IOS_KEYBOARD_ANIMATION_EASING };
35
36
 
36
37
  export const FRAME_Z_INDEX = {
37
38
  page: 10,
@@ -283,7 +284,8 @@ export function resolveKeyboardFrame({
283
284
  pageAvoidsKeyboard?: boolean;
284
285
  nativeAnimationDuration?: number;
285
286
  }): KeyboardFrameState {
286
- const useVisualViewportHeight = platformProfile === "android" && visualViewportKeyboardHeight > 0;
287
+ const useVisualViewportHeight =
288
+ platformProfile === "android" && !pageAvoidsKeyboard && visualViewportKeyboardHeight > 0;
287
289
  const visualFallbackHeight =
288
290
  keyboardHeight <= 0 && visualViewportKeyboardHeight > 0 ? visualViewportKeyboardHeight : 0;
289
291
  const effectiveKeyboardHeight = useVisualViewportHeight
@@ -304,7 +306,7 @@ export function resolveKeyboardFrame({
304
306
  : 0;
305
307
  const offset = sticky && !freeze ? Math.max(0, effectiveKeyboardHeight - visualCompensation) : 0;
306
308
  const isShowing = effectiveKeyboardHeight > 0 && !freeze;
307
- const avoidsContent = platformProfile === "ios" && pageAvoidsKeyboard;
309
+ const avoidsContent = (platformProfile === "ios" || platformProfile === "android") && pageAvoidsKeyboard;
308
310
  const followsKeyboard = avoidsContent && nativeAnimationDuration > 0;
309
311
  return {
310
312
  height: effectiveKeyboardHeight,
@@ -319,7 +321,9 @@ export function resolveKeyboardFrame({
319
321
  ? KEYBOARD_SHOW_ANIMATION_DURATION_MS
320
322
  : KEYBOARD_HIDE_ANIMATION_DURATION_MS,
321
323
  animationEasing: followsKeyboard
322
- ? IOS_KEYBOARD_ANIMATION_EASING
324
+ ? platformProfile === "android"
325
+ ? ANDROID_KEYBOARD_ANIMATION_EASING
326
+ : IOS_KEYBOARD_ANIMATION_EASING
323
327
  : isShowing
324
328
  ? KEYBOARD_SHOW_ANIMATION_EASING
325
329
  : KEYBOARD_HIDE_ANIMATION_EASING,