akanjs 3.3.0-rc.26 → 3.3.0-rc.28
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 +4 -0
- package/client/keyboardRide.ts +120 -28
- package/package.json +1 -1
- package/server/selfExec.ts +13 -1
- package/types/client/keyboardRide.d.ts +4 -2
- package/types/server/selfExec.d.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -521,6 +521,10 @@
|
|
|
521
521
|
|
|
522
522
|
- 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.
|
|
523
523
|
- 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.
|
|
524
|
+
- 6443972: `AppWorker.spawn` runs the worker when the server itself was started as `bun -e <code>`: under `akan start`, and in a backend a gateway starts.
|
|
525
|
+
|
|
526
|
+
Such a server handed its own start code on to the worker's command, so the child ran the server's code again with the worker file as an argument, exited with 1 and was started again every second: the worker never ran, and the log showed `[Worker:<name>] WARN exited 1; restarting in 1000ms` over and over. A server started from its file (`bun main.js` with no backends of its own) was not affected. The same command builds the `ops snapshot` and `ops migrate` children, which now leave the start code out as well.
|
|
527
|
+
|
|
524
528
|
- f678e80: The `akanjs` package no longer ships `ARCHITECTURE.md`. The map of the framework's processes and messages is for contributors and stays in the repository (`pkgs/akanjs/ARCHITECTURE.md`); a coding agent building an app read its 11.9 KB from the unpacked package before scaffolding. Verifying a built `akanjs` dist now fails if the file is back in it.
|
|
525
529
|
- 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.
|
|
526
530
|
- 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.
|
package/client/keyboardRide.ts
CHANGED
|
@@ -4,7 +4,16 @@ const RIDE_SELECTOR = "[data-akan-keyboard-ride]";
|
|
|
4
4
|
const OVERLAY_SELECTOR = "[data-akan-keyboard-overlay]";
|
|
5
5
|
const END_SLACK_PX = 2;
|
|
6
6
|
|
|
7
|
+
const GLIDE_ATTRIBUTE = "data-akan-keyboard-glide";
|
|
8
|
+
|
|
7
9
|
const bottomOf = (element: HTMLElement) => element.getBoundingClientRect().bottom;
|
|
10
|
+
|
|
11
|
+
const isReversed = (scroller: HTMLElement) => getComputedStyle(scroller).flexDirection === "column-reverse";
|
|
12
|
+
const isAtEnd = (scroller: HTMLElement) =>
|
|
13
|
+
isReversed(scroller)
|
|
14
|
+
? Math.abs(scroller.scrollTop) <= END_SLACK_PX
|
|
15
|
+
: scroller.scrollHeight - scroller.scrollTop - scroller.clientHeight <= END_SLACK_PX;
|
|
16
|
+
const endOf = (scroller: HTMLElement) => (isReversed(scroller) ? 0 : scroller.scrollHeight - scroller.clientHeight);
|
|
8
17
|
const isInset = (rider: HTMLElement) => rider.dataset.akanKeyboardRide === "inset";
|
|
9
18
|
|
|
10
19
|
/**
|
|
@@ -16,15 +25,18 @@ const isInset = (rider: HTMLElement) => rider.dataset.akanKeyboardRide === "inse
|
|
|
16
25
|
* up, since the shorter box would clip a rider still on its way, and keys going down give the taller box at once while
|
|
17
26
|
* the riders start from where they were drawn. When the focused field sits in `data-akan-keyboard-overlay`, the page
|
|
18
27
|
* keeps the whole screen, as a native chat screen does, so what lies under the glass keys stays drawn: the riders go
|
|
19
|
-
* where the shorter box would put them and stay there
|
|
20
|
-
*
|
|
28
|
+
* where the shorter box would put them and stay there. An `inset` rider (a list's content) is not carried: it takes the
|
|
29
|
+
* rise as bottom padding at once, so the list still scrolls to its top, and a list resting at its end scrolls the rise
|
|
30
|
+
* with the keys, and back down with them. While it does, its scroller carries `data-akan-keyboard-glide`: a list's own
|
|
31
|
+
* keep-at-end logic yields to it.
|
|
21
32
|
*/
|
|
22
33
|
export class KeyboardRide {
|
|
23
34
|
static #committed = 0;
|
|
24
35
|
static #target = 0;
|
|
25
36
|
static #isOverlay = false;
|
|
26
37
|
static #timer: ReturnType<typeof setTimeout> | null = null;
|
|
27
|
-
static #insets = new Map<HTMLElement, { paddingBottom: string; rise: number }>();
|
|
38
|
+
static #insets = new Map<HTMLElement, { paddingBottom: string; base: string; rise: number }>();
|
|
39
|
+
static #glides = new Map<HTMLElement, number>();
|
|
28
40
|
|
|
29
41
|
static move(height: number, durationMs: number) {
|
|
30
42
|
if (height === KeyboardRide.#target) return;
|
|
@@ -44,23 +56,34 @@ export class KeyboardRide {
|
|
|
44
56
|
if (KeyboardRide.#timer) clearTimeout(KeyboardRide.#timer);
|
|
45
57
|
KeyboardRide.#timer = null;
|
|
46
58
|
|
|
47
|
-
const
|
|
59
|
+
const shown = [...document.querySelectorAll<HTMLElement>(RIDE_SELECTOR)].filter(
|
|
48
60
|
(element) => element.getClientRects().length > 0,
|
|
49
61
|
);
|
|
50
62
|
|
|
63
|
+
const lists = isOverlay ? shown.filter(isInset) : [];
|
|
64
|
+
const riders = shown.filter((rider) => !lists.includes(rider));
|
|
65
|
+
KeyboardRide.#stopGlides();
|
|
66
|
+
const listEnds = lists.map((list) => KeyboardRide.#scrollersAtEnd([list]).at(0) ?? null);
|
|
67
|
+
|
|
51
68
|
const drawn = riders.map((rider) => bottomOf(rider) - (KeyboardRide.#insets.get(rider)?.rise ?? 0));
|
|
52
69
|
for (const rider of riders) {
|
|
53
70
|
rider.style.transition = "none";
|
|
54
71
|
rider.style.transform = "";
|
|
55
72
|
}
|
|
56
|
-
KeyboardRide.#releaseInsets();
|
|
57
|
-
const scrollers = KeyboardRide.#scrollersAtEnd(
|
|
73
|
+
KeyboardRide.#releaseInsets(lists);
|
|
74
|
+
const scrollers = KeyboardRide.#scrollersAtEnd(shown);
|
|
58
75
|
const previous = KeyboardRide.#committed;
|
|
59
76
|
const isHeld = !isOverlay && height > previous;
|
|
60
77
|
KeyboardRide.#commit(height, scrollers);
|
|
61
78
|
const settled = riders.map(bottomOf);
|
|
79
|
+
const listsSettled = lists.map(bottomOf);
|
|
62
80
|
if (isHeld || isOverlay) KeyboardRide.#commit(isOverlay ? 0 : previous, scrollers);
|
|
63
81
|
const laid = isHeld || isOverlay ? riders.map(bottomOf) : settled;
|
|
82
|
+
lists.forEach((list, idx) => {
|
|
83
|
+
const scroller = listEnds[idx] ?? null;
|
|
84
|
+
if (height > 0) KeyboardRide.#raiseList(list, bottomOf(list) - (listsSettled[idx] ?? 0), scroller, durationMs);
|
|
85
|
+
else KeyboardRide.#lowerList(list, scroller, durationMs);
|
|
86
|
+
});
|
|
64
87
|
riders.forEach((rider, idx) => {
|
|
65
88
|
rider.style.transform = `translateY(${drawn[idx] - laid[idx]}px)`;
|
|
66
89
|
});
|
|
@@ -73,9 +96,7 @@ export class KeyboardRide {
|
|
|
73
96
|
KeyboardRide.#timer = setTimeout(() => {
|
|
74
97
|
KeyboardRide.#timer = null;
|
|
75
98
|
if (isHeld) KeyboardRide.#commit(height, KeyboardRide.#scrollersAtEnd(riders));
|
|
76
|
-
const
|
|
77
|
-
if (isKept) KeyboardRide.#holdInsets(riders, settled, laid);
|
|
78
|
-
const settling = riders.filter((rider) => !isKept || isInset(rider));
|
|
99
|
+
const settling = isOverlay && height > 0 ? [] : riders;
|
|
79
100
|
for (const rider of settling) {
|
|
80
101
|
rider.style.transition = "none";
|
|
81
102
|
rider.style.transform = "";
|
|
@@ -90,34 +111,105 @@ export class KeyboardRide {
|
|
|
90
111
|
root.style.setProperty("--akan-keyboard-cover", `${height}px`);
|
|
91
112
|
root.toggleAttribute("data-akan-keyboard-layout", height > 0);
|
|
92
113
|
KeyboardRide.#committed = height;
|
|
93
|
-
for (const scroller of scrollers) scroller.scrollTop = scroller
|
|
114
|
+
for (const scroller of scrollers) scroller.scrollTop = endOf(scroller);
|
|
94
115
|
}
|
|
95
116
|
|
|
96
|
-
static #
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
117
|
+
static #raiseList(list: HTMLElement, rise: number, scroller: HTMLElement | null, durationMs: number) {
|
|
118
|
+
const held = KeyboardRide.#insets.get(list);
|
|
119
|
+
const base = held?.base ?? getComputedStyle(list).paddingBottom;
|
|
120
|
+
if (rise <= 0) return;
|
|
121
|
+
KeyboardRide.#insets.set(list, { paddingBottom: held?.paddingBottom ?? list.style.paddingBottom, base, rise });
|
|
122
|
+
list.style.paddingBottom = `calc(${base} + ${rise}px)`;
|
|
123
|
+
const outer = KeyboardRide.#scrollerOf(list);
|
|
124
|
+
|
|
125
|
+
if (outer && isReversed(outer)) outer.scrollTop -= rise - (held?.rise ?? 0);
|
|
126
|
+
if (scroller) KeyboardRide.#glide(scroller, endOf(scroller), durationMs);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
static #lowerList(list: HTMLElement, scroller: HTMLElement | null, durationMs: number) {
|
|
130
|
+
const held = KeyboardRide.#insets.get(list);
|
|
131
|
+
if (!held) return;
|
|
132
|
+
const outer = KeyboardRide.#scrollerOf(list);
|
|
133
|
+
const release = () => {
|
|
134
|
+
list.style.paddingBottom = held.paddingBottom;
|
|
135
|
+
KeyboardRide.#insets.delete(list);
|
|
136
|
+
if (outer && isReversed(outer)) outer.scrollTop += held.rise;
|
|
137
|
+
};
|
|
138
|
+
if (!scroller) return release();
|
|
139
|
+
const to = isReversed(scroller) ? -held.rise : Math.max(0, scroller.scrollTop - held.rise);
|
|
140
|
+
KeyboardRide.#glide(scroller, to, durationMs, release);
|
|
105
141
|
}
|
|
106
142
|
|
|
107
|
-
static #releaseInsets() {
|
|
108
|
-
for (const [rider, { paddingBottom }] of KeyboardRide.#insets)
|
|
109
|
-
|
|
143
|
+
static #releaseInsets(kept: HTMLElement[]) {
|
|
144
|
+
for (const [rider, { paddingBottom }] of KeyboardRide.#insets) {
|
|
145
|
+
if (kept.includes(rider)) continue;
|
|
146
|
+
rider.style.paddingBottom = paddingBottom;
|
|
147
|
+
KeyboardRide.#insets.delete(rider);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
static #glide(scroller: HTMLElement, to: number, durationMs: number, done?: () => void) {
|
|
152
|
+
const from = scroller.scrollTop;
|
|
153
|
+
scroller.setAttribute(GLIDE_ATTRIBUTE, "");
|
|
154
|
+
const ease = KeyboardRide.#easeOf(nativeKeyboardEasing());
|
|
155
|
+
const startedAt = performance.now();
|
|
156
|
+
const step = (now: number) => {
|
|
157
|
+
const progress = durationMs > 0 ? Math.min(1, (now - startedAt) / durationMs) : 1;
|
|
158
|
+
scroller.scrollTop = from + (to - from) * ease(progress);
|
|
159
|
+
if (progress < 1) {
|
|
160
|
+
KeyboardRide.#glides.set(scroller, requestAnimationFrame(step));
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
KeyboardRide.#glides.delete(scroller);
|
|
164
|
+
done?.();
|
|
165
|
+
scroller.removeAttribute(GLIDE_ATTRIBUTE);
|
|
166
|
+
};
|
|
167
|
+
KeyboardRide.#glides.set(scroller, requestAnimationFrame(step));
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
static #stopGlides() {
|
|
171
|
+
for (const [scroller, frame] of KeyboardRide.#glides) {
|
|
172
|
+
cancelAnimationFrame(frame);
|
|
173
|
+
scroller.removeAttribute(GLIDE_ATTRIBUTE);
|
|
174
|
+
}
|
|
175
|
+
KeyboardRide.#glides.clear();
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
static #easeOf(easing: string) {
|
|
179
|
+
const parsed = easing
|
|
180
|
+
.replace(/^cubic-bezier\(|\)$/g, "")
|
|
181
|
+
.split(",")
|
|
182
|
+
.map(Number);
|
|
183
|
+
const [x1, y1, x2, y2] = parsed.length === 4 && parsed.every(Number.isFinite) ? parsed : [0.25, 0.1, 0.25, 1];
|
|
184
|
+
const curve = (a: number, b: number, t: number) => 3 * a * (1 - t) ** 2 * t + 3 * b * (1 - t) * t ** 2 + t ** 3;
|
|
185
|
+
return (progress: number) => {
|
|
186
|
+
let low = 0;
|
|
187
|
+
let high = 1;
|
|
188
|
+
let t = progress;
|
|
189
|
+
for (let step = 0; step < 24; step++) {
|
|
190
|
+
const x = curve(x1, x2, t);
|
|
191
|
+
if (Math.abs(x - progress) < 1e-4) break;
|
|
192
|
+
if (x < progress) low = t;
|
|
193
|
+
else high = t;
|
|
194
|
+
t = (low + high) / 2;
|
|
195
|
+
}
|
|
196
|
+
return curve(y1, y2, t);
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
static #scrollerOf(rider: HTMLElement) {
|
|
201
|
+
for (let element = rider.parentElement; element; element = element.parentElement) {
|
|
202
|
+
const { overflowY } = getComputedStyle(element);
|
|
203
|
+
if (overflowY === "auto" || overflowY === "scroll") return element;
|
|
204
|
+
}
|
|
205
|
+
return null;
|
|
110
206
|
}
|
|
111
207
|
|
|
112
208
|
static #scrollersAtEnd(riders: HTMLElement[]) {
|
|
113
209
|
const scrollers = new Set<HTMLElement>();
|
|
114
210
|
for (const rider of riders) {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
if (overflowY !== "auto" && overflowY !== "scroll") continue;
|
|
118
|
-
if (element.scrollHeight - element.scrollTop - element.clientHeight <= END_SLACK_PX) scrollers.add(element);
|
|
119
|
-
break;
|
|
120
|
-
}
|
|
211
|
+
const scroller = KeyboardRide.#scrollerOf(rider);
|
|
212
|
+
if (scroller && isAtEnd(scroller)) scrollers.add(scroller);
|
|
121
213
|
}
|
|
122
214
|
return [...scrollers];
|
|
123
215
|
}
|
package/package.json
CHANGED
package/server/selfExec.ts
CHANGED
|
@@ -27,7 +27,19 @@ export class SelfExec {
|
|
|
27
27
|
return beBun === undefined ? env : { ...env, BUN_BE_BUN: beBun };
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
static readonly #codeFlags = ["-e", "--eval", "-p", "--print"];
|
|
31
|
+
|
|
32
|
+
static runtimeFlags(execArgv: string[] = process.execArgv): string[] {
|
|
33
|
+
const flags: string[] = [];
|
|
34
|
+
for (let idx = 0; idx < execArgv.length; idx++) {
|
|
35
|
+
const flag = execArgv[idx] ?? "";
|
|
36
|
+
if (SelfExec.#codeFlags.includes(flag)) idx++;
|
|
37
|
+
else if (!SelfExec.#codeFlags.some((codeFlag) => flag.startsWith(`${codeFlag}=`))) flags.push(flag);
|
|
38
|
+
}
|
|
39
|
+
return flags;
|
|
40
|
+
}
|
|
41
|
+
|
|
30
42
|
static command(script: string, ...args: string[]): string[] {
|
|
31
|
-
return [process.execPath, ...
|
|
43
|
+
return [process.execPath, ...SelfExec.runtimeFlags(), script, ...args];
|
|
32
44
|
}
|
|
33
45
|
}
|
|
@@ -7,8 +7,10 @@
|
|
|
7
7
|
* up, since the shorter box would clip a rider still on its way, and keys going down give the taller box at once while
|
|
8
8
|
* the riders start from where they were drawn. When the focused field sits in `data-akan-keyboard-overlay`, the page
|
|
9
9
|
* keeps the whole screen, as a native chat screen does, so what lies under the glass keys stays drawn: the riders go
|
|
10
|
-
* where the shorter box would put them and stay there
|
|
11
|
-
*
|
|
10
|
+
* where the shorter box would put them and stay there. An `inset` rider (a list's content) is not carried: it takes the
|
|
11
|
+
* rise as bottom padding at once, so the list still scrolls to its top, and a list resting at its end scrolls the rise
|
|
12
|
+
* with the keys, and back down with them. While it does, its scroller carries `data-akan-keyboard-glide`: a list's own
|
|
13
|
+
* keep-at-end logic yields to it.
|
|
12
14
|
*/
|
|
13
15
|
export declare class KeyboardRide {
|
|
14
16
|
#private;
|
|
@@ -4,5 +4,6 @@ export declare class SelfExec {
|
|
|
4
4
|
/** A desktop app's carried server: only its shell starts the app executable as Bun. */
|
|
5
5
|
static get carried(): boolean;
|
|
6
6
|
static env(env?: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
|
|
7
|
+
static runtimeFlags(execArgv?: string[]): string[];
|
|
7
8
|
static command(script: string, ...args: string[]): string[];
|
|
8
9
|
}
|