@cxxi-lab/hubbyware-sdk 0.0.0-stage → 3.0.1
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/LICENSE +21 -0
- package/frame/hubby.tsx +59 -0
- package/frame/index.ts +8 -0
- package/frame/runtime.css +16 -0
- package/frame/sdk.ts +125 -0
- package/package.json +37 -5
- package/protocol.ts +47 -0
- package/shared.json +10 -0
- package/types/index.d.ts +1030 -0
- package/version.json +4 -0
- package/README.md +0 -3
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,1030 @@
|
|
|
1
|
+
// @cxxi-lab/hubbyware-sdk 3.0.1: generated by app/scripts/emit-sdk-types.mjs from app/src/sdk — do not edit.
|
|
2
|
+
import { IconDefinition } from '@fortawesome/fontawesome-svg-core';
|
|
3
|
+
import { ComponentType, HTMLInputTypeAttribute, MouseEventHandler, ReactNode, TdHTMLAttributes, ThHTMLAttributes } from 'react';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The platform contract: everything the shared UI needs from its host shell.
|
|
7
|
+
*
|
|
8
|
+
* `app/` depends only on this file; each shell provides an implementation
|
|
9
|
+
* (`electron.ts` today, a Capacitor one later). The domain types below are the
|
|
10
|
+
* single source of truth — the Electron preload imports them from here
|
|
11
|
+
* (`@hub/app/platform`) so `window.api` cannot drift from this contract.
|
|
12
|
+
*/
|
|
13
|
+
export type VpnStatus = "disabled" | "starting" | "connected" | "error";
|
|
14
|
+
export interface VpnInfo {
|
|
15
|
+
status: VpnStatus;
|
|
16
|
+
port: number | null;
|
|
17
|
+
error: string | null;
|
|
18
|
+
endpoint: string | null;
|
|
19
|
+
}
|
|
20
|
+
export type UpdatePhase = "available" | "downloading" | "verifying" | "installing" | "error";
|
|
21
|
+
export interface UpdateState {
|
|
22
|
+
phase: UpdatePhase;
|
|
23
|
+
version: string;
|
|
24
|
+
currentVersion: string;
|
|
25
|
+
progress: {
|
|
26
|
+
percent: number;
|
|
27
|
+
transferred: number;
|
|
28
|
+
total: number;
|
|
29
|
+
bytesPerSecond: number;
|
|
30
|
+
} | null;
|
|
31
|
+
error: string | null;
|
|
32
|
+
}
|
|
33
|
+
export interface IntegrationCookie {
|
|
34
|
+
name: string;
|
|
35
|
+
value: string;
|
|
36
|
+
}
|
|
37
|
+
export interface IntegrationReferer {
|
|
38
|
+
url: string;
|
|
39
|
+
cdnHostPattern: string;
|
|
40
|
+
}
|
|
41
|
+
export interface WebsiteIntegration {
|
|
42
|
+
cookies?: IntegrationCookie[];
|
|
43
|
+
referer?: IntegrationReferer;
|
|
44
|
+
}
|
|
45
|
+
export type CompanionEngineStatus = "off" | "starting" | "on" | "error";
|
|
46
|
+
export interface CompanionEngineInfo {
|
|
47
|
+
status: CompanionEngineStatus;
|
|
48
|
+
external: boolean;
|
|
49
|
+
error: string | null;
|
|
50
|
+
}
|
|
51
|
+
/** One line of a conversation's activity log: what happened in the background. */
|
|
52
|
+
export interface CompanionLogEntry {
|
|
53
|
+
id: number;
|
|
54
|
+
at: number;
|
|
55
|
+
level: "info" | "warn" | "error";
|
|
56
|
+
text: string;
|
|
57
|
+
/** raw text behind the line (reply, notes, scene, tags…) */
|
|
58
|
+
detail?: string;
|
|
59
|
+
}
|
|
60
|
+
/** What the companion is doing right now: writing, recording a voice message or taking a photo. */
|
|
61
|
+
export type CompanionActivity = "typing" | "recording" | "photo" | null;
|
|
62
|
+
export interface CompanionProfile {
|
|
63
|
+
/** conversation id ('main' for the first one) */
|
|
64
|
+
id: string;
|
|
65
|
+
name: string;
|
|
66
|
+
/** name shown in the app (`name` unless the profile sets another one) */
|
|
67
|
+
label: string;
|
|
68
|
+
userName: string;
|
|
69
|
+
/** media file of the profile picture */
|
|
70
|
+
avatar: string | null;
|
|
71
|
+
}
|
|
72
|
+
export interface CompanionMessage {
|
|
73
|
+
id: number;
|
|
74
|
+
role: "user" | "companion";
|
|
75
|
+
kind: "text" | "image" | "audio";
|
|
76
|
+
content: string;
|
|
77
|
+
mediaPath: string | null;
|
|
78
|
+
createdAt: number;
|
|
79
|
+
readAt: number | null;
|
|
80
|
+
proactive: boolean;
|
|
81
|
+
userReaction: string | null;
|
|
82
|
+
userReactionAt: number | null;
|
|
83
|
+
companionReaction: string | null;
|
|
84
|
+
replyId: number | null;
|
|
85
|
+
}
|
|
86
|
+
/** A hubby's window as the host knows it (its component stays in the hubby). */
|
|
87
|
+
export interface HubbyWindowInfo {
|
|
88
|
+
hubbyId: string;
|
|
89
|
+
id: string;
|
|
90
|
+
title: string;
|
|
91
|
+
width?: number;
|
|
92
|
+
height?: number;
|
|
93
|
+
menu?: {
|
|
94
|
+
label: string;
|
|
95
|
+
accelerator?: string;
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
/** Unsubscribe handle returned by every `on…` listener. */
|
|
99
|
+
export type Unsubscribe = () => void;
|
|
100
|
+
/**
|
|
101
|
+
* A hubby as published or installed: its catalogue entry (app/scripts/build-hubbies.mjs), enough
|
|
102
|
+
* to list it before it is installed.
|
|
103
|
+
*/
|
|
104
|
+
export interface HubbyPackage {
|
|
105
|
+
id: string;
|
|
106
|
+
version: string;
|
|
107
|
+
/** the SDK range it needs (^x.y.z) */
|
|
108
|
+
sdk: string;
|
|
109
|
+
css: boolean;
|
|
110
|
+
/** it ships models.json (its collections' models); absent in entries from before the flag */
|
|
111
|
+
models?: boolean;
|
|
112
|
+
label: string;
|
|
113
|
+
description?: string;
|
|
114
|
+
/** its icon's [width, height, svg path] */
|
|
115
|
+
icon?: [
|
|
116
|
+
number,
|
|
117
|
+
number,
|
|
118
|
+
string
|
|
119
|
+
] | null;
|
|
120
|
+
local?: boolean;
|
|
121
|
+
requires?: string[];
|
|
122
|
+
requiresCapabilities?: string[];
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* A restricted hubby (offered only to the accounts given it), as the server lists it for this
|
|
126
|
+
* account: its catalogue entry (JSON, with its files) signed alone with the update key, and a
|
|
127
|
+
* signed, expiring URL per file.
|
|
128
|
+
*/
|
|
129
|
+
export interface RestrictedHubbyPackage {
|
|
130
|
+
entry: string;
|
|
131
|
+
/** base64 */
|
|
132
|
+
signature: string;
|
|
133
|
+
urls: Record<string, string>;
|
|
134
|
+
/** an entry signed by its publisher's key, not the official one: that key's certificate */
|
|
135
|
+
publisher?: PublisherCertificate;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* A key allowed to sign one hubby's entries (a third party's): `certificate` is the JSON text
|
|
139
|
+
* {"hubby": <id>, "key": <its Ed25519 public key, SPKI DER, base64>}, `signature` the official
|
|
140
|
+
* key's (base64). Trusted for that hubby only.
|
|
141
|
+
*/
|
|
142
|
+
export interface PublisherCertificate {
|
|
143
|
+
certificate: string;
|
|
144
|
+
signature: string;
|
|
145
|
+
}
|
|
146
|
+
/** The hubbies of this device: installed from the server's catalogue (signed), on demand. */
|
|
147
|
+
export interface HubbyStoreApi {
|
|
148
|
+
/**
|
|
149
|
+
* The hubbies this app can have, one entry each: the installed ones, and the published ones
|
|
150
|
+
* compatible with this app (the newest). Without the server (VPN down), the installed ones and
|
|
151
|
+
* the last catalogue read.
|
|
152
|
+
*/
|
|
153
|
+
list(): Promise<{
|
|
154
|
+
hubbies: HubbyPackage[];
|
|
155
|
+
installed: string[];
|
|
156
|
+
}>;
|
|
157
|
+
/** Installs a hubby (its newest compatible version), usable at once. Already installed: at once. */
|
|
158
|
+
install(id: string): Promise<HubbyPackage>;
|
|
159
|
+
/** Removes a hubby's files from this device (a loaded one stays until the app restarts). */
|
|
160
|
+
uninstall(id: string): Promise<void>;
|
|
161
|
+
/**
|
|
162
|
+
* The restricted hubbies this account was given (the server's list, renderer side: it needs the
|
|
163
|
+
* session): the store checks each signature, lists and installs them like the others.
|
|
164
|
+
*/
|
|
165
|
+
setRestricted(hubbies: RestrictedHubbyPackage[]): Promise<void>;
|
|
166
|
+
/**
|
|
167
|
+
* The newer versions already downloaded than what runs ("id version"). A hubby's version is
|
|
168
|
+
* decided at start; these wait for activate() (or the next start).
|
|
169
|
+
*/
|
|
170
|
+
pending(): Promise<string[]>;
|
|
171
|
+
/** Runs them from now on: the app reloads its page right after. Returns what changed. */
|
|
172
|
+
activate(): Promise<string[]>;
|
|
173
|
+
}
|
|
174
|
+
/** One of the app's notifications, as the system shows it. */
|
|
175
|
+
export interface SystemNotification {
|
|
176
|
+
id: number;
|
|
177
|
+
title: string;
|
|
178
|
+
body: string | null;
|
|
179
|
+
/** a state's count (null: an event); shown again when it grows */
|
|
180
|
+
count: number | null;
|
|
181
|
+
/** where a click leads in the app */
|
|
182
|
+
link: string | null;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* The app's notifications shown by the system (desktop: its notification center, the dock marks
|
|
186
|
+
* hub as having some). The page hands over its whole list at each change.
|
|
187
|
+
*/
|
|
188
|
+
export interface SystemNotificationsApi {
|
|
189
|
+
sync(items: SystemNotification[]): void;
|
|
190
|
+
/** a click on one: the app opens its link */
|
|
191
|
+
onOpen(cb: (link: string) => void): Unsubscribe;
|
|
192
|
+
}
|
|
193
|
+
/** A document of a hubby's store (docs/plan-hubby-storage.md), local or on the server. */
|
|
194
|
+
export interface StoredDocument {
|
|
195
|
+
collection: string;
|
|
196
|
+
id: string;
|
|
197
|
+
data: unknown;
|
|
198
|
+
/** milliseconds: the last write wins */
|
|
199
|
+
updatedAt: number;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* The device's base for the hubbies' data (SQLite: desktop in the main process, Android a plugin),
|
|
203
|
+
* where the local-first sync keeps them (core/sync). Every call names the account (a hash), the
|
|
204
|
+
* hubby and the scope.
|
|
205
|
+
*/
|
|
206
|
+
export interface LocalStoreApi {
|
|
207
|
+
list(account: string, hubby: string, scope: string, collection?: string): Promise<StoredDocument[]>;
|
|
208
|
+
get(account: string, hubby: string, scope: string, collection: string, id: string): Promise<StoredDocument | null>;
|
|
209
|
+
put(account: string, hubby: string, scope: string, documents: StoredDocument[]): Promise<void>;
|
|
210
|
+
delete(account: string, hubby: string, scope: string, collection: string, id: string): Promise<void>;
|
|
211
|
+
purge(account: string, hubby: string, scope: string): Promise<void>;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* The app's notifications by push (Android: Firebase Cloud Messaging): the server sends each change,
|
|
215
|
+
* the shell shows it as a system notification, even with the app closed.
|
|
216
|
+
*/
|
|
217
|
+
export interface PushApi {
|
|
218
|
+
/** Asks the permission to notify (once) and returns this device's token for the server; null: no push. */
|
|
219
|
+
register(): Promise<{
|
|
220
|
+
token: string;
|
|
221
|
+
platform: "android";
|
|
222
|
+
} | null>;
|
|
223
|
+
/** a notification tapped: the app opens its link */
|
|
224
|
+
onOpen(cb: (link: string) => void): Unsubscribe;
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* The AI companion. Desktop-only today (local Ollama); a shell without it
|
|
228
|
+
* reports `capabilities.companion === false` and the UI hides the hubby.
|
|
229
|
+
*/
|
|
230
|
+
export interface CompanionApi {
|
|
231
|
+
getEngine(): Promise<CompanionEngineInfo>;
|
|
232
|
+
setEngine(on: boolean): void;
|
|
233
|
+
onEngineChange(cb: (info: CompanionEngineInfo) => void): Unsubscribe;
|
|
234
|
+
listConversations(): Promise<CompanionProfile[]>;
|
|
235
|
+
getProfile(conversationId: string): Promise<CompanionProfile>;
|
|
236
|
+
listMessages(conversationId: string, opts: {
|
|
237
|
+
limit: number;
|
|
238
|
+
beforeId?: number;
|
|
239
|
+
}): Promise<CompanionMessage[]>;
|
|
240
|
+
send(conversationId: string, content: string): Promise<CompanionMessage>;
|
|
241
|
+
react(conversationId: string, id: number, emoji: string | null): Promise<CompanionMessage | null>;
|
|
242
|
+
regenerate(conversationId: string): Promise<number[] | null>;
|
|
243
|
+
onMessagesDeleted(cb: (conversationId: string, ids: number[]) => void): Unsubscribe;
|
|
244
|
+
onMessageUpdate(cb: (conversationId: string, message: CompanionMessage) => void): Unsubscribe;
|
|
245
|
+
listImages(conversationId: string): Promise<CompanionMessage[]>;
|
|
246
|
+
onMessage(cb: (conversationId: string, message: CompanionMessage) => void): Unsubscribe;
|
|
247
|
+
onActivity(cb: (conversationId: string, activity: CompanionActivity) => void): Unsubscribe;
|
|
248
|
+
onError(cb: (conversationId: string, error: string) => void): Unsubscribe;
|
|
249
|
+
getActivity(conversationId: string): Promise<CompanionActivity>;
|
|
250
|
+
listLog(conversationId: string): Promise<CompanionLogEntry[]>;
|
|
251
|
+
onLog(cb: (conversationId: string, entry: CompanionLogEntry) => void): Unsubscribe;
|
|
252
|
+
getUnread(): Promise<Record<string, number>>;
|
|
253
|
+
onUnreadChange(cb: (counts: Record<string, number>) => void): Unsubscribe;
|
|
254
|
+
markRead(conversationId: string): void;
|
|
255
|
+
}
|
|
256
|
+
/** What the web layer hands the native player: desktop VideoPlayerModal's webview inputs. */
|
|
257
|
+
export interface NativePlayerOptions {
|
|
258
|
+
url: string;
|
|
259
|
+
/** Referer header for the first load (embed mode), null for none */
|
|
260
|
+
referrer: string | null;
|
|
261
|
+
/** script run once the DOM is ready; the player is ready when its promise settles (null: ready on load) */
|
|
262
|
+
bootstrap: string | null;
|
|
263
|
+
/** shown while the page loads */
|
|
264
|
+
poster: string | null;
|
|
265
|
+
/** swipe neighbours: whether there is one each way, and its poster (slides in while swiping) */
|
|
266
|
+
hasPrev: boolean;
|
|
267
|
+
hasNext: boolean;
|
|
268
|
+
prevPoster: string | null;
|
|
269
|
+
nextPoster: string | null;
|
|
270
|
+
/** posters to fetch ahead (videos further away), so fast swipes find them ready */
|
|
271
|
+
preloadPosters: string[];
|
|
272
|
+
}
|
|
273
|
+
/** A Font Awesome icon as drawn natively: viewBox size + SVG path data. */
|
|
274
|
+
export interface NativeIcon {
|
|
275
|
+
width: number;
|
|
276
|
+
height: number;
|
|
277
|
+
path: string;
|
|
278
|
+
}
|
|
279
|
+
/** One of the player's actions, behind its gear button. Taps come back through `onAction`. */
|
|
280
|
+
export interface NativePlayerAction {
|
|
281
|
+
id: string;
|
|
282
|
+
label: string;
|
|
283
|
+
icon: NativeIcon;
|
|
284
|
+
/** danger: a destructive action awaiting its confirming second tap */
|
|
285
|
+
tone: "default" | "danger";
|
|
286
|
+
/** running: shown dimmed, taps ignored */
|
|
287
|
+
busy: boolean;
|
|
288
|
+
}
|
|
289
|
+
/** Overlay over the video (tags, info); tapping it closes it. */
|
|
290
|
+
export interface NativePlayerPanel {
|
|
291
|
+
chips?: string[];
|
|
292
|
+
rows?: Array<[
|
|
293
|
+
label: string,
|
|
294
|
+
value: string
|
|
295
|
+
]>;
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Fullscreen native player above the app (Capacitor). Stands in for the
|
|
299
|
+
* <webview> of the video player modal on shells without `capabilities.webview`;
|
|
300
|
+
* only reached when `capabilities.nativePlayer` is true.
|
|
301
|
+
*/
|
|
302
|
+
export interface NativePlayerApi {
|
|
303
|
+
open(options: NativePlayerOptions): Promise<void>;
|
|
304
|
+
exec(script: string): Promise<void>;
|
|
305
|
+
reload(): Promise<void>;
|
|
306
|
+
close(): Promise<void>;
|
|
307
|
+
/** the actions behind the gear (the whole list each time), and the icons of the gear and close buttons */
|
|
308
|
+
setActions(actions: NativePlayerAction[], icons: {
|
|
309
|
+
menu: NativeIcon;
|
|
310
|
+
close: NativeIcon;
|
|
311
|
+
}): Promise<void>;
|
|
312
|
+
showPanel(panel: NativePlayerPanel | null): Promise<void>;
|
|
313
|
+
onReady(cb: () => void): Unsubscribe;
|
|
314
|
+
onClosed(cb: () => void): Unsubscribe;
|
|
315
|
+
onAction(cb: (id: string) => void): Unsubscribe;
|
|
316
|
+
/** a swipe went through: the web side switches to that neighbour and opens it */
|
|
317
|
+
onNavigate(cb: (direction: "prev" | "next") => void): Unsubscribe;
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* What the host shell can do. The UI reads these to hide what a shell lacks
|
|
321
|
+
* (e.g. the Capacitor shell has no native windows and no companion engine).
|
|
322
|
+
*/
|
|
323
|
+
export interface PlatformCapabilities {
|
|
324
|
+
/** AI companion engine (local LLM) */
|
|
325
|
+
companion: boolean;
|
|
326
|
+
/** integrated WireGuard tunnel controllable from the UI */
|
|
327
|
+
vpn: boolean;
|
|
328
|
+
/** hubbies hidden behind a reveal shortcut (Privacy) */
|
|
329
|
+
privateMode: boolean;
|
|
330
|
+
/** in-app self-update */
|
|
331
|
+
updates: boolean;
|
|
332
|
+
/** per-site cookie/referer injection for the embedded browser/player */
|
|
333
|
+
integrations: boolean;
|
|
334
|
+
/** embedded <webview> (the integrated browser and the external player) */
|
|
335
|
+
webview: boolean;
|
|
336
|
+
/** fullscreen native player (`platform.player`) instead of an embedded <webview> */
|
|
337
|
+
nativePlayer: boolean;
|
|
338
|
+
/** separate native windows (Settings/History/About) vs in-app pages */
|
|
339
|
+
nativeWindows: boolean;
|
|
340
|
+
/** global audio mute toggle */
|
|
341
|
+
mute: boolean;
|
|
342
|
+
/** developer "local server" toggle */
|
|
343
|
+
devMode: boolean;
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* The host shell, as seen by the shared UI. Method names mirror the Electron
|
|
347
|
+
* preload so the Electron adapter is a thin pass-through; other shells
|
|
348
|
+
* implement what they can and advertise the rest through `capabilities`.
|
|
349
|
+
*/
|
|
350
|
+
export interface Platform {
|
|
351
|
+
readonly name: "electron" | "capacitor";
|
|
352
|
+
/**
|
|
353
|
+
* Value sent in the `X-Hub-Client` header on the server's cookie-authenticated
|
|
354
|
+
* auth routes. Must be one of the server's accepted client values
|
|
355
|
+
* (SecurityController::CLIENT_HEADER_VALUES).
|
|
356
|
+
*/
|
|
357
|
+
readonly client: "desktop" | "android";
|
|
358
|
+
readonly capabilities: PlatformCapabilities;
|
|
359
|
+
/** Host runtime info for the About screen (OS + engine versions). */
|
|
360
|
+
readonly runtime: {
|
|
361
|
+
os: string;
|
|
362
|
+
versions: Record<string, string>;
|
|
363
|
+
};
|
|
364
|
+
ping(): Promise<string>;
|
|
365
|
+
getDevMode(): Promise<boolean>;
|
|
366
|
+
onDevModeChange(cb: (value: boolean) => void): Unsubscribe;
|
|
367
|
+
notifyAuthState(authenticated: boolean): void;
|
|
368
|
+
/**
|
|
369
|
+
* The server just set a new refresh-token cookie (login, refresh: each
|
|
370
|
+
* refresh revokes the previous token). The shell makes it durable at once,
|
|
371
|
+
* or an app killed before its cookie store flushes comes back with a revoked
|
|
372
|
+
* token and a forced re-login.
|
|
373
|
+
*/
|
|
374
|
+
persistSession(): void;
|
|
375
|
+
/**
|
|
376
|
+
* The hidden hubbies revealed this session (Privacy: their shortcut), shared by the app's
|
|
377
|
+
* windows; forgotten at restart. Hidden again all at once by Ctrl+Alt+Q.
|
|
378
|
+
*/
|
|
379
|
+
getRevealedHubbies(): Promise<string[]>;
|
|
380
|
+
/**
|
|
381
|
+
* A secret kept by this device only, encrypted by the system (desktop: the OS keyring through
|
|
382
|
+
* safeStorage; Android: the Keystore): the account's data key (core/crypto). null: none.
|
|
383
|
+
*/
|
|
384
|
+
getDeviceSecret(name: string): Promise<string | null>;
|
|
385
|
+
/** null: forgotten. */
|
|
386
|
+
setDeviceSecret(name: string, value: string | null): Promise<void>;
|
|
387
|
+
setRevealedHubbies(ids: string[]): void;
|
|
388
|
+
onRevealedHubbiesChange(cb: (ids: string[]) => void): Unsubscribe;
|
|
389
|
+
onWebviewKey(cb: (event: {
|
|
390
|
+
key: string;
|
|
391
|
+
ctrl: boolean;
|
|
392
|
+
alt: boolean;
|
|
393
|
+
}) => void): Unsubscribe;
|
|
394
|
+
showMessage(message: string): Promise<void>;
|
|
395
|
+
/**
|
|
396
|
+
* The theme chosen (`mode`) and shown (`theme`, auto resolved), and the accent colour, for the
|
|
397
|
+
* shell: desktop, the native theme, the windows' background before they load and the icon in
|
|
398
|
+
* the accent; Android, the system bars.
|
|
399
|
+
*/
|
|
400
|
+
setTheme(mode: "auto" | "light" | "dark", theme: "light" | "dark", accent: string): void;
|
|
401
|
+
getMuted(): Promise<boolean>;
|
|
402
|
+
setMuted(value: boolean): void;
|
|
403
|
+
onMutedChange(cb: (value: boolean) => void): Unsubscribe;
|
|
404
|
+
getVpnStatus(): Promise<VpnInfo>;
|
|
405
|
+
startVpn(): Promise<void>;
|
|
406
|
+
stopVpn(): Promise<void>;
|
|
407
|
+
onVpnStatusChange(cb: (info: VpnInfo) => void): Unsubscribe;
|
|
408
|
+
replaceVpnConfig(): Promise<{
|
|
409
|
+
ok: boolean;
|
|
410
|
+
path: string | null;
|
|
411
|
+
error?: string;
|
|
412
|
+
}>;
|
|
413
|
+
/** Opens the Settings window, on a screen when given (e.g. 'security'). */
|
|
414
|
+
openSettings(target?: string): Promise<void>;
|
|
415
|
+
/** In the Settings window: a screen another window asked for. */
|
|
416
|
+
onSettingsGoto(cb: (target: string) => void): Unsubscribe;
|
|
417
|
+
/**
|
|
418
|
+
* Opens an OAuth consent page in an app window; resolves with the URL the provider redirected to
|
|
419
|
+
* (`redirectUri` + the code), caught before it loads, or null when the window was closed.
|
|
420
|
+
*/
|
|
421
|
+
authorizeOAuth(url: string, redirectUri: string): Promise<string | null>;
|
|
422
|
+
/** Opens a hubby's window (HubbyManifest.windows), registered beforehand. */
|
|
423
|
+
openHubbyWindow(hubbyId: string, windowId: string): Promise<void>;
|
|
424
|
+
/** @deprecated openHubbyWindow: its SDK 2 name, kept for the hubbies built before the rename */
|
|
425
|
+
openModuleWindow(hubbyId: string, windowId: string): Promise<void>;
|
|
426
|
+
/** The windows of the active hubbies: what the app menu offers (replaces the previous list). */
|
|
427
|
+
registerHubbyWindows(windows: HubbyWindowInfo[]): Promise<void>;
|
|
428
|
+
openAbout(): Promise<void>;
|
|
429
|
+
getAppVersion(): Promise<string>;
|
|
430
|
+
getUpdateState(): Promise<UpdateState | null>;
|
|
431
|
+
onUpdateStateChange(cb: (state: UpdateState) => void): Unsubscribe;
|
|
432
|
+
installUpdate(): Promise<void>;
|
|
433
|
+
skipUpdate(): Promise<void>;
|
|
434
|
+
quitApp(): Promise<void>;
|
|
435
|
+
listIntegrations(): Promise<Array<{
|
|
436
|
+
host: string;
|
|
437
|
+
updatedAt: number;
|
|
438
|
+
}>>;
|
|
439
|
+
applyIntegration(payload: {
|
|
440
|
+
host: string;
|
|
441
|
+
integration: WebsiteIntegration;
|
|
442
|
+
updatedAt: number;
|
|
443
|
+
}): Promise<void>;
|
|
444
|
+
removeIntegration(host: string): Promise<void>;
|
|
445
|
+
/**
|
|
446
|
+
* Hosts the embedded browser / video player blocks (ads, trackers), compiled
|
|
447
|
+
* by the back. The shell persists the list; the version lets the UI skip a
|
|
448
|
+
* download when it already holds the latest one.
|
|
449
|
+
*/
|
|
450
|
+
getPlayerBlocklistVersion(): Promise<string | null>;
|
|
451
|
+
setPlayerBlocklist(version: string, hosts: string[]): Promise<void>;
|
|
452
|
+
readonly companion: CompanionApi;
|
|
453
|
+
readonly player: NativePlayerApi;
|
|
454
|
+
/** null: the shell shows none (Android: they come by push, `push`) */
|
|
455
|
+
readonly systemNotifications: SystemNotificationsApi | null;
|
|
456
|
+
/** null: no push (desktop: the open app shows them itself) */
|
|
457
|
+
readonly push: PushApi | null;
|
|
458
|
+
/** null: no local store here (Android, for now): a scope kept local isn't reachable on this device */
|
|
459
|
+
readonly localStore: LocalStoreApi | null;
|
|
460
|
+
/** null: the hubbies come from their sources (development), all of them, nothing to install */
|
|
461
|
+
readonly hubbyStore: HubbyStoreApi | null;
|
|
462
|
+
/**
|
|
463
|
+
* Where an isolated hubby's frame loads from (its own origin: desktop hubby://<id>/, Android
|
|
464
|
+
* https://<id>.hubby.localhost/); null where hubbies can't run isolated (yet).
|
|
465
|
+
*/
|
|
466
|
+
hubbyUrl(hubby: string): string | null;
|
|
467
|
+
}
|
|
468
|
+
export declare const platform: Platform;
|
|
469
|
+
/**
|
|
470
|
+
* Cross-hubby "timeline" capability. A hubby MAY expose dated items it owns (e.g.
|
|
471
|
+
* workout sessions) that any calendar/agenda surface can display, plus an optional
|
|
472
|
+
* self-contained detail view opened when an item is interacted with.
|
|
473
|
+
*
|
|
474
|
+
* Fully agnostic: no producer or consumer is named here. `payload` is opaque data the
|
|
475
|
+
* PRODUCING hubby attaches and reads back in its own renderer — consumers never touch it.
|
|
476
|
+
*/
|
|
477
|
+
export interface TimelineItem {
|
|
478
|
+
/** globally unique, namespaced by the source hubby, e.g. 'workout:123' */
|
|
479
|
+
id: string;
|
|
480
|
+
date: Date;
|
|
481
|
+
title: string;
|
|
482
|
+
/**
|
|
483
|
+
* the hubby that produced it (for grouping / coloring). A hubby built before the rename (SDK 2)
|
|
484
|
+
* sets `moduleId` instead: a consumer reads `hubbyId ?? moduleId`.
|
|
485
|
+
*/
|
|
486
|
+
hubbyId: string;
|
|
487
|
+
/** @deprecated hubbyId (SDK 2) */
|
|
488
|
+
moduleId?: string;
|
|
489
|
+
/** where a consumer can send the user for the full item (deep-link fallback) */
|
|
490
|
+
href: string;
|
|
491
|
+
/** optional presentation hint: a CSS color used as the chip accent (generic) */
|
|
492
|
+
color?: string;
|
|
493
|
+
/** opaque hubby-private data, read only by the producing hubby's renderDetail */
|
|
494
|
+
payload?: unknown;
|
|
495
|
+
}
|
|
496
|
+
/** Fetch a hubby's dated items overlapping [start, end). */
|
|
497
|
+
export type TimelineItemsProvider = (start: Date, end: Date) => Promise<TimelineItem[]>;
|
|
498
|
+
export interface TimelineDetailContext {
|
|
499
|
+
onClose: () => void;
|
|
500
|
+
/** call after a mutation so the consumer can refresh its data */
|
|
501
|
+
onChanged: () => void;
|
|
502
|
+
}
|
|
503
|
+
/** Render a self-contained detail view (e.g. a modal) for one of the hubby's items. */
|
|
504
|
+
export type TimelineDetailRenderer = (item: TimelineItem, ctx: TimelineDetailContext) => ReactNode;
|
|
505
|
+
/** Planner's calendar: dated items in a range, and how to show one of them. */
|
|
506
|
+
export interface TimelineContribution {
|
|
507
|
+
items: TimelineItemsProvider;
|
|
508
|
+
renderDetail?: TimelineDetailRenderer;
|
|
509
|
+
}
|
|
510
|
+
/**
|
|
511
|
+
* What a hubby can offer the others, by contribution point. A hubby consuming a point never
|
|
512
|
+
* knows who contributes to it; a contribution lives only while its hubby is enabled and shown
|
|
513
|
+
* (a private hubby's contributions disappear with it outside private mode). New points are added
|
|
514
|
+
* here, as part of the SDK contract.
|
|
515
|
+
*/
|
|
516
|
+
export interface ContributionPoints {
|
|
517
|
+
/** Planner's calendar: items dated by another hubby */
|
|
518
|
+
timeline: TimelineContribution;
|
|
519
|
+
}
|
|
520
|
+
export type ContributionPoint = keyof ContributionPoints;
|
|
521
|
+
/** One hubby's contribution to a point. */
|
|
522
|
+
export interface Contribution<P extends ContributionPoint> {
|
|
523
|
+
hubbyId: string;
|
|
524
|
+
/** @deprecated hubbyId: its SDK 2 name, still set for the hubbies built before the rename */
|
|
525
|
+
moduleId: string;
|
|
526
|
+
value: ContributionPoints[P];
|
|
527
|
+
}
|
|
528
|
+
export interface HubbyNavItem {
|
|
529
|
+
to: string;
|
|
530
|
+
label: string;
|
|
531
|
+
/** optional live label (e.g. a name read at runtime + a badge), rendered instead of `label` */
|
|
532
|
+
Label?: ComponentType;
|
|
533
|
+
/** the block of the sidebar it sits in, under this title (consecutive items share it) */
|
|
534
|
+
section?: string;
|
|
535
|
+
/** its icon in the phone's bottom bar (default: its section's, then the hubby's) */
|
|
536
|
+
icon?: IconDefinition;
|
|
537
|
+
/** the page the hubby opens on (default: the first item) */
|
|
538
|
+
home?: boolean;
|
|
539
|
+
}
|
|
540
|
+
export interface HubbyWindow {
|
|
541
|
+
/** unique in the hubby ([a-z0-9-]) */
|
|
542
|
+
id: string;
|
|
543
|
+
title: string;
|
|
544
|
+
Component: ComponentType;
|
|
545
|
+
width?: number;
|
|
546
|
+
height?: number;
|
|
547
|
+
/** an entry of the app menu (Window) opening it */
|
|
548
|
+
menu?: {
|
|
549
|
+
label: string;
|
|
550
|
+
accelerator?: string;
|
|
551
|
+
};
|
|
552
|
+
}
|
|
553
|
+
export interface HubbyRoute {
|
|
554
|
+
path: string;
|
|
555
|
+
Component: ComponentType;
|
|
556
|
+
/** kept mounted (KeepAlive) so page state survives navigation */
|
|
557
|
+
persistent?: boolean;
|
|
558
|
+
/** also answers the paths under it (an isolated hubby: /<id>/… all go to its frame) */
|
|
559
|
+
prefix?: boolean;
|
|
560
|
+
}
|
|
561
|
+
/**
|
|
562
|
+
* Desktop-side hubby manifest. The desktop owns the hubby catalogue (which hubbies
|
|
563
|
+
* exist, their nav and pages); the server advertises which it can serve + which the
|
|
564
|
+
* user enabled. `id` must match the server hubby slug (singular, e.g. 'workout').
|
|
565
|
+
*/
|
|
566
|
+
/**
|
|
567
|
+
* A shared feature a hubby may support:
|
|
568
|
+
* - 'notifications': its notifications (the top bar's dot, the bell, its settings section);
|
|
569
|
+
* - 'vpn': the VPN tunnel, run only while the hubby is open (its pages wait for it);
|
|
570
|
+
* - 'amounts': it shows amounts (money…): its Privacy can blur them (the SDK's Amount).
|
|
571
|
+
*/
|
|
572
|
+
export type HubbySupport = "notifications" | "vpn" | "amounts";
|
|
573
|
+
export interface HubbyManifest {
|
|
574
|
+
id: string;
|
|
575
|
+
label: string;
|
|
576
|
+
/** its card on the home page */
|
|
577
|
+
icon?: IconDefinition;
|
|
578
|
+
/** one line under its name on the home page */
|
|
579
|
+
description?: string;
|
|
580
|
+
/** its own part of its settings screen (Hubbies > the hubby), under the common one */
|
|
581
|
+
Settings?: ComponentType;
|
|
582
|
+
/**
|
|
583
|
+
* Runs entirely on this machine with no server counterpart: always shown, outside the
|
|
584
|
+
* server's enabled list and the front/server integrity diff.
|
|
585
|
+
*/
|
|
586
|
+
local?: boolean;
|
|
587
|
+
/**
|
|
588
|
+
* Host capabilities this hubby needs (see PlatformCapabilities). A shell that
|
|
589
|
+
* lacks any of them hides the hubby entirely — e.g. 'companion' and 'webview'
|
|
590
|
+
* are desktop-only, so AI never appears in the mobile shell.
|
|
591
|
+
*/
|
|
592
|
+
requiresCapabilities?: Array<keyof PlatformCapabilities>;
|
|
593
|
+
navItems: HubbyNavItem[];
|
|
594
|
+
/**
|
|
595
|
+
* Runs isolated, in a sandboxed frame (docs/plan-hubby-architecture.md § 4 ter): none of its
|
|
596
|
+
* code is loaded in the app; its navigation is the one its frame announces.
|
|
597
|
+
*/
|
|
598
|
+
isolated?: boolean;
|
|
599
|
+
/** the icons of its nav sections (by title): a section is a tab of the phone's bottom bar */
|
|
600
|
+
navSections?: Record<string, IconDefinition>;
|
|
601
|
+
routes: HubbyRoute[];
|
|
602
|
+
/**
|
|
603
|
+
* Hubbies this one cannot work without (ids): it is only active while they all are, and
|
|
604
|
+
* the Hubbies screen says so. For a feature that only makes sense with another hubby, prefer
|
|
605
|
+
* a contribution of that hubby (`contributes`).
|
|
606
|
+
*/
|
|
607
|
+
requires?: string[];
|
|
608
|
+
/**
|
|
609
|
+
* The shared features it supports (as its server hubby does): each brings its part of the
|
|
610
|
+
* hubby's settings and its plumbing in the app, e.g. 'notifications' (the top bar's badge).
|
|
611
|
+
*/
|
|
612
|
+
supports?: HubbySupport[];
|
|
613
|
+
/** What this hubby offers the others, by contribution point (see ContributionPoints). */
|
|
614
|
+
contributes?: Partial<ContributionPoints>;
|
|
615
|
+
/**
|
|
616
|
+
* Contexts this hubby needs around the whole app while it is active (e.g. a job followed from
|
|
617
|
+
* any page), outermost first.
|
|
618
|
+
*/
|
|
619
|
+
providers?: Array<ComponentType<{
|
|
620
|
+
children: ReactNode;
|
|
621
|
+
}>>;
|
|
622
|
+
/** Windows of its own (desktop only), opened with platform.openHubbyWindow(hubbyId, id). */
|
|
623
|
+
windows?: HubbyWindow[];
|
|
624
|
+
}
|
|
625
|
+
/**
|
|
626
|
+
* A hubby's hubby.json: its version, the SDK it needs, and how it is described before it is
|
|
627
|
+
* installed (the store lists hubbies from these, see scripts/build-hubbies.mjs). `icon` is a Font
|
|
628
|
+
* Awesome solid icon name, the one its manifest shows.
|
|
629
|
+
*/
|
|
630
|
+
export interface HubbyInfo {
|
|
631
|
+
version: string;
|
|
632
|
+
sdk: string;
|
|
633
|
+
label: string;
|
|
634
|
+
description?: string;
|
|
635
|
+
icon?: string;
|
|
636
|
+
local?: boolean;
|
|
637
|
+
requires?: string[];
|
|
638
|
+
requiresCapabilities?: string[];
|
|
639
|
+
/** shared features (HubbySupport) */
|
|
640
|
+
supports?: string[];
|
|
641
|
+
}
|
|
642
|
+
export type Described = Pick<HubbyManifest, "label" | "description" | "local" | "requires" | "requiresCapabilities" | "supports">;
|
|
643
|
+
/** The manifest's descriptive part, from its hubby.json (one source for both). */
|
|
644
|
+
export declare function describe(info: HubbyInfo): Described;
|
|
645
|
+
/**
|
|
646
|
+
* What the active hubbies offer at a contribution point (none outside the main window): only
|
|
647
|
+
* those the account allowed it (their `hubby:` scope).
|
|
648
|
+
*/
|
|
649
|
+
export declare function useContributions<P extends ContributionPoint>(point: P): Contribution<P>[];
|
|
650
|
+
/** Whether a hubby's amounts are blurred (its Privacy setting). */
|
|
651
|
+
export declare function useAmountsBlurred(hubby: string): boolean;
|
|
652
|
+
/** Whether a hubby shows: not hidden, or revealed this session. */
|
|
653
|
+
export declare function useHubbyVisible(id: string): boolean;
|
|
654
|
+
/**
|
|
655
|
+
* Whether a hidden hubby is revealed this session (the former "private mode"): the players pause
|
|
656
|
+
* when it turns false (Ctrl+Alt+Q). Kept for the hubbies built before useHubbyVisible.
|
|
657
|
+
*/
|
|
658
|
+
export declare function usePrivateMode(): boolean;
|
|
659
|
+
/**
|
|
660
|
+
* An amount of a hubby (money, a balance…): blurred when the hubby's Privacy asks for it
|
|
661
|
+
* (`supports: ['amounts']`), a click shows that one until it is clicked again, the page is left or
|
|
662
|
+
* Ctrl+Alt+Q. Not for an amount being typed (a field): only shown ones.
|
|
663
|
+
*/
|
|
664
|
+
export declare function Amount({ hubby, module, children, className }: {
|
|
665
|
+
hubby?: string;
|
|
666
|
+
/** @deprecated hubby: its SDK 2 name, still read for the hubbies built before the rename */
|
|
667
|
+
module?: string;
|
|
668
|
+
children: ReactNode;
|
|
669
|
+
className?: string;
|
|
670
|
+
}): import("react").JSX.Element;
|
|
671
|
+
/**
|
|
672
|
+
* Non-2xx response. `message` stays `HTTP <status>` (callers match on it); `detail`
|
|
673
|
+
* carries the server's problem+json explanation when there is one.
|
|
674
|
+
*/
|
|
675
|
+
export declare class ApiError extends Error {
|
|
676
|
+
readonly status: number;
|
|
677
|
+
readonly detail: string | null;
|
|
678
|
+
constructor(status: number, detail: string | null);
|
|
679
|
+
}
|
|
680
|
+
/** Best human-readable message for a caught error: server detail first. */
|
|
681
|
+
export declare function errorMessage(err: unknown, fallback?: string): string;
|
|
682
|
+
export declare function api<T>(path: string, options?: RequestInit, retry?: boolean): Promise<T>;
|
|
683
|
+
/**
|
|
684
|
+
* The server's base URL. Given the path called, the routes of the hubbies reached through the VPN
|
|
685
|
+
* (their data, their capabilities, their media: as they declare, core/hubby/declarations.ts) go to
|
|
686
|
+
* the name only reachable through it (prod): the desktop routes that name through the tunnel, the
|
|
687
|
+
* phone routes everything through it in private mode. Development: one local server.
|
|
688
|
+
*/
|
|
689
|
+
export declare function getApiBaseUrl(path?: string): string;
|
|
690
|
+
export type StreamEventHandler = (event: string, data: unknown) => void;
|
|
691
|
+
/**
|
|
692
|
+
* Opens an authenticated server-sent event stream — over fetch, so it can POST a
|
|
693
|
+
* body and carry the token — and resolves once the server closes it. Like api(),
|
|
694
|
+
* a 401 refreshes the token once before giving up.
|
|
695
|
+
*/
|
|
696
|
+
export declare function apiStream(path: string, options: RequestInit, onEvent: StreamEventHandler, retry?: boolean): Promise<void>;
|
|
697
|
+
/**
|
|
698
|
+
* Parses a text/event-stream body, calling onEvent with each event name and its
|
|
699
|
+
* JSON-decoded data. Comments, empty blocks and undecodable data are skipped.
|
|
700
|
+
*/
|
|
701
|
+
export declare function readEventStream(body: ReadableStream<Uint8Array>, onEvent: StreamEventHandler): Promise<void>;
|
|
702
|
+
export declare function fetchSettings<T = Record<string, unknown>>(scope: string): Promise<T>;
|
|
703
|
+
export declare function updateSettings<T = Record<string, unknown>>(scope: string, values: Partial<T>): Promise<T>;
|
|
704
|
+
/** Standard JSON envelopes returned by the hub API. */
|
|
705
|
+
export interface SingleResponse<T> {
|
|
706
|
+
data: T;
|
|
707
|
+
}
|
|
708
|
+
export interface ListResponse<T> {
|
|
709
|
+
data: T[];
|
|
710
|
+
}
|
|
711
|
+
/** Paginated list envelope (data + page metadata). */
|
|
712
|
+
export interface PaginatedResponse<T> {
|
|
713
|
+
data: T[];
|
|
714
|
+
meta: {
|
|
715
|
+
page: number;
|
|
716
|
+
limit: number;
|
|
717
|
+
total: number;
|
|
718
|
+
pages: number;
|
|
719
|
+
};
|
|
720
|
+
}
|
|
721
|
+
export declare function ensureIntegrationForUrl(rawUrl: string): Promise<void>;
|
|
722
|
+
/**
|
|
723
|
+
* Sync probe — true if the domain has already been checked (positive or
|
|
724
|
+
* negative). Lets call-sites skip the async await on hot paths.
|
|
725
|
+
*/
|
|
726
|
+
export declare function isIntegrationKnownSync(rawUrl: string): boolean;
|
|
727
|
+
/** A site's player scripts, served by the back (the web socle, Resources/<host>/). */
|
|
728
|
+
export interface PlayerScripts {
|
|
729
|
+
/** run on the video page (page mode) to isolate the player */
|
|
730
|
+
page: string | null;
|
|
731
|
+
/** run on a bare embed player (embed mode) */
|
|
732
|
+
embed: string | null;
|
|
733
|
+
pause: string | null;
|
|
734
|
+
}
|
|
735
|
+
export interface PlayerConfig {
|
|
736
|
+
/** the host whose scripts apply to the requested domain */
|
|
737
|
+
host: string;
|
|
738
|
+
scripts: PlayerScripts;
|
|
739
|
+
}
|
|
740
|
+
/**
|
|
741
|
+
* The player config for a domain, null when the back has no scripts for the
|
|
742
|
+
* site (it is then loaded as-is). A failed lookup resolves null too, and is
|
|
743
|
+
* retried next time.
|
|
744
|
+
*/
|
|
745
|
+
export declare function getPlayerConfig(domain: string): Promise<PlayerConfig | null>;
|
|
746
|
+
/**
|
|
747
|
+
* Makes sure the shell holds the back's current player blocklist before a
|
|
748
|
+
* player loads a site: once per session, a 304 when nothing changed. A failure
|
|
749
|
+
* leaves the shell's previous list in place and is retried next time.
|
|
750
|
+
*/
|
|
751
|
+
export declare function syncPlayerBlocklist(): Promise<void>;
|
|
752
|
+
export type ButtonColor = "primary" | "secondary" | "danger";
|
|
753
|
+
export interface ButtonProps {
|
|
754
|
+
label?: ReactNode;
|
|
755
|
+
children?: ReactNode;
|
|
756
|
+
icon?: IconDefinition;
|
|
757
|
+
color?: ButtonColor;
|
|
758
|
+
isDisabled?: boolean;
|
|
759
|
+
isLoading?: boolean;
|
|
760
|
+
className?: string;
|
|
761
|
+
onClick?: MouseEventHandler<HTMLButtonElement>;
|
|
762
|
+
type?: "button" | "submit" | "reset";
|
|
763
|
+
title?: string;
|
|
764
|
+
"aria-label"?: string;
|
|
765
|
+
}
|
|
766
|
+
export declare function Button({ label, children, icon, onClick, className, color, isDisabled, isLoading, type, ...rest }: ButtonProps): import("react").JSX.Element;
|
|
767
|
+
export type IconButtonColor = "primary" | "secondary" | "danger" | "dark";
|
|
768
|
+
export type IconButtonShape = "square" | "circle";
|
|
769
|
+
export type IconButtonSize = "xxs" | "xs" | "sm" | "md" | "xl";
|
|
770
|
+
export interface IconButtonProps {
|
|
771
|
+
icon: IconDefinition;
|
|
772
|
+
onClick?: MouseEventHandler<HTMLButtonElement>;
|
|
773
|
+
className?: string;
|
|
774
|
+
active?: boolean;
|
|
775
|
+
highlighted?: boolean;
|
|
776
|
+
isDisabled?: boolean;
|
|
777
|
+
isLoading?: boolean;
|
|
778
|
+
color?: IconButtonColor;
|
|
779
|
+
shape?: IconButtonShape;
|
|
780
|
+
size?: IconButtonSize;
|
|
781
|
+
type?: "button" | "submit" | "reset";
|
|
782
|
+
title?: string;
|
|
783
|
+
"aria-label"?: string;
|
|
784
|
+
"aria-expanded"?: boolean;
|
|
785
|
+
}
|
|
786
|
+
export declare function IconButton({ icon, onClick, className, active, highlighted, isDisabled, isLoading, color, shape, size, type, ...rest }: IconButtonProps): import("react").JSX.Element;
|
|
787
|
+
type FormData$1 = Record<string, unknown>;
|
|
788
|
+
export interface FormProps {
|
|
789
|
+
initialData?: FormData$1;
|
|
790
|
+
title?: string;
|
|
791
|
+
actions?: ReactNode;
|
|
792
|
+
onSubmit: (data: FormData$1) => void | Promise<void>;
|
|
793
|
+
children: ReactNode;
|
|
794
|
+
className?: string;
|
|
795
|
+
}
|
|
796
|
+
export declare function Form({ initialData, children, ...props }: FormProps): import("react").JSX.Element;
|
|
797
|
+
export interface InputFieldProps {
|
|
798
|
+
name: string;
|
|
799
|
+
label?: string;
|
|
800
|
+
type?: HTMLInputTypeAttribute;
|
|
801
|
+
required?: boolean;
|
|
802
|
+
placeholder?: string;
|
|
803
|
+
autoComplete?: string;
|
|
804
|
+
autoFocus?: boolean;
|
|
805
|
+
min?: number | string;
|
|
806
|
+
max?: number | string;
|
|
807
|
+
step?: number | string;
|
|
808
|
+
}
|
|
809
|
+
export declare function InputField({ name, label, type, required, placeholder, ...rest }: InputFieldProps): import("react").JSX.Element;
|
|
810
|
+
/**
|
|
811
|
+
* A switch between two choices (this || that, not on/off): both labels sit in the track, the
|
|
812
|
+
* thumb slides under the picked one. SwitchField's look, blue on both sides.
|
|
813
|
+
*/
|
|
814
|
+
export declare function ChoiceSwitch<V extends string>({ value, options, label, onChange }: {
|
|
815
|
+
value: V;
|
|
816
|
+
/** `count`: a number shown after the label (e.g. results waiting there) */
|
|
817
|
+
options: [
|
|
818
|
+
{
|
|
819
|
+
value: V;
|
|
820
|
+
label: string;
|
|
821
|
+
icon?: ReactNode;
|
|
822
|
+
count?: number;
|
|
823
|
+
},
|
|
824
|
+
{
|
|
825
|
+
value: V;
|
|
826
|
+
label: string;
|
|
827
|
+
icon?: ReactNode;
|
|
828
|
+
count?: number;
|
|
829
|
+
}
|
|
830
|
+
];
|
|
831
|
+
/** said to screen readers */
|
|
832
|
+
label: string;
|
|
833
|
+
onChange: (value: V) => void;
|
|
834
|
+
}): import("react").JSX.Element;
|
|
835
|
+
/** The SwitchField switch on its own, outside a form: controlled by `checked`. */
|
|
836
|
+
export declare function Switch({ checked, onChange, title }: {
|
|
837
|
+
checked: boolean;
|
|
838
|
+
onChange: (checked: boolean) => void;
|
|
839
|
+
title?: string;
|
|
840
|
+
}): import("react").JSX.Element;
|
|
841
|
+
/** The CheckboxField box on its own, outside a form: controlled by `checked`, its label beside it. */
|
|
842
|
+
export declare function Checkbox({ checked, label, onChange }: {
|
|
843
|
+
checked: boolean;
|
|
844
|
+
label: ReactNode;
|
|
845
|
+
onChange: (checked: boolean) => void;
|
|
846
|
+
}): import("react").JSX.Element;
|
|
847
|
+
export type DropdownColor = "menu" | "field";
|
|
848
|
+
export type DropdownSide = "left" | "center" | "right";
|
|
849
|
+
export type DropdownHeader = ReactNode | ((isOpen: boolean) => ReactNode);
|
|
850
|
+
export interface DropdownProps {
|
|
851
|
+
header?: DropdownHeader;
|
|
852
|
+
children: ReactNode;
|
|
853
|
+
color?: DropdownColor;
|
|
854
|
+
side?: DropdownSide;
|
|
855
|
+
isOpen?: boolean;
|
|
856
|
+
onOpenChange?: (open: boolean) => void;
|
|
857
|
+
/** extra classes on the root (e.g. to size it inside a flex row) */
|
|
858
|
+
className?: string;
|
|
859
|
+
}
|
|
860
|
+
export declare function Dropdown({ header, children, color, side, isOpen: controlledOpen, onOpenChange, className }: DropdownProps): import("react").JSX.Element;
|
|
861
|
+
export type ModalSize = "sm" | "md" | "lg" | "xl" | "full";
|
|
862
|
+
export interface ModalProps {
|
|
863
|
+
title?: ReactNode;
|
|
864
|
+
size?: ModalSize;
|
|
865
|
+
onClose: () => void;
|
|
866
|
+
children: ReactNode;
|
|
867
|
+
}
|
|
868
|
+
export declare function Modal({ title, size, onClose, children }: ModalProps): import("react").ReactPortal;
|
|
869
|
+
export interface ConfirmationModalProps {
|
|
870
|
+
title: ReactNode;
|
|
871
|
+
size?: ModalSize;
|
|
872
|
+
confirmLabel?: string;
|
|
873
|
+
confirmColor?: ButtonColor;
|
|
874
|
+
cancelLabel?: string;
|
|
875
|
+
onConfirm: () => void | Promise<void>;
|
|
876
|
+
onClose: () => void;
|
|
877
|
+
children: ReactNode;
|
|
878
|
+
}
|
|
879
|
+
export declare function ConfirmationModal({ title, size, confirmLabel, confirmColor, cancelLabel, onConfirm, onClose, children }: ConfirmationModalProps): import("react").JSX.Element;
|
|
880
|
+
export interface TableProps {
|
|
881
|
+
children: ReactNode;
|
|
882
|
+
className?: string;
|
|
883
|
+
}
|
|
884
|
+
export declare function Table({ children, className }: TableProps): import("react").JSX.Element;
|
|
885
|
+
export type TextAlign = "left" | "center" | "right";
|
|
886
|
+
export interface TableHeadProps extends Omit<ThHTMLAttributes<HTMLTableCellElement>, "children"> {
|
|
887
|
+
textAlign?: TextAlign;
|
|
888
|
+
mobile?: boolean;
|
|
889
|
+
children?: ReactNode;
|
|
890
|
+
}
|
|
891
|
+
export declare function TableHead({ textAlign, mobile, className, children, ...rest }: TableHeadProps): import("react").JSX.Element;
|
|
892
|
+
export declare function TableHeadGroup({ children }: {
|
|
893
|
+
children: ReactNode;
|
|
894
|
+
}): import("react").JSX.Element;
|
|
895
|
+
export interface TableRowProps {
|
|
896
|
+
children: ReactNode;
|
|
897
|
+
highlighted?: boolean;
|
|
898
|
+
className?: string;
|
|
899
|
+
}
|
|
900
|
+
export declare function TableRow({ children, highlighted, className }: TableRowProps): import("react").JSX.Element;
|
|
901
|
+
export declare function TableRowGroup({ children }: {
|
|
902
|
+
children: ReactNode;
|
|
903
|
+
}): import("react").JSX.Element;
|
|
904
|
+
export interface TableCellProps extends Omit<TdHTMLAttributes<HTMLTableCellElement>, "children"> {
|
|
905
|
+
to?: string;
|
|
906
|
+
textAlign?: TextAlign;
|
|
907
|
+
mobile?: boolean;
|
|
908
|
+
children?: ReactNode;
|
|
909
|
+
}
|
|
910
|
+
export declare function TableCell({ to, textAlign, mobile, className, children, ...rest }: TableCellProps): import("react").JSX.Element;
|
|
911
|
+
/** While `open`, the back button closes this (onClose). */
|
|
912
|
+
export declare function useBackHandler(open: boolean, onClose: () => void): void;
|
|
913
|
+
/** Whether `query` (a CSS media query) currently matches; follows its changes. */
|
|
914
|
+
export declare function useMediaQuery(query: string): boolean;
|
|
915
|
+
/** An entry of a tab's menu. */
|
|
916
|
+
export interface BottomBarEntry {
|
|
917
|
+
key: string;
|
|
918
|
+
label: string;
|
|
919
|
+
/** a live label rendered instead of `label` (in the menu) */
|
|
920
|
+
Label?: ComponentType;
|
|
921
|
+
icon?: IconDefinition;
|
|
922
|
+
active: boolean;
|
|
923
|
+
onClick: () => void;
|
|
924
|
+
/** a dot: something new there */
|
|
925
|
+
dot?: boolean;
|
|
926
|
+
/** a count beside it in the menu (e.g. unread) */
|
|
927
|
+
count?: number;
|
|
928
|
+
}
|
|
929
|
+
/**
|
|
930
|
+
* A tab of the bottom bar: an action of its own (`primary`: the page's main action, a round button
|
|
931
|
+
* in the brand colour, e.g. Mail's new message), or a menu opening upwards (its entries in groups,
|
|
932
|
+
* under an optional title). An active menu tab stands for its active entry (its icon and label,
|
|
933
|
+
* highlighted) unless `fixed`: e.g. Mail's "+" while one of its folders is open.
|
|
934
|
+
*/
|
|
935
|
+
export type BottomBarTab = {
|
|
936
|
+
key: string;
|
|
937
|
+
label: string;
|
|
938
|
+
icon: IconDefinition;
|
|
939
|
+
active: boolean;
|
|
940
|
+
onClick: () => void;
|
|
941
|
+
dot?: boolean;
|
|
942
|
+
primary?: boolean;
|
|
943
|
+
} | {
|
|
944
|
+
key: string;
|
|
945
|
+
label: string;
|
|
946
|
+
icon: IconDefinition;
|
|
947
|
+
menu: {
|
|
948
|
+
title?: string;
|
|
949
|
+
entries: BottomBarEntry[];
|
|
950
|
+
}[];
|
|
951
|
+
fixed?: boolean;
|
|
952
|
+
};
|
|
953
|
+
/**
|
|
954
|
+
* The phone's bottom bar, like Android's: a hubby's pages (HubbyNav), or a page's own places
|
|
955
|
+
* (Mail's folders). A menu closes on a choice, on back, on a tap beside it, on navigation.
|
|
956
|
+
*/
|
|
957
|
+
export declare function BottomBar({ tabs }: {
|
|
958
|
+
tabs: BottomBarTab[];
|
|
959
|
+
}): import("react").JSX.Element;
|
|
960
|
+
/**
|
|
961
|
+
* A hubby's declared collection (docs/spec-hubby.md § 5): the current account's documents, kept
|
|
962
|
+
* on this device and synced through the server, which only relays them sealed
|
|
963
|
+
* (docs/plan-local-first.md, core/sync). For the hubbies running in the app; an isolated hubby gets
|
|
964
|
+
* the same through its host (@cxxi-lab/hubbyware-sdk/frame, packages/hubbyware-sdk/frame/sdk.ts).
|
|
965
|
+
*/
|
|
966
|
+
/** What the platform adds to every document. */
|
|
967
|
+
export interface HubbyDocument {
|
|
968
|
+
id: string;
|
|
969
|
+
_createdAt: string;
|
|
970
|
+
_updatedAt: string;
|
|
971
|
+
_version: number;
|
|
972
|
+
}
|
|
973
|
+
/** A filter's value: equality, or operators (`in` takes a list). Fields: indexed ones only. */
|
|
974
|
+
export type FilterValue = string | number | boolean | null | {
|
|
975
|
+
eq?: FilterValue;
|
|
976
|
+
ne?: FilterValue;
|
|
977
|
+
in?: FilterValue[];
|
|
978
|
+
gt?: FilterValue;
|
|
979
|
+
gte?: FilterValue;
|
|
980
|
+
lt?: FilterValue;
|
|
981
|
+
lte?: FilterValue;
|
|
982
|
+
exists?: boolean;
|
|
983
|
+
prefix?: string;
|
|
984
|
+
};
|
|
985
|
+
export interface CollectionQuery {
|
|
986
|
+
filter?: Record<string, FilterValue>;
|
|
987
|
+
/** fields along an index, `-` for descending (e.g. '-_updatedAt'); default '-_updatedAt' */
|
|
988
|
+
sort?: string;
|
|
989
|
+
/** 1–200, default 50 */
|
|
990
|
+
limit?: number;
|
|
991
|
+
cursor?: string;
|
|
992
|
+
}
|
|
993
|
+
export interface CollectionPage<T> {
|
|
994
|
+
data: T[];
|
|
995
|
+
next: string | null;
|
|
996
|
+
}
|
|
997
|
+
export type BatchOperation<T> = {
|
|
998
|
+
op: "create";
|
|
999
|
+
data: Partial<T>;
|
|
1000
|
+
} | {
|
|
1001
|
+
op: "update";
|
|
1002
|
+
id: string;
|
|
1003
|
+
data: Partial<T>;
|
|
1004
|
+
version?: number;
|
|
1005
|
+
} | {
|
|
1006
|
+
op: "delete";
|
|
1007
|
+
id: string;
|
|
1008
|
+
};
|
|
1009
|
+
/** One of a hubby's collections. `T`: its declared fields (the platform's are added). */
|
|
1010
|
+
export declare function collection<T extends object>(hubby: string, name: string): {
|
|
1011
|
+
find(q?: CollectionQuery): Promise<CollectionPage<T & HubbyDocument>>;
|
|
1012
|
+
findAll(q?: Omit<CollectionQuery, "cursor" | "limit">): Promise<(T & HubbyDocument)[]>;
|
|
1013
|
+
get(id: string): Promise<T & HubbyDocument>;
|
|
1014
|
+
create(data: Partial<T>): Promise<T & HubbyDocument>;
|
|
1015
|
+
createWithId(id: string, data: Partial<T>): Promise<T & HubbyDocument>;
|
|
1016
|
+
update(id: string, data: Partial<T>, version?: number): Promise<T & HubbyDocument>;
|
|
1017
|
+
replace(id: string, data: T): Promise<T & HubbyDocument>;
|
|
1018
|
+
remove(id: string): Promise<void>;
|
|
1019
|
+
batch(operations: BatchOperation<T>[]): Promise<((T & HubbyDocument) | null)[]>;
|
|
1020
|
+
};
|
|
1021
|
+
export declare function useVpnStatus(): VpnInfo;
|
|
1022
|
+
export declare function formatDuration(seconds: number | null): string;
|
|
1023
|
+
export declare function formatDate(iso: string | null): string;
|
|
1024
|
+
|
|
1025
|
+
export {
|
|
1026
|
+
FormData$1 as FormData,
|
|
1027
|
+
useHubbyVisible as useModuleVisible,
|
|
1028
|
+
};
|
|
1029
|
+
|
|
1030
|
+
export {};
|