tempestweb.native¶
The browser's Web APIs as typed Python awaitables — geolocation, clipboard, camera, HTTP, storage, sensors, WebPush. The same await native.<capability>() call works in Modes A and B; only who runs it on the far side of the bridge changes.
Guide with examples: Native capabilities · Native capability reference · Native event channel.
tempestweb.native ¶
tempestweb.native — typed Python wrappers over browser Web APIs (Track N).
The web sibling of tempestroid.native: each device/web capability is a typed
Python awaitable that application code calls without caring whether its Python runs
in the browser (Mode A / WASM) or on the server (Mode B). The single seam that
differs between the modes is the installed :class:NativeBridge — see
:mod:tempestweb.native.dispatch for the full Mode-A vs Mode-B explanation and
client/native/*.js for the browser glue.
Capabilities are exposed two ways. Import the module for the plan-facing namespaced calls::
from tempestweb import native
res = await native.http.request("GET", "/api/items")
pos = await native.geolocation.get()
await native.audio.play("/audio/plim.wav", volume=0.4)
result = await native.share(title="Hi", url="https://example.com")
photo = await native.camera.capture()
or import the symbols directly::
from tempestweb.native import request, get_position, ShareResult
Capabilities:
- http (N0) — :func:
~tempestweb.native.http.request(retry + backoff + idempotency), :func:~tempestweb.native.http.upload, :func:~tempestweb.native.http.poll, :func:~tempestweb.native.http.generate_idempotency_key. - audio (N1) — :func:
~tempestweb.native.audio.play/stop. - share (N2) — :func:
~tempestweb.native.share.share/ :func:~tempestweb.native.share.is_share_supported. - geolocation / clipboard / storage (N3) —
:func:
~tempestweb.native.geolocation.get,clipboard.read/write,storage.put/get/list_keys/remove(layered over IndexedDB). - camera (N4) — :func:
~tempestweb.native.camera.capture. - notifications — :func:
~tempestweb.native.notifications.notify/request_permission.
PlayResult ¶
Bases: BaseModel
The outcome of a :func:play call.
Attributes:
| Name | Type | Description |
|---|---|---|
played |
bool
|
Whether playback actually started. |
blocked |
bool
|
Whether the browser blocked autoplay (no user gesture yet). When
|
channel |
str
|
The channel the sound was routed to. |
Source code in tempestweb/native/audio.py
BatteryStatus ¶
Bases: BaseModel
A snapshot of the device battery reported by the Battery Status API.
Attributes:
| Name | Type | Description |
|---|---|---|
level |
float
|
The charge level as a fraction from |
charging |
bool
|
Whether the battery is currently charging. |
charging_time |
float
|
Seconds until the battery is fully charged ( |
discharging_time |
float
|
Seconds until the battery is empty ( |
Source code in tempestweb/native/battery.py
BluetoothDevice
dataclass
¶
A Bluetooth device paired through the Web Bluetooth API.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
str
|
The opaque device id; the client holds the live |
name |
str
|
The device's advertised name, or |
Source code in tempestweb/native/bluetooth.py
FFIBridge ¶
Mode A bridge: call client/native/*.js in-process via Pyodide FFI.
Under Pyodide, client/native/index.js exposes a single async dispatch
function on the page (window.__tempestweb_native__(envelope)) returning a
JS promise that resolves to a native_result envelope. This bridge awaits
that promise directly — Python and the Web API share the browser's one event
loop, so there is no serialization and no round-trip.
The JS callable is injected (rather than reached through a hard import js)
so the dispatch logic is unit-testable with a fake async callable that mimics
the FFI contract.
Attributes:
| Name | Type | Description |
|---|---|---|
dispatch |
Callable[[str], Awaitable[str]]
|
The injected async JS callable |
Source code in tempestweb/native/bridges.py
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 | |
call
async
¶
Dispatch a native_call envelope and await the JS promise result.
The envelope crosses to JS as a JSON string and the native_result comes
back as one, so nothing relies on FFI object conversion.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
envelope
|
dict[str, Any]
|
A |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
The |
Source code in tempestweb/native/bridges.py
subscribe
async
¶
Open an event-channel subscription in-process via the JS FFI (T-EV).
The subscribe envelope crosses to JS as a JSON string; the browser calls
the wrapped emit with each event as a JSON string, which this method
parses back into a dict before handing it to the Python emit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
capability
|
str
|
The dotted streaming capability name. |
required |
args
|
dict[str, Any]
|
JSON-able subscription arguments. |
required |
emit
|
Callable[[dict[str, Any]], None]
|
Callback invoked with each |
required |
Returns:
| Type | Description |
|---|---|
str
|
The subscription id. |
Raises:
| Type | Description |
|---|---|
BrowserUnavailableError
|
If Mode-A streaming was not wired at bootstrap. |
Source code in tempestweb/native/bridges.py
unsubscribe
async
¶
Close an event-channel subscription via the JS FFI.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sub_id
|
str
|
The id returned by :meth: |
required |
Source code in tempestweb/native/bridges.py
ProxyBridge ¶
Mode B bridge: proxy native calls to the browser over the WS/SSE transport.
The server has no Web APIs of its own, so every native_call is forwarded to
the thin client, which runs client/native/*.js against the browser Web API
and posts a native_result back. This bridge translates the
:class:~tempestweb.native.dispatch.NativeBridge contract into "send a
native_call frame, await the matching native_result frame".
Attributes:
| Name | Type | Description |
|---|---|---|
send_frame |
Callable[[dict[str, Any]], None]
|
Injected callable that ships a JSON-able frame to the client (the server session wires this to the patch transport's send path). |
timeout |
float | None
|
Seconds to wait for a |
Source code in tempestweb/native/bridges.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 | |
call
async
¶
Ship a native_call frame and await the client's native_result.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
envelope
|
dict[str, Any]
|
A |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
The |
Raises:
| Type | Description |
|---|---|
BrowserUnavailableError
|
If the bridge has been closed. |
NativeError
|
With code |
Source code in tempestweb/native/bridges.py
resolve ¶
Resolve a pending call with a native_result frame from the client.
The server session calls this when a native_result frame arrives back
over the transport.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
call_id
|
str
|
The correlation id from the |
required |
payload
|
dict[str, Any]
|
The result envelope |
required |
Returns:
| Type | Description |
|---|---|
bool
|
|
Source code in tempestweb/native/bridges.py
subscribe
async
¶
Open an event-channel subscription and ship a native_subscribe frame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
capability
|
str
|
The dotted streaming capability name. |
required |
args
|
dict[str, Any]
|
JSON-able subscription arguments. |
required |
emit
|
Callable[[dict[str, Any]], None]
|
Callback the session invokes (via :meth: |
required |
Returns:
| Type | Description |
|---|---|
str
|
The subscription id. |
Raises:
| Type | Description |
|---|---|
BrowserUnavailableError
|
If the bridge has been closed. |
Source code in tempestweb/native/bridges.py
unsubscribe
async
¶
Close a subscription and ship a native_unsubscribe frame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sub_id
|
str
|
The id returned by :meth: |
required |
Source code in tempestweb/native/bridges.py
deliver_event ¶
Deliver an inbound native_event frame to its subscription (Mode B).
The server session calls this when a native_event frame arrives. A
terminal event (done or error) also drops the subscription.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sub_id
|
str
|
The subscription id from the |
required |
payload
|
dict[str, Any]
|
The event payload ( |
required |
Returns:
| Type | Description |
|---|---|
bool
|
|
Source code in tempestweb/native/bridges.py
fail_pending ¶
Settle every in-flight call with exc (without closing the bridge).
Lets the owner (e.g. a Mode-B session at teardown) fail outstanding calls
with a domain-specific error — such as a transport-closed error — instead
of the plain :class:asyncio.CancelledError that :meth:close raises.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
exc
|
BaseException
|
The exception to set on each not-yet-settled pending future. |
required |
Source code in tempestweb/native/bridges.py
close ¶
Close the bridge, cancel in-flight calls, and end all subscriptions.
Source code in tempestweb/native/bridges.py
Photo ¶
Bases: BaseModel
A captured photo returned by the browser.
Attributes:
| Name | Type | Description |
|---|---|---|
mime_type |
str
|
The image MIME type (e.g. |
width |
int
|
Frame width in pixels. |
height |
int
|
Frame height in pixels. |
data_base64 |
str
|
The image bytes, base64-encoded (JSON-safe over the wire).
Empty when the capture asked not to carry them — see |
ref |
str
|
An opaque handle to the same bytes, still held by the client. Hand
it to :mod: |
Source code in tempestweb/native/camera.py
to_bytes ¶
ClipboardImage
dataclass
¶
An image read from the system clipboard.
Attributes:
| Name | Type | Description |
|---|---|---|
data_base64 |
str
|
The image bytes, base64-encoded (JSON-safe over the wire). |
mime_type |
str
|
The image MIME type (e.g. |
Source code in tempestweb/native/clipboard.py
Capability
dataclass
¶
One native capability's contract entry.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
The dotted capability name ( |
group |
str
|
The namespace it belongs to ( |
mode_c |
bool
|
Whether the Mode C facade ( |
streaming |
bool
|
Whether it is a streaming capability served over the native
event channel (T-EV) — many events per subscription — rather than a
single-shot request/response call. Streaming capabilities register in
the client's |
Source code in tempestweb/native/contract.py
BrowserUnavailableError ¶
Bases: RuntimeError
Raised when a native call is made with no :class:NativeBridge installed.
The capability modules always reach the browser through an installed bridge. Off-platform (a plain Python process, a unit test that forgot to install a bridge), there is no browser to call, so dispatch fails fast with this error instead of silently no-op-ing.
Source code in tempestweb/native/dispatch.py
EventBridge ¶
Bases: Protocol
A :class:NativeBridge that also serves the native event channel (T-EV).
The request/response :meth:NativeBridge.call seam is single-shot. Streaming
capabilities (geolocation.watch, sensors, network/visibility/orientation
change, media/idle, cross-tab broadcast receive, ...) need many events per
subscription over time, so a streaming bridge additionally implements
:meth:subscribe/:meth:unsubscribe.
A subscription delivers events through the injected emit callback. Each
emitted payload is one of {"event": <value>} (a data event),
{"error": <code>, "message": <detail>} (a terminal failure), or
{"done": true} (the stream ended normally). emit may be called from a
non-loop thread; implementations forward to the loop safely.
Source code in tempestweb/native/dispatch.py
subscribe
async
¶
Open a subscription and stream its events through emit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
capability
|
str
|
The dotted streaming capability name ( |
required |
args
|
dict[str, Any]
|
JSON-able subscription arguments. |
required |
emit
|
Callable[[dict[str, Any]], None]
|
Callback invoked once per event with an |
required |
Returns:
| Type | Description |
|---|---|
str
|
The subscription id used to later :meth: |
Source code in tempestweb/native/dispatch.py
unsubscribe
async
¶
Close a subscription so the browser stops delivering its events.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sub_id
|
str
|
The id returned by :meth: |
required |
NativeBridge ¶
Bases: Protocol
The seam between a native capability and the browser's Web API.
A bridge is installed once per running app (Mode A or Mode B) via
:func:install_bridge. The capability modules call :meth:call without
knowing which concrete bridge backs them.
Implementations must be safe to drive from an asyncio event loop.
Source code in tempestweb/native/dispatch.py
call
async
¶
Deliver a native_call envelope and await its native_result.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
envelope
|
dict[str, Any]
|
A |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
The result envelope |
dict[str, Any]
|
by |
Raises:
| Type | Description |
|---|---|
BrowserUnavailableError
|
If the browser channel is gone. |
Source code in tempestweb/native/dispatch.py
NativeError ¶
Bases: RuntimeError
A native Web-capability call failed in the browser.
Attributes:
| Name | Type | Description |
|---|---|---|
code |
str
|
A short machine-readable error code (e.g. |
Source code in tempestweb/native/dispatch.py
PickedFile ¶
Bases: BaseModel
A file chosen by the user via the native file picker.
Attributes:
| Name | Type | Description |
|---|---|---|
data_base64 |
str
|
The file bytes, base64-encoded (no data-URI prefix). |
mime |
str
|
The file's MIME type as reported by the browser. |
name |
str
|
The original file name. |
Source code in tempestweb/native/file.py
to_bytes ¶
Decode the picked file to raw bytes.
Returns:
| Type | Description |
|---|---|
bytes
|
The decoded file bytes. |
SaveResult ¶
Bases: BaseModel
The outcome of a :func:save call.
Attributes:
| Name | Type | Description |
|---|---|---|
method |
str
|
How the file was delivered — |
shared |
bool
|
|
Source code in tempestweb/native/file.py
FileHandle
dataclass
¶
A handle to a file opened or created through the File System Access API.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
str
|
The opaque handle id; the client holds the live |
name |
str
|
The file name (e.g. |
mime_type |
str
|
The file MIME type, or |
data_base64 |
str
|
The file bytes, base64-encoded; |
Source code in tempestweb/native/filesystem.py
Position ¶
Bases: BaseModel
A geographic position fix returned by the browser.
Mirrors GeolocationCoordinates: accuracy is always present, while
altitude is None when the device cannot report it.
Attributes:
| Name | Type | Description |
|---|---|---|
latitude |
float
|
Latitude in decimal degrees. |
longitude |
float
|
Longitude in decimal degrees. |
accuracy |
float
|
Horizontal accuracy radius in meters ( |
altitude |
float | None
|
Altitude in meters above the WGS84 ellipsoid, or |
Source code in tempestweb/native/geolocation.py
HttpResponse ¶
Bases: BaseModel
A typed HTTP response returned by the browser fetch call.
Attributes:
| Name | Type | Description |
|---|---|---|
status |
int
|
The HTTP status code. |
ok |
bool
|
Whether |
headers |
dict[str, str]
|
Response headers, lower-cased keys. |
text |
str
|
The response body decoded as text (empty string when absent). |
json_body |
Any
|
The parsed JSON body when the response was JSON, else |
Source code in tempestweb/native/http.py
RetryOptions ¶
Bases: BaseModel
Retry / exponential-backoff policy for :func:request.
An unknown keyword is an error, not a silent no-op: this is a policy the
developer writes by hand, so RetryOptions(backoff=0.5) naming a field
that does not exist means the request runs with the defaults while the code
reads as if it were configured. Every widget in the tree already refuses a
kwarg it does not declare — a policy object gets the same answer. Payload
models parsed from the browser keep ignoring extras, because there a new
client key must not break an older Python.
Attributes:
| Name | Type | Description |
|---|---|---|
attempts |
int
|
Total attempts including the first try. |
base_delay |
float
|
Seconds to wait before the first retry. |
factor |
float
|
Multiplier applied to the delay after each failed attempt. |
max_delay |
float
|
Upper bound on any single backoff delay, in seconds. |
retry_statuses |
frozenset[int]
|
HTTP status codes that should trigger a retry. |
Source code in tempestweb/native/http.py
delay_for ¶
Compute the backoff delay before the retry numbered attempt_index.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
attempt_index
|
int
|
Zero-based index of the upcoming retry ( |
required |
Returns:
| Type | Description |
|---|---|
float
|
The capped exponential delay in seconds. |
Source code in tempestweb/native/http.py
IdleState ¶
Bases: BaseModel
A snapshot of the user's idle state reported by the Idle Detection API.
Attributes:
| Name | Type | Description |
|---|---|---|
user |
str
|
The user idle state, |
screen |
str
|
The screen state, |
Source code in tempestweb/native/idle.py
InstallState ¶
Bases: BaseModel
The current PWA install state.
Attributes:
| Name | Type | Description |
|---|---|---|
can_install |
bool
|
A deferred prompt is available to fire. |
installed |
bool
|
The app reports as installed (standalone / appinstalled). |
method |
str
|
How the user can install here — |
Source code in tempestweb/native/install.py
MidiMessage ¶
Bases: BaseModel
A MIDI message received from an input port (event channel / T-EV).
Attributes:
| Name | Type | Description |
|---|---|---|
input_id |
str
|
The id of the input port the message arrived on. |
data |
list[int]
|
The MIDI message bytes (0-255 each). |
timestamp |
float
|
The high-resolution timestamp (ms) the message was received. |
Source code in tempestweb/native/midi.py
MidiPorts
dataclass
¶
The MIDI input and output ports exposed by the Web MIDI API.
Attributes:
| Name | Type | Description |
|---|---|---|
inputs |
list[dict[str, Any]]
|
The available input ports as JSON-able dicts (id, name, …). |
outputs |
list[dict[str, Any]]
|
The available output ports as JSON-able dicts; the client holds
the live |
Source code in tempestweb/native/midi.py
NetworkState
dataclass
¶
A snapshot of the browser's network conditions.
Attributes:
| Name | Type | Description |
|---|---|---|
online |
bool
|
Whether the browser reports itself as online. |
effective_type |
str
|
The effective connection type ( |
downlink |
float
|
Estimated downlink bandwidth in megabits per second. |
rtt |
int
|
Estimated round-trip time in milliseconds. |
save_data |
bool
|
Whether the user has requested reduced data usage. |
Source code in tempestweb/native/network.py
NdefMessage ¶
Bases: BaseModel
One NDEF message read from a nearby tag.
Attributes:
| Name | Type | Description |
|---|---|---|
serial_number |
str
|
The tag's serial number, or |
records |
list[dict[str, Any]]
|
The decoded NDEF records (browser-defined shape). |
Source code in tempestweb/native/nfc.py
NotificationPermission ¶
Bases: StrEnum
The browser's notification permission state.
Mirrors the Web NotificationPermission enum.
Attributes:
| Name | Type | Description |
|---|---|---|
DEFAULT |
The user has not yet chosen (notifications are not allowed yet). |
|
GRANTED |
The user allowed notifications. |
|
DENIED |
The user blocked notifications. |
Source code in tempestweb/native/notifications.py
PushState ¶
Bases: BaseModel
WebPush support and current permission, reported without prompting.
Attributes:
| Name | Type | Description |
|---|---|---|
supported |
bool
|
Whether WebPush (service worker + PushManager + Notification) is available in this context. |
permission |
str
|
The current notification permission
( |
Source code in tempestweb/native/notifications.py
Mutation ¶
Bases: BaseModel
A queued offline mutation.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
str
|
The queue row's primary key. |
owner |
str
|
The owner scope the mutation belongs to. |
idempotency_key |
str
|
The stable key the server dedups replays on. |
method |
str
|
The HTTP method ( |
url |
str
|
The target URL. |
attempts |
int
|
How many replay attempts have been made. |
status |
str
|
The row status ( |
Source code in tempestweb/native/offline.py
ReplayResult ¶
Bases: BaseModel
The outcome of a queue replay.
Attributes:
| Name | Type | Description |
|---|---|---|
sent |
int
|
How many mutations were accepted and removed. |
remaining |
int
|
How many mutations are still pending. |
failed |
int
|
How many mutations were dead-lettered this run (permanent client error, or transient attempts exhausted). |
conflicts |
int
|
How many mutations were moved to the conflict lane this run
(the server returned |
Source code in tempestweb/native/offline.py
OnnxModel ¶
Bases: BaseModel
A loaded onnxruntime-web session living on the JS side.
Attributes:
| Name | Type | Description |
|---|---|---|
session_id |
str
|
Opaque id used to address the cached session on |
input_names |
list[str]
|
The model's input names, in declaration order. |
output_names |
list[str]
|
The model's output names, in declaration order. |
Source code in tempestweb/native/onnx.py
input_name
property
¶
Name of the first (and usually only) input.
Returns:
| Type | Description |
|---|---|
str
|
The first input name. |
Raises:
| Type | Description |
|---|---|
IndexError
|
If the model declares no inputs. |
Tensor ¶
Bases: BaseModel
A dense tensor crossing the bridge as base64-encoded raw bytes.
Attributes:
| Name | Type | Description |
|---|---|---|
data_base64 |
str
|
The raw little-endian tensor bytes, base64-encoded. |
dims |
list[int]
|
The tensor shape (e.g. |
dtype |
str
|
The element type as an onnxruntime-web type string
( |
Source code in tempestweb/native/onnx.py
OrientationState
dataclass
¶
The current screen orientation.
Attributes:
| Name | Type | Description |
|---|---|---|
type |
str
|
The orientation type (e.g. |
angle |
int
|
The orientation angle in degrees ( |
Source code in tempestweb/native/orientation.py
StorageEstimate
dataclass
¶
An estimate of the origin's storage usage and quota.
Attributes:
| Name | Type | Description |
|---|---|---|
usage |
int
|
Bytes currently used by the origin. |
quota |
int
|
Total bytes available to the origin. |
Source code in tempestweb/native/quota.py
Recording
dataclass
¶
A finalized media recording.
Attributes:
| Name | Type | Description |
|---|---|---|
data_base64 |
str
|
The recorded bytes, base64-encoded (JSON-safe over the wire). |
mime_type |
str
|
The recording MIME type (e.g. |
size |
int
|
The recorded byte length. |
Source code in tempestweb/native/recorder.py
DeviceOrientation ¶
Bases: BaseModel
A device-orientation reading from the Device Orientation API.
Attributes:
| Name | Type | Description |
|---|---|---|
alpha |
float | None
|
Rotation around the z-axis in degrees (0-360), or |
beta |
float | None
|
Front-to-back tilt in degrees (-180-180), or |
gamma |
float | None
|
Left-to-right tilt in degrees (-90-90), or |
absolute |
bool
|
Whether the reading is relative to Earth's coordinate frame. |
Source code in tempestweb/native/sensors.py
Motion ¶
Bases: BaseModel
A device-motion reading from the Device Motion API.
Attributes:
| Name | Type | Description |
|---|---|---|
acceleration |
dict[str, float | None]
|
Acceleration on |
rotation_rate |
dict[str, float | None]
|
Rotation rate around |
interval |
float
|
The sampling interval in milliseconds between readings. |
Source code in tempestweb/native/sensors.py
ShareOutcome ¶
Bases: StrEnum
The outcome of a :func:share call.
Attributes:
| Name | Type | Description |
|---|---|---|
SHARED |
The OS share sheet completed (content was shared). |
|
CANCELLED |
The user dismissed the share sheet. |
|
UNSUPPORTED |
The Web Share API is unavailable in this browser. |
Source code in tempestweb/native/share.py
ShareResult ¶
Bases: BaseModel
The typed result of a :func:share call.
Attributes:
| Name | Type | Description |
|---|---|---|
outcome |
ShareOutcome
|
The :class: |
Source code in tempestweb/native/share.py
SpeechResult ¶
Bases: BaseModel
A speech-recognition (STT) result from the Web Speech API.
Attributes:
| Name | Type | Description |
|---|---|---|
transcript |
str
|
The recognized text for this result. |
is_final |
bool
|
Whether this is a finalized result ( |
confidence |
float
|
The recognizer's confidence in the transcript, |
Source code in tempestweb/native/speech.py
Voice
dataclass
¶
A speech-synthesis voice available in the browser.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
The human-readable voice name (e.g. |
lang |
str
|
The BCP-47 language tag the voice speaks (e.g. |
default |
bool
|
Whether this is the browser's default voice. |
Source code in tempestweb/native/speech.py
SyncState ¶
Bases: BaseModel
The observable state of a sync source.
Attributes:
| Name | Type | Description |
|---|---|---|
phase |
str
|
|
online |
bool
|
Last known connectivity. |
pending |
int
|
Pending (unpushed) mutation count. |
last_synced_at |
int | None
|
Epoch ms of the last successful sync, or None. |
last_summary |
SyncSummary | None
|
The last run's :class: |
error |
str | None
|
The last error message, or None. |
Source code in tempestweb/native/sync.py
SyncSummary ¶
Bases: BaseModel
The outcome of one sync run.
Attributes:
| Name | Type | Description |
|---|---|---|
sent |
int
|
Mutations accepted and removed from the write queue. |
remaining |
int
|
Mutations still pending upload. |
failed |
int
|
Mutations dead-lettered this run. |
conflicts |
int
|
Mutations moved to the conflict lane this run. |
applied |
int
|
Remote rows applied by the pull. |
Source code in tempestweb/native/sync.py
UsbDevice
dataclass
¶
A USB device granted through the WebUSB API.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
str
|
The opaque device id; the client holds the live |
vendor_id |
int
|
The USB vendor id. |
product_id |
int
|
The USB product id. |
product_name |
str
|
The device's product name, or |
Source code in tempestweb/native/usb.py
Level ¶
Bases: BaseModel
One analysis frame.
Attributes:
| Name | Type | Description |
|---|---|---|
rms |
float
|
Loudness over the frame's samples, |
peak |
float
|
The loudest single sample in the frame, |
bands |
list[float]
|
The frequency bins averaged into buckets, each |
Source code in tempestweb/native/webaudio.py
SequenceResult ¶
Bases: BaseModel
What the client scheduled.
Attributes:
| Name | Type | Description |
|---|---|---|
scheduled |
int
|
How many steps were scheduled. |
ends_in_ms |
int
|
When the last step ends, measured from the call. |
blocked |
bool
|
Whether the audio context is still suspended — the browser blocks
audio until the first user gesture, and the phrase stays scheduled
rather than raising, mirroring |
Source code in tempestweb/native/webaudio.py
Step ¶
Bases: BaseModel
One note in a phrase.
Attributes:
| Name | Type | Description |
|---|---|---|
frequency |
float
|
The pitch in hertz. |
duration_ms |
int
|
How long the note sounds. |
start_ms |
int
|
How long after the call the note starts — overlap two steps by
giving them the same |
type |
str
|
The oscillator waveform ( |
gain |
float
|
The note's peak gain, from |
attack_ms |
int
|
Ramp-up from silence to |
release_ms |
int
|
Ramp-down back to silence, for the same reason. |
Source code in tempestweb/native/webaudio.py
capture
async
¶
capture(*, facing: str = 'environment', quality: float = 0.85, mime_type: str = 'image/jpeg', include_bytes: bool = True) -> Photo
Capture a single photo from the device camera.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
facing
|
str
|
Preferred camera ( |
'environment'
|
quality
|
float
|
Encoding quality in |
0.85
|
mime_type
|
str
|
The desired output image MIME type. |
'image/jpeg'
|
include_bytes
|
bool
|
Whether to carry the image bytes back to Python. Pass
|
True
|
Returns:
| Type | Description |
|---|---|
Photo
|
The captured :class: |
Raises:
| Type | Description |
|---|---|
NativeError
|
If the user denies camera permission ( |
BrowserUnavailableError
|
If called with no native bridge installed. |
Source code in tempestweb/native/camera.py
read
async
¶
Read the current text from the system clipboard.
Returns:
| Type | Description |
|---|---|
str
|
The clipboard text, or |
Raises:
| Type | Description |
|---|---|
NativeError
|
If the read is blocked ( |
BrowserUnavailableError
|
If called with no native bridge installed. |
Source code in tempestweb/native/clipboard.py
write
async
¶
Write text to the system clipboard.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The text to place on the clipboard. |
required |
Raises:
| Type | Description |
|---|---|
NativeError
|
If the write is blocked ( |
BrowserUnavailableError
|
If called with no native bridge installed. |
Source code in tempestweb/native/clipboard.py
capability_names ¶
Return the full set of dotted capability names.
Returns:
| Type | Description |
|---|---|
frozenset[str]
|
Every capability's |
mode_c_capability_names ¶
Return the set of dotted names the Mode C facade exposes.
Returns:
| Type | Description |
|---|---|
frozenset[str]
|
The |
streaming_capability_names ¶
Return the set of streaming (event-channel) capability names.
Returns:
| Type | Description |
|---|---|
frozenset[str]
|
The |
frozenset[str]
|
client's |
Source code in tempestweb/native/contract.py
current_bridge ¶
Return the bridge installed in the current context, raising if none.
Returns:
| Type | Description |
|---|---|
NativeBridge
|
The context-local :class: |
Raises:
| Type | Description |
|---|---|
BrowserUnavailableError
|
If no bridge has been installed in this context. |
Source code in tempestweb/native/dispatch.py
install_bridge ¶
Install the native bridge for the current execution mode and context.
Called once during app bootstrap — by the WASM runtime (Mode A) with an
in-process FFI bridge, or by each server session (Mode B) with its own
transport bridge. The bridge is stored in a context-local variable, so a
Mode-B server serving many connections keeps each session's bridge isolated
(the call must run in that connection's task — which it does, since the
session's :meth:~tempestweb.runtime.session.AppSession.start is awaited
from its own run task).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bridge
|
NativeBridge
|
The :class: |
required |
Source code in tempestweb/native/dispatch.py
native_call ¶
Build a native_call envelope matching docs/contract.md.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
capability
|
str
|
The stable dotted capability name (e.g. |
required |
args
|
dict[str, Any]
|
JSON-able arguments for the capability. |
required |
call_id
|
str
|
The correlation id the client echoes back with the result. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
The serializable |
Source code in tempestweb/native/dispatch.py
native_events
async
¶
Subscribe to a streaming capability and yield its events (T-EV).
The plan-facing API for every streaming capability: it opens a subscription on
the installed bridge, yields one dict per browser event, and guarantees the
subscription is closed when the iterator is exhausted, broken out of, or its
consumer is cancelled. Backpressure-free: events are buffered in an unbounded
queue as the browser produces them.
Example::
async for pos in native_events("geolocation.watch", {"high_accuracy": True}):
app.set_state(lambda s: setattr(s, "here", pos))
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
capability
|
str
|
The dotted streaming capability name. |
required |
args
|
dict[str, Any]
|
JSON-able subscription arguments. |
required |
Yields:
| Type | Description |
|---|---|
AsyncIterator[dict[str, Any]]
|
Each event's |
Raises:
| Type | Description |
|---|---|
BrowserUnavailableError
|
If no bridge is installed, or the installed bridge does not support streaming. |
NativeError
|
If the browser reports the subscription failed. |
Source code in tempestweb/native/dispatch.py
native_subscribe ¶
Build a native_subscribe envelope for the event channel (T-EV).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
capability
|
str
|
The dotted streaming capability name ( |
required |
args
|
dict[str, Any]
|
JSON-able subscription arguments. |
required |
sub_id
|
str
|
The correlation id the client tags every event of this stream with. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
The serializable |
Source code in tempestweb/native/dispatch.py
native_unsubscribe ¶
Build a native_unsubscribe envelope for the event channel (T-EV).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sub_id
|
str
|
The id of the subscription to close. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
The serializable |
Source code in tempestweb/native/dispatch.py
resolve_native_event ¶
resolve_native_event(sub_id: str, payload: dict[str, Any], subscriptions: dict[str, Callable[[dict[str, Any]], None]]) -> bool
Deliver an inbound native_event to its subscription's emit (Mode B).
Called (on the loop thread) by a Mode-B transport bridge when a
native_event frame tagged with sub_id arrives. Mode A has no use for
this — its FFI bridge invokes emit inline from the JS callback.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sub_id
|
str
|
The subscription id parsed from the |
required |
payload
|
dict[str, Any]
|
The event payload ( |
required |
subscriptions
|
dict[str, Callable[[dict[str, Any]], None]]
|
The bridge's |
required |
Returns:
| Type | Description |
|---|---|
bool
|
|
Source code in tempestweb/native/dispatch.py
resolve_native_result ¶
resolve_native_result(call_id: str, payload: dict[str, Any], pending: dict[str, Future[dict[str, Any]]]) -> bool
Resolve a pending native call with the client's native_result (Mode B).
Called (on the loop thread) by a Mode-B transport bridge when a
native_result envelope tagged with call_id arrives back over the
channel. Mode A has no use for this — its FFI bridge resolves its own promise
inline.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
call_id
|
str
|
The correlation id parsed from the |
required |
payload
|
dict[str, Any]
|
The result envelope ( |
required |
pending
|
dict[str, Future[dict[str, Any]]]
|
The bridge's |
required |
Returns:
| Type | Description |
|---|---|
bool
|
|
bool
|
(unknown or already-settled id). |
Source code in tempestweb/native/dispatch.py
send_native_call
async
¶
Send a native_call and await the browser's typed result.
Builds an envelope with a fresh call_id, hands it to the installed bridge,
and unwraps the result: a successful value payload is returned; a failure
(ok is false) is raised as :class:NativeError. Must be called from the
asyncio loop the app runs on (i.e. inside a widget handler).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
capability
|
str
|
The stable dotted capability name. |
required |
args
|
dict[str, Any]
|
JSON-able arguments for the capability. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
The |
Raises:
| Type | Description |
|---|---|
BrowserUnavailableError
|
If no bridge is installed (off-platform). |
NativeError
|
If the browser reports the call failed ( |
Source code in tempestweb/native/dispatch.py
uninstall_bridge ¶
Remove the installed bridge for the current context (off-platform state).
Used by tests and by session teardown so a stale bridge never leaks across
apps. Resets the context-local bridge to None in the calling context.
Source code in tempestweb/native/dispatch.py
file_pick
async
¶
Open a native file picker and return the chosen file's bytes.
The FilePicker widget's event carries only a uri/name, not bytes; this
capability opens an <input type="file"> and reads the selection back as
base64 — the gallery/upload path for an on-device pipeline.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
accept
|
str
|
The accept filter (e.g. |
'image/*'
|
capture
|
str | None
|
Optional capture hint ( |
None
|
Returns:
| Type | Description |
|---|---|
PickedFile
|
The chosen :class: |
Raises:
| Type | Description |
|---|---|
NativeError
|
If the user cancels ( |
BrowserUnavailableError
|
If called with no native bridge installed. |
Source code in tempestweb/native/file.py
file_save
async
¶
Share or download a generated file in the browser.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
The suggested file name (e.g. |
required |
data
|
bytes
|
The raw file bytes to deliver. |
required |
mime_type
|
str
|
The file's MIME type (e.g. |
'application/octet-stream'
|
Returns:
| Name | Type | Description |
|---|---|---|
A |
SaveResult
|
class: |
Raises:
| Type | Description |
|---|---|
NativeError
|
If the user cancels a share that cannot fall back
( |
BrowserUnavailableError
|
If called with no native bridge installed. |
Source code in tempestweb/native/file.py
get_position
async
¶
Request a single location fix from the browser.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
high_accuracy
|
bool
|
Set |
True
|
Returns:
| Type | Description |
|---|---|
Position
|
The current :class: |
Raises:
| Type | Description |
|---|---|
NativeError
|
If the user denies permission ( |
BrowserUnavailableError
|
If called with no native bridge installed. |
Source code in tempestweb/native/geolocation.py
generate_idempotency_key ¶
Generate a fresh, URL-safe idempotency key.
Mirrors the React SDK's generateIdempotencyKey. The key lets a retried (or
offline-replayed) request be deduplicated server-side so its effect happens at
most once.
Returns:
| Type | Description |
|---|---|
str
|
A random URL-safe token (32 hex-ish characters). |
Source code in tempestweb/native/http.py
poll
async
¶
poll(url: str, *, until: Callable[[HttpResponse], bool], interval: float = 1.0, max_attempts: int = 30, headers: dict[str, str] | None = None, sleep: Callable[[float], Awaitable[None]] = asyncio.sleep) -> HttpResponse
Poll a URL until a predicate is satisfied or attempts run out.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
The URL to poll (always fetched with |
required |
until
|
Callable[[HttpResponse], bool]
|
Predicate deciding when polling is done, given the latest response. |
required |
interval
|
float
|
Seconds to wait between polls. |
1.0
|
max_attempts
|
int
|
Maximum number of polls before giving up. |
30
|
headers
|
dict[str, str] | None
|
Extra request headers. |
None
|
sleep
|
Callable[[float], Awaitable[None]]
|
Awaitable sleep, injected so tests can run without real delays. |
sleep
|
Returns:
| Name | Type | Description |
|---|---|---|
The |
HttpResponse
|
class: |
Raises:
| Type | Description |
|---|---|
NativeError
|
If a poll fails at the network level, or the predicate is
never satisfied within |
BrowserUnavailableError
|
If no native bridge is installed. |
Source code in tempestweb/native/http.py
request
async
¶
request(method: str, url: str, *, json: Any = None, headers: dict[str, str] | None = None, retry: RetryOptions | None = None, idempotency_key: str | None = None, sleep: Callable[[float], Awaitable[None]] = asyncio.sleep) -> HttpResponse
Perform an HTTP request with optional retry and idempotency.
The request is retried with exponential backoff when it fails transiently
(a retryable status code, or a network-level :class:NativeError) and the
request is safe to retry — an idempotent method, or any method carrying an
idempotency_key. The key is sent as the Idempotency-Key header so the
server deduplicates the effect across retries and offline replays.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
method
|
str
|
The HTTP method (case-insensitive). |
required |
url
|
str
|
The request URL. |
required |
json
|
Any
|
A JSON-able request body, or |
None
|
headers
|
dict[str, str] | None
|
Extra request headers. |
None
|
retry
|
RetryOptions | None
|
The retry policy. |
None
|
idempotency_key
|
str | None
|
An explicit idempotency key; also makes a non-idempotent
method (e.g. |
None
|
sleep
|
Callable[[float], Awaitable[None]]
|
Awaitable sleep, injected so tests can run without real delays. |
sleep
|
Returns:
| Type | Description |
|---|---|
HttpResponse
|
The final :class: |
HttpResponse
|
after exhausting retries. |
Raises:
| Type | Description |
|---|---|
NativeError
|
If every attempt fails at the network level. |
BrowserUnavailableError
|
If no native bridge is installed. |
Source code in tempestweb/native/http.py
upload
async
¶
upload(url: str, file: dict[str, Any], *, headers: dict[str, str] | None = None, on_progress: Callable[[float], None] | None = None) -> HttpResponse
Upload a file, reporting progress via a callback.
The browser performs a streaming upload (XMLHttpRequest/fetch with an
upload progress listener); each progress tick is proxied back and forwarded to
on_progress as a fraction in [0.0, 1.0].
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
The upload endpoint. |
required |
file
|
dict[str, Any]
|
A JSON-able descriptor of the file to upload, e.g.
|
required |
headers
|
dict[str, str] | None
|
Extra request headers. |
None
|
on_progress
|
Callable[[float], None] | None
|
Optional callback receiving the upload fraction. The final
tick is always |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
The |
HttpResponse
|
class: |
Raises:
| Type | Description |
|---|---|
NativeError
|
If the upload fails. |
BrowserUnavailableError
|
If no native bridge is installed. |
Source code in tempestweb/native/http.py
install_prompt
async
¶
Fire the stashed native install prompt after a user gesture.
Returns:
| Type | Description |
|---|---|
str
|
The outcome: |
str
|
prompt was captured, or it was already used). |
Raises:
| Type | Description |
|---|---|
BrowserUnavailableError
|
If called with no native bridge installed. |
Source code in tempestweb/native/install.py
install_state
async
¶
Report whether the app is installable and/or already installed.
Returns:
| Type | Description |
|---|---|
InstallState
|
The current :class: |
Raises:
| Type | Description |
|---|---|
BrowserUnavailableError
|
If called with no native bridge installed. |
Source code in tempestweb/native/install.py
notify
async
¶
Post a local system notification.
The notification only appears if permission has been granted (see
:func:request_permission); otherwise the browser silently drops it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
title
|
str
|
The notification title. |
required |
body
|
str
|
The notification body text. |
''
|
Raises:
| Type | Description |
|---|---|
NativeError
|
If the Notifications API is unavailable ( |
BrowserUnavailableError
|
If called with no native bridge installed. |
Source code in tempestweb/native/notifications.py
push_state
async
¶
Report WebPush support and current permission WITHOUT prompting.
Use this to decide whether to show an "enable notifications" button before
calling :func:subscribe (which must follow a user gesture).
Returns:
| Name | Type | Description |
|---|---|---|
The |
PushState
|
class: |
Raises:
| Type | Description |
|---|---|
BrowserUnavailableError
|
If called with no native bridge installed. |
Source code in tempestweb/native/notifications.py
request_permission
async
¶
Request permission to show notifications, awaiting the user's choice.
Returns:
| Type | Description |
|---|---|
NotificationPermission
|
The resulting :class: |
NotificationPermission
|
existing state if the user already chose). |
Raises:
| Type | Description |
|---|---|
NativeError
|
If the Notifications API is unavailable ( |
BrowserUnavailableError
|
If called with no native bridge installed. |
Source code in tempestweb/native/notifications.py
subscribe
async
¶
Subscribe to WebPush, returning the raw browser subscription (P3).
Asks the client to run the browser-side push flow (ensure permission, create
or reuse the pushManager subscription) with the given VAPID public key, and
hands the subscription JSON back. Persist it server-side however your app likes
(the framework does not own the endpoint schema).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vapid_public_key
|
str
|
The base64url-encoded VAPID application server key. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
The push subscription as a JSON-able dict ( |
Raises:
| Type | Description |
|---|---|
NativeError
|
If push is unsupported, permission is denied, or no service worker registration is available. |
BrowserUnavailableError
|
If called with no native bridge installed. |
Source code in tempestweb/native/notifications.py
unsubscribe
async
¶
Cancel the current WebPush subscription, if any (P3).
Asks the client to unsubscribe from pushManager. Returns whether a
subscription was actually cancelled (False when none existed).
Returns:
| Type | Description |
|---|---|
bool
|
|
Raises:
| Type | Description |
|---|---|
NativeError
|
If the unsubscribe call fails in the browser. |
BrowserUnavailableError
|
If called with no native bridge installed. |
Source code in tempestweb/native/notifications.py
offline_conflicts
async
¶
List the mutations parked in the conflict lane for an owner.
A mutation lands here when the server rejects its replay with 409,
signalling a write conflict that last-write-wins dedup cannot resolve. The
row is kept (not dropped) so the app can reconcile it explicitly.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
owner
|
str | None
|
The owner scope; defaults to the queue's default owner. |
None
|
Returns:
| Type | Description |
|---|---|
list[Mutation]
|
The conflicting mutations (an empty list when none conflicted). |
Raises:
| Type | Description |
|---|---|
BrowserUnavailableError
|
If called with no native bridge installed. |
Source code in tempestweb/native/offline.py
offline_enqueue
async
¶
offline_enqueue(method: str, url: str, body: Any = None, *, idempotency_key: str | None = None, owner: str | None = None) -> Mutation
Enqueue a mutation for durable, replay-on-reconnect delivery.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
method
|
str
|
The HTTP method. |
required |
url
|
str
|
The target URL. |
required |
body
|
Any
|
The JSON-able request body. |
None
|
idempotency_key
|
str | None
|
An explicit key the server dedups on; generated when omitted. |
None
|
owner
|
str | None
|
The owner scope; defaults to the queue's default owner. |
None
|
Returns:
| Type | Description |
|---|---|
Mutation
|
The enqueued :class: |
Raises:
| Type | Description |
|---|---|
BrowserUnavailableError
|
If called with no native bridge installed. |
Source code in tempestweb/native/offline.py
offline_failed
async
¶
List the dead-lettered (permanently failed) mutations for an owner.
A mutation is dead-lettered when it hits a permanent client error (a non-retryable 4xx) or exhausts its retry attempts on a transient failure. These rows no longer block the queue and are surfaced here for inspection or a manual retry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
owner
|
str | None
|
The owner scope; defaults to the queue's default owner. |
None
|
Returns:
| Type | Description |
|---|---|
list[Mutation]
|
The failed mutations (an empty list when none have failed). |
Raises:
| Type | Description |
|---|---|
BrowserUnavailableError
|
If called with no native bridge installed. |
Source code in tempestweb/native/offline.py
offline_pending
async
¶
List the pending mutations for an owner, oldest first.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
owner
|
str | None
|
The owner scope; defaults to the queue's default owner. |
None
|
Returns:
| Type | Description |
|---|---|
list[Mutation]
|
The pending mutations (an empty list when none are queued). |
Raises:
| Type | Description |
|---|---|
BrowserUnavailableError
|
If called with no native bridge installed. |
Source code in tempestweb/native/offline.py
offline_replay
async
¶
Replay the pending queue now.
Drains in FIFO order: accepted rows are removed; a transient failure stops
replay to preserve order and is dead-lettered once attempts are exhausted; a
permanent 4xx is dead-lettered immediately; a 409 moves the row to the
conflict lane. Neither a dead-letter nor a conflict blocks the rest of the
queue.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
owner
|
str | None
|
The owner scope; defaults to the queue's default owner. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
The |
ReplayResult
|
class: |
Raises:
| Type | Description |
|---|---|
BrowserUnavailableError
|
If called with no native bridge installed. |
Source code in tempestweb/native/offline.py
offline_size
async
¶
Count the pending mutations for an owner.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
owner
|
str | None
|
The owner scope; defaults to the queue's default owner. |
None
|
Returns:
| Type | Description |
|---|---|
int
|
The number of pending mutations. |
Raises:
| Type | Description |
|---|---|
BrowserUnavailableError
|
If called with no native bridge installed. |
Source code in tempestweb/native/offline.py
is_share_supported
async
¶
Report whether the Web Share API is available in the current browser.
Returns:
| Type | Description |
|---|---|
bool
|
|
bool
|
|
Raises:
| Type | Description |
|---|---|
BrowserUnavailableError
|
If called with no native bridge installed. |
Source code in tempestweb/native/share.py
storage_get
async
¶
Read the string value stored under a key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The storage key (an IndexedDB key, scoped to the origin). |
required |
Returns:
| Type | Description |
|---|---|
str
|
The stored string value. |
Raises:
| Type | Description |
|---|---|
NativeError
|
If the key does not exist ( |
BrowserUnavailableError
|
If called with no native bridge installed. |
Source code in tempestweb/native/storage.py
list_keys
async
¶
List the keys currently present in storage.
The keys are the origin's, not one owner's: on a device where two owners used the app, both sets come back.
Returns:
| Type | Description |
|---|---|
list[str]
|
The storage keys, or |
Raises:
| Type | Description |
|---|---|
BrowserUnavailableError
|
If called with no native bridge installed. |
Source code in tempestweb/native/storage.py
put
async
¶
Write a string value under a storage key, creating or overwriting it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The storage key (an IndexedDB key, scoped to the origin). |
required |
content
|
str
|
The string value to store. |
required |
Raises:
| Type | Description |
|---|---|
NativeError
|
If the write fails, e.g. the quota is exceeded
( |
BrowserUnavailableError
|
If called with no native bridge installed. |
Source code in tempestweb/native/storage.py
remove
async
¶
Delete the value stored under a key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The storage key (an IndexedDB key, scoped to the origin). |
required |
Raises:
| Type | Description |
|---|---|
NativeError
|
If the key does not exist ( |
BrowserUnavailableError
|
If called with no native bridge installed. |