Bridge APIs
Bridge APIs are global objects provided by the Await host. The generated section below is sourced from runtime/types/bridge.d.ts.
Usage
Bridge APIs are globals. Do not import them.
const count = AwaitStore.num('count', 0);
AwaitStore.set('count', count + 1);Use these APIs only as declared here. This reference documents the public contract, not the host implementation.
Categories
- Registration:
Await.define. - Environment:
AwaitEnv,AwaitSystem,AwaitUI. - State and files:
AwaitStore,AwaitFile,AwaitClipboard. - Data:
AwaitNetwork,AwaitWeather,AwaitHealth,AwaitLocation,AwaitCalendar,AwaitReminder. - Actions and media:
AwaitAlarm,AwaitMedia,AwaitAudio,AwaitLaunch. - Timers and logging:
setTimeout,setInterval,sleep,print,console.log.
Generated Bridge Declarations
setTimeout
Source: runtime/types/bridge.d.ts:5
export declare function setTimeout(
callback: (...args: unknown[]) => void,
ms: number,
): unknown;clearTimeout
Source: runtime/types/bridge.d.ts:9
export declare function clearTimeout(timerID: unknown): void;setInterval
Source: runtime/types/bridge.d.ts:10
export declare function setInterval(
callback: (...args: unknown[]) => void,
ms: number,
): unknown;sleep
Source: runtime/types/bridge.d.ts:14
export declare function sleep(ms: number): Promise<void>;clearInterval
Source: runtime/types/bridge.d.ts:15
export declare function clearInterval(timerID: unknown): void;print
Source: runtime/types/bridge.d.ts:16
export declare function print(...args: unknown[]): void;console
Source: runtime/types/bridge.d.ts:17
export declare const console: {
log(...args: unknown[]): void;
};AwaitClipboard
Source: runtime/types/bridge.d.ts:20
export declare const AwaitClipboard: {
set(value: string): void;
};AwaitNetwork
Source: runtime/types/bridge.d.ts:39
export declare const AwaitNetwork: {
request(
urlString: string,
config?: AwaitNetworkConfig,
): Promise<AwaitNetworkResponse>;
fanfou(urlString: string, config?: AwaitFoufouConfig): Promise<unknown>;
};AwaitWeather
Source: runtime/types/bridge.d.ts:46
export declare const AwaitWeather: {
get(config?: AwaitWeatherConfig): Promise<AwaitWeatherResult | undefined>;
};AwaitHealth
Source: runtime/types/bridge.d.ts:49
export declare const AwaitHealth: {
get(): Promise<AwaitHealthInfo | undefined>;
};AwaitLocation
Source: runtime/types/bridge.d.ts:52
export declare const AwaitLocation: {
get(config?: AwaitLocationConfig): Promise<AwaitLocationInfo | undefined>;
};AwaitCalendar
Source: runtime/types/bridge.d.ts:55
export declare const AwaitCalendar: {
get(config?: AwaitCalendarConfig): Promise<AwaitCalendarItem[] | undefined>;
};AwaitReminder
Source: runtime/types/bridge.d.ts:58
export declare const AwaitReminder: {
get(config?: AwaitReminderConfig): Promise<AwaitReminderItem[] | undefined>;
};AwaitSystem
Source: runtime/types/bridge.d.ts:61
export declare const AwaitSystem: {
get(): AwaitSystemInfo;
};AwaitAlarm
Source: runtime/types/bridge.d.ts:64
export declare const AwaitAlarm: {
schedule(config: AwaitAlarmScheduleConfig): Promise<string>;
cancel(id: string): any;
};AwaitMedia
Source: runtime/types/bridge.d.ts:68
export declare const AwaitMedia: {
nowPlayingMedia(config?: AwaitNowPlayingConfig): Promise<AwaitNowPlayingInfo>;
mediaPlayerCommand(
command: AwaitMusicPlayerCommand,
config?: AwaitMediaPlayConfig,
): Promise<void>;
};AwaitStore
Source: runtime/types/bridge.d.ts:75
export declare const AwaitStore: {
get<T>(key: string): T | undefined;
num(key: string, defaultValue?: number): number;
bool(key: string, defaultValue?: boolean): boolean;
string(key: string, defaultValue?: string): string;
array<T>(key: string, defaultValue?: T[]): T[];
delete(key: string): void;
set(key: string, value: Encodable): void;
};AwaitFile
Source: runtime/types/bridge.d.ts:84
export declare const AwaitFile: {
files(path: string): string[];
readJSON(path: string): unknown;
readText(path: string): string | undefined;
fileSize(path: string): number | undefined;
readTextByPage(
path: string,
page: number,
pageSize: number,
): string | undefined;
readTextByPages(
path: string,
pages: number[],
pageSize: number,
): Array<string | undefined>;
saveUIRenderImage(path: string, value: NativeView): void;
};AwaitAudio
Source: runtime/types/bridge.d.ts:101
export declare const AwaitAudio: {
readonly isPlayingNote: boolean;
setAudioSession(active: boolean, option?: AudioOption): void;
reinstallInstruments(): void;
playAudio(url: string, config?: AudioConfig): void;
pauseAudio(): void;
playMidi(url: string, config?: AudioConfig): void;
stopMidi(): void;
replayMidi(config?: AudioConfig): void;
recordMidi(): void;
buildSoundFont(config: SoundFontBuildConfig): Promise<SoundFontBuildResult>;
compressSoundFont(
config: SoundFontCompressConfig,
): Promise<SoundFontBuildResult>;
playNote(notes: number[] | number, config?: AudioConfig): void;
};AwaitUI
Source: runtime/types/bridge.d.ts:117
export declare const AwaitUI: {
readonly displayScale: number;
haptic(type: string): void;
};Await
Source: runtime/types/bridge.d.ts:143
export declare const Await: {
define<Intents, T extends Record<string, unknown>>(
config: AwaitDefineConfig<Intents, T>,
): AwaitDefineResult<Intents>;
};AwaitLaunch
Source: runtime/types/bridge.d.ts:148
export declare const AwaitLaunch: {
start(bundleId: string): any;
};AwaitEnv
Source: runtime/types/bridge.d.ts:151
export declare const AwaitEnv: {
readonly id: string;
readonly tag: number;
readonly host: "app" | "widget";
test(...args: unknown[]): unknown;
};Generated Bridge Helper Types
AwaitNetworkResponse
Source: runtime/types/bridge.d.ts:1
type AwaitNetworkResponse = {
code: number;
data: string;
};AwaitNetworkConfig
Source: runtime/types/bridge.d.ts:23
type AwaitNetworkConfig = {
method?: string;
headers?: Record<string, string>;
body?: Encodable;
};AwaitFoufouConfig
Source: runtime/types/bridge.d.ts:28
type AwaitFoufouConfig = {
method?: string;
image?: string;
oauthToken?: string;
oauthTokenSecret?: string;
consumerKey?: string;
consumerSecret?: string;
username?: string;
password?: string;
parameters?: Record<string, string | number | boolean>;
};AwaitDefineConfig
Source: runtime/types/bridge.d.ts:121
type AwaitDefineConfig<Intents, T extends Record<string, unknown>> = {
widget: (entry: WidgetEntry<T>) => NativeView;
widgetTimeline?: (
context: TimelineContext,
) => Timeline<T> | Promise<Timeline<T>>;
widgetIntents?: {
[IntentKey in keyof Intents]: Intents[IntentKey] extends (
...args: infer IntentArguments
) => void
? IntentArguments extends Encodable[]
? Intents[IntentKey]
: never
: never;
};
};AwaitDefineResult
Source: runtime/types/bridge.d.ts:136
type AwaitDefineResult<Intents> = {
[IntentKey in keyof Intents]: Intents[IntentKey] extends (
...args: infer IntentArguments
) => void
? (...args: IntentArguments) => IntentInfo
: never;
};AwaitGlobal
Source: runtime/types/bridge.d.ts:157
type AwaitGlobal = typeof Await;AwaitEnvGlobal
Source: runtime/types/bridge.d.ts:158
type AwaitEnvGlobal = typeof AwaitEnv;AwaitLaunchGlobal
Source: runtime/types/bridge.d.ts:159
type AwaitLaunchGlobal = typeof AwaitLaunch;AwaitUIGlobal
Source: runtime/types/bridge.d.ts:160
type AwaitUIGlobal = typeof AwaitUI;AwaitClipboardGlobal
Source: runtime/types/bridge.d.ts:161
type AwaitClipboardGlobal = typeof AwaitClipboard;AwaitNetworkGlobal
Source: runtime/types/bridge.d.ts:162
type AwaitNetworkGlobal = typeof AwaitNetwork;AwaitWeatherGlobal
Source: runtime/types/bridge.d.ts:163
type AwaitWeatherGlobal = typeof AwaitWeather;AwaitHealthGlobal
Source: runtime/types/bridge.d.ts:164
type AwaitHealthGlobal = typeof AwaitHealth;AwaitLocationGlobal
Source: runtime/types/bridge.d.ts:165
type AwaitLocationGlobal = typeof AwaitLocation;AwaitCalendarGlobal
Source: runtime/types/bridge.d.ts:166
type AwaitCalendarGlobal = typeof AwaitCalendar;AwaitReminderGlobal
Source: runtime/types/bridge.d.ts:167
type AwaitReminderGlobal = typeof AwaitReminder;AwaitSystemGlobal
Source: runtime/types/bridge.d.ts:168
type AwaitSystemGlobal = typeof AwaitSystem;AwaitAlarmGlobal
Source: runtime/types/bridge.d.ts:169
type AwaitAlarmGlobal = typeof AwaitAlarm;AwaitMediaGlobal
Source: runtime/types/bridge.d.ts:170
type AwaitMediaGlobal = typeof AwaitMedia;AwaitStoreGlobal
Source: runtime/types/bridge.d.ts:171
type AwaitStoreGlobal = typeof AwaitStore;AwaitFileGlobal
Source: runtime/types/bridge.d.ts:172
type AwaitFileGlobal = typeof AwaitFile;AwaitAudioGlobal
Source: runtime/types/bridge.d.ts:173
type AwaitAudioGlobal = typeof AwaitAudio;SleepGlobal
Source: runtime/types/bridge.d.ts:174
type SleepGlobal = typeof sleep;