@livx.cc/native-kit 0.45.23 → 0.45.25
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/package.json +1 -1
- package/src/index.ts +1 -1
- package/src/modules/webview.ts +39 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@livx.cc/native-kit",
|
|
3
|
-
"version": "0.45.
|
|
3
|
+
"version": "0.45.25",
|
|
4
4
|
"description": "Isomorphic native-capabilities kit for PWAs — same API in browser and in an appwrap native shell. Zero dependencies.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Elya Livshitz",
|
package/src/index.ts
CHANGED
|
@@ -43,7 +43,7 @@ export { isScanResult } from './modules/scanner';
|
|
|
43
43
|
export type { SpeechVoice, SpeakOptions, ListenOptions, SpeechPartial } from './modules/speech';
|
|
44
44
|
export type { CalendarEventOptions } from './modules/calendar';
|
|
45
45
|
export type { BrowserOptions } from './modules/browser';
|
|
46
|
-
export type { WebViewState, WebViewOpenOptions, WebViewNavOp } from './modules/webview';
|
|
46
|
+
export type { WebViewState, WebViewOpenOptions, WebViewNavOp, WebViewFabOptions, WebViewFloatOptions } from './modules/webview';
|
|
47
47
|
export type { OAuthAuthorizeParams, OAuthResult } from './modules/oauth';
|
|
48
48
|
export type { TrackingStatus } from './modules/tracking';
|
|
49
49
|
export type {
|
package/src/modules/webview.ts
CHANGED
|
@@ -17,6 +17,25 @@ export interface WebViewOpenOptions {
|
|
|
17
17
|
bottom?: number;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
export interface WebViewFabOptions {
|
|
21
|
+
show: boolean;
|
|
22
|
+
bottom?: number;
|
|
23
|
+
right?: number;
|
|
24
|
+
size?: number;
|
|
25
|
+
/** Corner radius (px); default = round. */
|
|
26
|
+
radius?: number;
|
|
27
|
+
color?: string;
|
|
28
|
+
symbol?: string;
|
|
29
|
+
text?: string;
|
|
30
|
+
label?: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface WebViewFloatOptions {
|
|
34
|
+
on: boolean;
|
|
35
|
+
/** The app's touchable boxes over the page (CSS px from the app WebView's top-left). */
|
|
36
|
+
hit?: { x: number; y: number; w: number; h: number }[];
|
|
37
|
+
}
|
|
38
|
+
|
|
20
39
|
/** A cookie as data; `expires` = unix seconds, absent/null = session cookie. A leading-dot `domain` = domain cookie. */
|
|
21
40
|
export interface WebViewCookie {
|
|
22
41
|
name: string;
|
|
@@ -80,6 +99,26 @@ export class WebViewModule {
|
|
|
80
99
|
return (await this.kit.invoke<{ result: T }>('webview.eval', { js, ...opts }, { timeoutMs: 35_000 })).result; // (native gives up at 30s)
|
|
81
100
|
}
|
|
82
101
|
|
|
102
|
+
/** A round floating button over the app and the overlay (stays tappable while a page is shown) — e.g. an assistant
|
|
103
|
+
* button. `bottom`/`right`: CSS px from the app WebView's bottom-right; `color` #rrggbb; `symbol`: an SF Symbol (iOS,
|
|
104
|
+
* default 'sparkles'); `text`: its glyph on Android ('✦'); `label`: accessibility. `show:false` hides it. Taps →
|
|
105
|
+
* {@link onFab}. Works with or without an open overlay. */
|
|
106
|
+
fab(opts: WebViewFabOptions): Promise<{ shown: boolean }> {
|
|
107
|
+
return this.kit.invoke('webview.fab', { ...opts });
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** Float the app's WebView OVER the overlay: it draws on top (transparent wherever the app's own page is — give the
|
|
111
|
+
* area over the overlay no background), so e.g. chat bubbles float over a shown page without resizing it. Touches
|
|
112
|
+
* inside `hit` (app CSS px, viewport coords) go to the app; everywhere else to the page. Call again to move the rects;
|
|
113
|
+
* `on:false` restores. iOS; elsewhere resolves `{floating:false}` — keep a fallback (e.g. inset the page). */
|
|
114
|
+
float(opts: WebViewFloatOptions): Promise<{ floating: boolean }> {
|
|
115
|
+
return this.kit.invoke('webview.float', { ...opts });
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
onFab(cb: () => void): Unsubscribe {
|
|
119
|
+
return this.kit.on('webview.fab', () => cb());
|
|
120
|
+
}
|
|
121
|
+
|
|
83
122
|
/** Tear the overlay down (fires {@link onClosed}). */
|
|
84
123
|
close(): Promise<void> {
|
|
85
124
|
return this.kit.invoke('webview.close', {});
|