@flighthq/keyboard 0.5.0-next.1944.cd6b6e7 → 0.5.1-edge.638.d4dbd4e
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/README.md +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/keyboard.d.ts +12 -23
- package/dist/keyboard.d.ts.map +1 -1
- package/dist/keyboard.js +45 -250
- package/dist/keyboard.js.map +1 -1
- package/package.json +4 -3
- package/src/keyboard.test.ts +255 -891
package/README.md
CHANGED
|
@@ -13,5 +13,5 @@ Import the supported application-facing API from `@flighthq/keyboard`. The `@fli
|
|
|
13
13
|
This package is part of the locked-version Flight SDK graph. Applications may instead install and import `@flighthq/sdk` when package-level tree shaking is sufficient.
|
|
14
14
|
|
|
15
15
|
- [Flight project](https://github.com/flighthq/flight)
|
|
16
|
-
- [Source for @flighthq/keyboard@0.5.
|
|
17
|
-
- [License](https://github.com/flighthq/flight/blob/
|
|
16
|
+
- [Source for @flighthq/keyboard@0.5.1-edge.638.d4dbd4e](https://github.com/flighthq/flight/tree/d4dbd4e347dc8be10b180c85a766ab50333dcb51/packages/keyboard)
|
|
17
|
+
- [License](https://github.com/flighthq/flight/blob/d4dbd4e347dc8be10b180c85a766ab50333dcb51/LICENSE.md)
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { attachSoftKeyboard, createSoftKeyboard, detachSoftKeyboard, disposeSoftKeyboard, getSoftKeyboardHeight, getSoftKeyboardInfo, hideSoftKeyboard, isSoftKeyboardVisible, setSoftKeyboardAccessoryBarVisible, setSoftKeyboardResizeMode, setSoftKeyboardScrollAssistEnabled, setSoftKeyboardStyle, showSoftKeyboard, } from './contract';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,qBAAqB,EACrB,mBAAmB,EACnB,gBAAgB,EAChB,qBAAqB,EACrB,kCAAkC,EAClC,yBAAyB,EACzB,kCAAkC,EAClC,oBAAoB,EACpB,gBAAgB,GACjB,MAAM,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { attachSoftKeyboard, createSoftKeyboard, detachSoftKeyboard, disposeSoftKeyboard, getSoftKeyboardHeight, getSoftKeyboardInfo, hideSoftKeyboard, isSoftKeyboardVisible, setSoftKeyboardAccessoryBarVisible, setSoftKeyboardResizeMode, setSoftKeyboardScrollAssistEnabled, setSoftKeyboardStyle, showSoftKeyboard, } from './contract';
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,qBAAqB,EACrB,mBAAmB,EACnB,gBAAgB,EAChB,qBAAqB,EACrB,kCAAkC,EAClC,yBAAyB,EACzB,kCAAkC,EAClC,oBAAoB,EACpB,gBAAgB,GACjB,MAAM,YAAY,CAAC"}
|
package/dist/keyboard.d.ts
CHANGED
|
@@ -1,26 +1,15 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare function attachSoftKeyboard(keyboard: SoftKeyboard):
|
|
3
|
-
export declare function createSoftKeyboard(): SoftKeyboard;
|
|
4
|
-
export declare function createSoftKeyboardInfo(): SoftKeyboardInfo;
|
|
5
|
-
export declare function createSoftKeyboardTransition(): SoftKeyboardTransition;
|
|
6
|
-
export declare function createWebSoftKeyboardBackend(): SoftKeyboardBackend;
|
|
1
|
+
import type { Entity, HasSoftKeyboardAccessoryBar, HasSoftKeyboardChange, HasSoftKeyboardInfo, HasSoftKeyboardResizeModeWrite, HasSoftKeyboardScrollAssist, HasSoftKeyboardStyle, HasSoftKeyboardVisibility, SoftKeyboard, SoftKeyboardAttachResult, SoftKeyboardInfo, SoftKeyboardResizeMode, SoftKeyboardSetterResult, SoftKeyboardStyleKind, SoftKeyboardVisibilityResult } from '@flighthq/types/contract';
|
|
2
|
+
export declare function attachSoftKeyboard(host: HasSoftKeyboardChange & HasSoftKeyboardInfo, keyboard: SoftKeyboard): Promise<SoftKeyboardAttachResult>;
|
|
3
|
+
export declare function createSoftKeyboard(): SoftKeyboard & Entity;
|
|
7
4
|
export declare function detachSoftKeyboard(keyboard: SoftKeyboard): void;
|
|
8
5
|
export declare function disposeSoftKeyboard(keyboard: SoftKeyboard): void;
|
|
9
|
-
export declare function
|
|
10
|
-
export declare function
|
|
11
|
-
export declare function
|
|
12
|
-
export declare function
|
|
13
|
-
export declare function
|
|
14
|
-
export declare function
|
|
15
|
-
export declare function
|
|
16
|
-
export declare function
|
|
17
|
-
export declare function
|
|
18
|
-
export declare function observeSoftKeyboardHostResult(operation: string, succeeded: boolean): void;
|
|
19
|
-
export declare function resetSoftKeyboardBackendForTest(): void;
|
|
20
|
-
export declare function setSoftKeyboardAccessoryBarVisible(visible: boolean): void;
|
|
21
|
-
export declare function setSoftKeyboardBackend(backend: SoftKeyboardBackend | null): void;
|
|
22
|
-
export declare function setSoftKeyboardResizeMode(mode: SoftKeyboardResizeMode): void;
|
|
23
|
-
export declare function setSoftKeyboardScrollAssistEnabled(enabled: boolean): void;
|
|
24
|
-
export declare function setSoftKeyboardStyle(style: SoftKeyboardStyleKind): void;
|
|
25
|
-
export declare function showSoftKeyboard(): void;
|
|
6
|
+
export declare function getSoftKeyboardHeight(host: HasSoftKeyboardInfo): number;
|
|
7
|
+
export declare function getSoftKeyboardInfo(host: HasSoftKeyboardInfo, out: SoftKeyboardInfo): SoftKeyboardInfo;
|
|
8
|
+
export declare function hideSoftKeyboard(host: HasSoftKeyboardVisibility): Promise<SoftKeyboardVisibilityResult>;
|
|
9
|
+
export declare function isSoftKeyboardVisible(host: HasSoftKeyboardInfo): boolean;
|
|
10
|
+
export declare function setSoftKeyboardAccessoryBarVisible(host: HasSoftKeyboardAccessoryBar, visible: boolean): Promise<SoftKeyboardSetterResult>;
|
|
11
|
+
export declare function setSoftKeyboardResizeMode(host: HasSoftKeyboardResizeModeWrite, mode: SoftKeyboardResizeMode): Promise<SoftKeyboardSetterResult>;
|
|
12
|
+
export declare function setSoftKeyboardScrollAssistEnabled(host: HasSoftKeyboardScrollAssist, enabled: boolean): Promise<SoftKeyboardSetterResult>;
|
|
13
|
+
export declare function setSoftKeyboardStyle(host: HasSoftKeyboardStyle, style: SoftKeyboardStyleKind): Promise<SoftKeyboardSetterResult>;
|
|
14
|
+
export declare function showSoftKeyboard(host: HasSoftKeyboardVisibility): Promise<SoftKeyboardVisibilityResult>;
|
|
26
15
|
//# sourceMappingURL=keyboard.d.ts.map
|
package/dist/keyboard.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keyboard.d.ts","sourceRoot":"","sources":["../src/keyboard.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"keyboard.d.ts","sourceRoot":"","sources":["../src/keyboard.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,MAAM,EACN,2BAA2B,EAC3B,qBAAqB,EACrB,mBAAmB,EACnB,8BAA8B,EAC9B,2BAA2B,EAC3B,oBAAoB,EACpB,yBAAyB,EACzB,YAAY,EACZ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AE,yBAAyB,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAEvG"}
|
package/dist/keyboard.js
CHANGED
|
@@ -1,131 +1,40 @@
|
|
|
1
|
+
import { createEntity } from '@flighthq/entity/contract';
|
|
1
2
|
import { createSignal, emitSignal } from '@flighthq/signals/contract';
|
|
2
|
-
|
|
3
|
-
// Begins delivering on-screen keyboard changes to `keyboard`'s signals by subscribing to the active
|
|
4
|
-
// backend. On each change it reads fresh info, emits will/did signal pairs (with onShow/onHide/onResize
|
|
5
|
-
// aliases firing alongside the did-phase edge), and tracks visibility-edge transitions for
|
|
6
|
-
// onWillShow/onWillHide and onDidShow/onDidHide pairs. Idempotent: a prior subscription is torn
|
|
7
|
-
// down first. Pair with detachSoftKeyboard/disposeSoftKeyboard.
|
|
8
|
-
export function attachSoftKeyboard(keyboard) {
|
|
3
|
+
export async function attachSoftKeyboard(host, keyboard) {
|
|
9
4
|
detachSoftKeyboard(keyboard);
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
else if (!nowVisible && prevVisible) {
|
|
22
|
-
emitSignal(keyboard.onWillHide, transition);
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
emitSignal(keyboard.onWillResize, transition);
|
|
26
|
-
}
|
|
5
|
+
const change = host.input.softKeyboardChange;
|
|
6
|
+
const info = host.input.softKeyboardInfo;
|
|
7
|
+
let prevHeight = info.getInfo(_scratch).height;
|
|
8
|
+
const subscription = await change.subscribe(() => {
|
|
9
|
+
const nowInfo = info.getInfo(_scratch);
|
|
10
|
+
const nowHeight = nowInfo.height;
|
|
11
|
+
const wasVisible = prevHeight > 0;
|
|
12
|
+
const nowVisible = nowHeight > 0;
|
|
13
|
+
if (nowVisible && !wasVisible) {
|
|
14
|
+
prevHeight = nowHeight;
|
|
15
|
+
emitSignal(keyboard.onShow, nowHeight);
|
|
27
16
|
}
|
|
28
|
-
else {
|
|
29
|
-
|
|
30
|
-
emitSignal(keyboard.
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
emitSignal(keyboard.onDidShow, info.height);
|
|
36
|
-
emitSignal(keyboard.onShow, info.height);
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
emitSignal(keyboard.onDidHide);
|
|
40
|
-
emitSignal(keyboard.onHide);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
17
|
+
else if (!nowVisible && wasVisible) {
|
|
18
|
+
prevHeight = 0;
|
|
19
|
+
emitSignal(keyboard.onHide);
|
|
20
|
+
}
|
|
21
|
+
else if (nowVisible && nowHeight !== prevHeight) {
|
|
22
|
+
prevHeight = nowHeight;
|
|
23
|
+
emitSignal(keyboard.onResize, nowHeight);
|
|
43
24
|
}
|
|
44
25
|
});
|
|
45
|
-
|
|
26
|
+
if (subscription.result !== 'ok')
|
|
27
|
+
return subscription.result;
|
|
28
|
+
_subscriptions.set(keyboard, subscription.unsubscribe);
|
|
29
|
+
return 'ok';
|
|
46
30
|
}
|
|
47
|
-
// Allocates a SoftKeyboard event entity with inert signals; call attachSoftKeyboard to start delivery.
|
|
48
31
|
export function createSoftKeyboard() {
|
|
49
|
-
return {
|
|
32
|
+
return createEntity({
|
|
50
33
|
onShow: createSignal(),
|
|
51
34
|
onHide: createSignal(),
|
|
52
35
|
onResize: createSignal(),
|
|
53
|
-
|
|
54
|
-
onWillHide: createSignal(),
|
|
55
|
-
onWillResize: createSignal(),
|
|
56
|
-
onDidShow: createSignal(),
|
|
57
|
-
onDidHide: createSignal(),
|
|
58
|
-
onDidResize: createSignal(),
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
// Allocates a zeroed SoftKeyboardInfo, suitable as the `out` for getSoftKeyboardInfo.
|
|
62
|
-
export function createSoftKeyboardInfo() {
|
|
63
|
-
return { visible: false, height: 0, x: 0, y: 0, width: 0 };
|
|
64
|
-
}
|
|
65
|
-
// Allocates a zeroed SoftKeyboardTransition with durationSeconds 0 and height 0.
|
|
66
|
-
export function createSoftKeyboardTransition() {
|
|
67
|
-
return { durationSeconds: 0, height: 0 };
|
|
68
|
-
}
|
|
69
|
-
// Builds the default web backend over window.visualViewport, inferring keyboard height from the
|
|
70
|
-
// viewport shrink relative to window.innerHeight. Also uses the Chromium VirtualKeyboard API
|
|
71
|
-
// (navigator.virtualKeyboard) when available: geometry comes from geometrychange, and
|
|
72
|
-
// showSoftKeyboard/hideSoftKeyboard become real operations instead of no-ops.
|
|
73
|
-
// Degrades to height 0 and a no-op subscription where the API is absent. All did-phase only
|
|
74
|
-
// (durationSeconds: 0); native backends may emit will-phase with timing.
|
|
75
|
-
export function createWebSoftKeyboardBackend() {
|
|
76
|
-
return {
|
|
77
|
-
getInfo(out) {
|
|
78
|
-
const geo = getWebKeyboardGeometry();
|
|
79
|
-
out.height = geo.height;
|
|
80
|
-
out.visible = geo.height > 0;
|
|
81
|
-
out.x = geo.x;
|
|
82
|
-
out.y = geo.y;
|
|
83
|
-
out.width = geo.width;
|
|
84
|
-
return out;
|
|
85
|
-
},
|
|
86
|
-
subscribe(listener) {
|
|
87
|
-
if (typeof window === 'undefined')
|
|
88
|
-
return () => { };
|
|
89
|
-
// transition.height stays 0 on web: this backend fires the 'did' phase only, where consumers
|
|
90
|
-
// read the settled geometry from getInfo(); the will-phase target height that transition.height
|
|
91
|
-
// is meant to carry is animation metadata the web viewport APIs never expose. Native hosts that
|
|
92
|
-
// emit a real 'will' phase must populate transition.height with the incoming keyboard height.
|
|
93
|
-
const transition = { durationSeconds: 0, height: 0 };
|
|
94
|
-
const fire = () => listener('did', transition);
|
|
95
|
-
// Use Chromium VirtualKeyboard API when available for geometry.
|
|
96
|
-
const virtualKeyboard = getVirtualKeyboard();
|
|
97
|
-
if (virtualKeyboard !== null) {
|
|
98
|
-
virtualKeyboard.addEventListener('geometrychange', fire);
|
|
99
|
-
return () => virtualKeyboard.removeEventListener('geometrychange', fire);
|
|
100
|
-
}
|
|
101
|
-
// Fall back to visualViewport resize/scroll.
|
|
102
|
-
const viewport = window.visualViewport;
|
|
103
|
-
if (viewport === undefined || viewport === null)
|
|
104
|
-
return () => { };
|
|
105
|
-
viewport.addEventListener('resize', fire);
|
|
106
|
-
viewport.addEventListener('scroll', fire);
|
|
107
|
-
return () => {
|
|
108
|
-
viewport.removeEventListener('resize', fire);
|
|
109
|
-
viewport.removeEventListener('scroll', fire);
|
|
110
|
-
};
|
|
111
|
-
},
|
|
112
|
-
show() {
|
|
113
|
-
const vk = getVirtualKeyboard();
|
|
114
|
-
if (vk !== null) {
|
|
115
|
-
vk.show();
|
|
116
|
-
}
|
|
117
|
-
// No-op on web without VirtualKeyboard API; the soft keyboard only opens when a field is focused.
|
|
118
|
-
},
|
|
119
|
-
hide() {
|
|
120
|
-
const vk = getVirtualKeyboard();
|
|
121
|
-
if (vk !== null) {
|
|
122
|
-
vk.hide();
|
|
123
|
-
}
|
|
124
|
-
// No-op on web without VirtualKeyboard API.
|
|
125
|
-
},
|
|
126
|
-
};
|
|
36
|
+
});
|
|
127
37
|
}
|
|
128
|
-
// Stops delivery to `keyboard` and forgets its subscription. Safe to call when not attached.
|
|
129
38
|
export function detachSoftKeyboard(keyboard) {
|
|
130
39
|
const unsubscribe = _subscriptions.get(keyboard);
|
|
131
40
|
if (unsubscribe !== undefined) {
|
|
@@ -133,150 +42,36 @@ export function detachSoftKeyboard(keyboard) {
|
|
|
133
42
|
_subscriptions.delete(keyboard);
|
|
134
43
|
}
|
|
135
44
|
}
|
|
136
|
-
// Releases `keyboard` for garbage collection by detaching its backend subscription. The signals
|
|
137
|
-
// remain plain GC-managed memory afterward.
|
|
138
45
|
export function disposeSoftKeyboard(keyboard) {
|
|
139
46
|
detachSoftKeyboard(keyboard);
|
|
140
47
|
}
|
|
141
|
-
export function
|
|
142
|
-
|
|
143
|
-
return { conflict: _hostConflict, layer: 'custom', operation: null, viability: 'unobserved' };
|
|
144
|
-
}
|
|
145
|
-
if (_host !== null) {
|
|
146
|
-
return {
|
|
147
|
-
conflict: _hostConflict,
|
|
148
|
-
layer: 'host',
|
|
149
|
-
operation: _hostObservation !== null ? _hostObservation.operation : null,
|
|
150
|
-
viability: _hostObservation !== null ? _hostObservation.viability : 'unobserved',
|
|
151
|
-
};
|
|
152
|
-
}
|
|
153
|
-
return { conflict: false, layer: 'host-not-enabled', operation: null, viability: 'unobserved' };
|
|
154
|
-
}
|
|
155
|
-
// The active soft keyboard backend. Precedence: custom > host > sentinel.
|
|
156
|
-
export function getSoftKeyboardBackend() {
|
|
157
|
-
return _custom ?? _host ?? _sentinel;
|
|
48
|
+
export function getSoftKeyboardHeight(host) {
|
|
49
|
+
return host.input.softKeyboardInfo.getInfo(_scratch).height;
|
|
158
50
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
return getSoftKeyboardBackend().getInfo(_scratch).height;
|
|
51
|
+
export function getSoftKeyboardInfo(host, out) {
|
|
52
|
+
return host.input.softKeyboardInfo.getInfo(out);
|
|
162
53
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
return getSoftKeyboardBackend().getInfo(out);
|
|
54
|
+
export function hideSoftKeyboard(host) {
|
|
55
|
+
return host.input.softKeyboardVisibility.hide();
|
|
166
56
|
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
export function getSoftKeyboardResizeMode() {
|
|
170
|
-
const backend = getSoftKeyboardBackend();
|
|
171
|
-
return backend.getResizeMode?.() ?? SoftKeyboardResizeNoneKind;
|
|
57
|
+
export function isSoftKeyboardVisible(host) {
|
|
58
|
+
return host.input.softKeyboardInfo.getInfo(_scratch).visible;
|
|
172
59
|
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
export function hideSoftKeyboard() {
|
|
176
|
-
getSoftKeyboardBackend().hide();
|
|
177
|
-
}
|
|
178
|
-
export function installSoftKeyboardHostBackend(backend) {
|
|
179
|
-
if (_host !== null) {
|
|
180
|
-
if (_host !== backend)
|
|
181
|
-
_hostConflict = true;
|
|
182
|
-
return;
|
|
183
|
-
}
|
|
184
|
-
_host = backend;
|
|
60
|
+
export function setSoftKeyboardAccessoryBarVisible(host, visible) {
|
|
61
|
+
return host.input.softKeyboardAccessoryBar.setAccessoryBarVisible(visible);
|
|
185
62
|
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
export function isSoftKeyboardAccessoryBarVisible() {
|
|
189
|
-
return getSoftKeyboardBackend().getAccessoryBarVisible?.() ?? false;
|
|
63
|
+
export function setSoftKeyboardResizeMode(host, mode) {
|
|
64
|
+
return host.input.softKeyboardResizeModeWrite.setResizeMode(mode);
|
|
190
65
|
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
return getSoftKeyboardBackend().getScrollAssistEnabled?.() ?? false;
|
|
66
|
+
export function setSoftKeyboardScrollAssistEnabled(host, enabled) {
|
|
67
|
+
return host.input.softKeyboardScrollAssist.setScrollAssistEnabled(enabled);
|
|
194
68
|
}
|
|
195
|
-
export function
|
|
196
|
-
|
|
197
|
-
operation,
|
|
198
|
-
viability: succeeded ? 'available' : 'runtime-api-unavailable',
|
|
199
|
-
};
|
|
69
|
+
export function setSoftKeyboardStyle(host, style) {
|
|
70
|
+
return host.input.softKeyboardStyle.setStyle(style);
|
|
200
71
|
}
|
|
201
|
-
export function
|
|
202
|
-
|
|
203
|
-
_host = null;
|
|
204
|
-
_hostConflict = false;
|
|
205
|
-
_hostObservation = null;
|
|
72
|
+
export function showSoftKeyboard(host) {
|
|
73
|
+
return host.input.softKeyboardVisibility.show();
|
|
206
74
|
}
|
|
207
|
-
|
|
208
|
-
// No-op when the backend does not support this.
|
|
209
|
-
export function setSoftKeyboardAccessoryBarVisible(visible) {
|
|
210
|
-
getSoftKeyboardBackend().setAccessoryBarVisible?.(visible);
|
|
211
|
-
}
|
|
212
|
-
// Installs a custom soft keyboard backend; takes precedence over the host backend.
|
|
213
|
-
export function setSoftKeyboardBackend(backend) {
|
|
214
|
-
_custom = backend;
|
|
215
|
-
}
|
|
216
|
-
// Controls keyboard resize behavior — how the app viewport reacts when the keyboard appears.
|
|
217
|
-
// No-op when the backend does not support resize-mode control.
|
|
218
|
-
export function setSoftKeyboardResizeMode(mode) {
|
|
219
|
-
getSoftKeyboardBackend().setResizeMode?.(mode);
|
|
220
|
-
}
|
|
221
|
-
// Controls whether the keyboard scroll-assist feature is enabled (scrolls the focused field into
|
|
222
|
-
// view when the keyboard appears). No-op when the backend does not support this.
|
|
223
|
-
export function setSoftKeyboardScrollAssistEnabled(enabled) {
|
|
224
|
-
getSoftKeyboardBackend().setScrollAssistEnabled?.(enabled);
|
|
225
|
-
}
|
|
226
|
-
// Sets the visual style / appearance of the on-screen keyboard (iOS light/dark keyboard appearance).
|
|
227
|
-
// No-op on web and on backends that do not support style control.
|
|
228
|
-
export function setSoftKeyboardStyle(style) {
|
|
229
|
-
getSoftKeyboardBackend().setStyle?.(style);
|
|
230
|
-
}
|
|
231
|
-
// Requests that the host present the on-screen keyboard. A no-op on web unless the
|
|
232
|
-
// navigator.virtualKeyboard API is available (Chromium with virtualKeyboard policy).
|
|
233
|
-
export function showSoftKeyboard() {
|
|
234
|
-
getSoftKeyboardBackend().show();
|
|
235
|
-
}
|
|
236
|
-
let _custom = null;
|
|
237
|
-
let _host = null;
|
|
238
|
-
let _hostConflict = false;
|
|
239
|
-
let _hostObservation = null;
|
|
240
|
-
const _sentinel = {
|
|
241
|
-
getInfo(out) {
|
|
242
|
-
out.visible = false;
|
|
243
|
-
out.height = 0;
|
|
244
|
-
out.x = 0;
|
|
245
|
-
out.y = 0;
|
|
246
|
-
out.width = 0;
|
|
247
|
-
return out;
|
|
248
|
-
},
|
|
249
|
-
subscribe() {
|
|
250
|
-
return () => { };
|
|
251
|
-
},
|
|
252
|
-
show() { },
|
|
253
|
-
hide() { },
|
|
254
|
-
};
|
|
255
|
-
const _scratch = createSoftKeyboardInfo();
|
|
75
|
+
const _scratch = { visible: false, height: 0, x: 0, y: 0, width: 0 };
|
|
256
76
|
const _subscriptions = new WeakMap();
|
|
257
|
-
function getVirtualKeyboard() {
|
|
258
|
-
if (typeof navigator === 'undefined')
|
|
259
|
-
return null;
|
|
260
|
-
const nav = navigator;
|
|
261
|
-
return nav.virtualKeyboard ?? null;
|
|
262
|
-
}
|
|
263
|
-
function getWebKeyboardGeometry() {
|
|
264
|
-
if (typeof window === 'undefined')
|
|
265
|
-
return { height: 0, width: 0, x: 0, y: 0 };
|
|
266
|
-
// Prefer the Chromium VirtualKeyboard API for precise geometry.
|
|
267
|
-
const vk = getVirtualKeyboard();
|
|
268
|
-
if (vk !== null) {
|
|
269
|
-
const rect = vk.boundingRect;
|
|
270
|
-
return { height: rect.height, width: rect.width, x: rect.x, y: rect.y };
|
|
271
|
-
}
|
|
272
|
-
// Fall back to inferring height from visualViewport shrink.
|
|
273
|
-
const viewport = window.visualViewport;
|
|
274
|
-
if (viewport === undefined || viewport === null)
|
|
275
|
-
return { height: 0, width: 0, x: 0, y: 0 };
|
|
276
|
-
const shrink = window.innerHeight - viewport.height;
|
|
277
|
-
const height = shrink > 0 ? shrink : 0;
|
|
278
|
-
const width = height > 0 ? window.innerWidth : 0;
|
|
279
|
-
const y = height > 0 ? viewport.height : 0;
|
|
280
|
-
return { height, width, x: 0, y };
|
|
281
|
-
}
|
|
282
77
|
//# sourceMappingURL=keyboard.js.map
|
package/dist/keyboard.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keyboard.js","sourceRoot":"","sources":["../src/keyboard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"keyboard.js","sourceRoot":"","sources":["../src/keyboard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAmBtE,MAAM,CAAC,KAAK,UAAU,k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ACvC,IAAoC,EACpC,IAA4B;IAE5B,OAAO,IAAI,CAAC,KAAK,CAAC,2BAA2B,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;AACpE,CAAC;AAED,MAAM,UAAU,kCAAkC,CAChD,IAAiC,EACjC,OAAgB;IAEhB,OAAO,IAAI,CAAC,KAAK,CAAC,wBAAwB,CAAC,sBAAsB,CAAC,OAAO,CAAC,CAAC;AAC7E,CAAC;AAED,MAAM,UAAU,oBAAoB,CAClC,IAA0B,EAC1B,KAA4B;IAE5B,OAAO,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AACtD,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,IAA+B;IAC9D,OAAO,IAAI,CAAC,KAAK,CAAC,sBAAsB,CAAC,IAAI,EAAE,CAAC;AAClD,CAAC;AAED,MAAM,QAAQ,GAAqB,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;AACvF,MAAM,cAAc,GAAG,IAAI,OAAO,EAA4B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flighthq/keyboard",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.1-edge.638.d4dbd4e",
|
|
4
4
|
"author": "Joshua Granick and other contributors",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -38,8 +38,9 @@
|
|
|
38
38
|
"clean:dist": "tsx ../../scripts/clean-package-dist.ts"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@flighthq/
|
|
42
|
-
"@flighthq/
|
|
41
|
+
"@flighthq/entity": "0.5.1-edge.638.d4dbd4e",
|
|
42
|
+
"@flighthq/signals": "0.5.1-edge.638.d4dbd4e",
|
|
43
|
+
"@flighthq/types": "0.5.1-edge.638.d4dbd4e"
|
|
43
44
|
},
|
|
44
45
|
"devDependencies": {
|
|
45
46
|
"typescript": "^5.3.0"
|